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?
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 #10m.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’
“”"
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()