Need X-Y grid of sqrt(3)/2 : 1

I’m working on an architectural model that’ laid out on a hexagonal grid. The 1:1 grid model means I cannot snap to grid and have the right thing happen. Ideally, I’d like to set the Y grid spacing to 1 and the X grid spacing to sqrt(3)/2. How do I specify separate grid units for X and Y axes?

I would also like to be able to input expressions into the NKEY widget, such as “=10*sqrt(3)”. I know that python expressions are now supported in the Node editor. What about the Mesh editor?

M

How do I specify separate grid units for X and Y axes?
I don’t think that’s possible at the moment. You could try to poke Bf-funboard mailing list with this question.

I would also like to be able to input expressions into the NKEY widget, such as "=10sqrt(3)". I know that python expressions are now supported in the Node editor. What about the Mesh editor?
Try #10
m.sqrt(3) in any number input field.

Thanks! That’s just what I was looking for. Here’s a script that fixed up my diagonal grid. I have since found some other snapping scripts, some of which may have GUI support. But this snapped all my 1587 points to the grid I was trying to create.

#!BPY
“”" Registration info for Blender menus:
Name: ‘Snap X:Y Verticies to multiples of sqrt(3):1’
Blender: 237
Group: ‘Mesh’
Tooltip: ‘Snap X:Y to sqrt(3):1 grid’
“”"

author = “Michael Tiemann”
url = (“blender”, “elysiun”)
version = “1.0 2006-10-30”

bpydoc = “”"
This script snaps X verticies to a grid of sqrt(3) and Y verticies to
a unit grid. Z values are unaffected.
“”"

***** BEGIN GPL LICENSE BLOCK *****

Copyright © 2006 Michael Tiemann

This program is free software; you can redistribute it and/or

modify it under the terms of the GNU General Public License

as published by the Free Software Foundation; either version 2

of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software Foundation,

Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

***** END GPL LICENCE BLOCK *****

--------------------------------------------------------------------------

import sys
import math
from Blender import *

def main():
scn = Scene.GetCurrent()
ob = scn.getActiveObject() # Gets the current active object (If Any)

if ob == None or ob.getType() != 'Mesh': # Checks the active objects a mesh
    Draw.PupMenu('ERROR%t|Select a mesh object.')
    return
    
Window.WaitCursor(1) # So the user knowns the script is buisy.
    
is_editmode = Window.EditMode() # Store edit mode state
if is_editmode: Window.EditMode(0) # Python must get a mesh in object mode.
    
me = ob.getData()
obloc = ob.getLocation()
scale = ob.getSize()

unit = 1
sqrt3 = math.sqrt(3)

#================#
# EDIT MESH HERE #
#================#
for v in me.verts:
    if v.sel: # Operating on selected verts is what the user expects.
        free_y = (v.co.y * scale[1] + obloc[1]) / unit
        snap_y = round(free_y)
        if ((free_y != snap_y) & (abs(free_y - snap_y) < 0.02)):
            print v.co
            v.co.y = (snap_y * unit - obloc[1]) / scale[1]
            print "y"
        free_x = (v.co.x * scale[0] + obloc[0]) / sqrt3
        snap_x = round(free_x)
        if ((free_x != snap_x) & (abs(free_x - snap_x) < 0.02)):
            print "x"
            v.co.x = ((snap_x * sqrt3) - obloc[0]) / scale[0]

#================#
# FINISH EDITING #
#================#
    
me.update() # Writes the mesh back into Blender.
    
# Go back into editmode if we started in edit mode.
if is_editmode: Window.EditMode(1)
Window.WaitCursor(0)

if name == ‘main’: # Dont run the script if its imported by another script.
main()