I wrote something for a buddy who wanted to do what sounds to be roughly the same thing a while back… Give this a try.
The script allows you to snap all the verts of the selected object to a grid intersection with the spacing selected in the dropdown; 1, 2, 4, 8, 16, 32, 64, 128, 256.
Then again, I may be misunderstanding what it is you’re trying to accomplish.
(Works on poly’s only.)
(
fn round x =
(
if x < 0 then
newX = (x - .5) as integer
else
newX = (x + .5) as integer
)
rollout vertSnap "Vertex Snapper" width:80 height:90
(
dropDownList ddlGrid "Grid" pos:[8,9] width:56 height:40 items:#("1", "2", "4", "8", "16", "32", "64", "128", "256")
button btnSnap "Snap" pos:[8,56] width:64 height:24
on btnSnap pressed do
(
if ((classOf selection[1]) == Editable_Poly) then
(
scale = ddlGrid.selected as integer
polyOp.setVertSelection selection[1] #all
for v = 1 to (polyOp.getNumVerts selection[1]) do
(
currentVertPos = (polyOp.getVert selection[1] v)
n = [0,0,0]
n.X = (round (currentVertPos.x / scale)) * scale
n.Y = (round (currentVertPos.y / scale)) * scale
n.Z = (round (currentVertPos.z / scale)) * scale
newVertPos = n
format "vert: % pos: % moved to %
" v (polyOp.getVert selection[1] v) n
polyOp.setVert selection[1] v newVertPos
)
piv = [0,0,0]
piv.X = (round (selection[1].pivot.x / scale)) * scale
piv.Y = (round (selection[1].pivot.y / scale)) * scale
piv.Z = (round (selection[1].pivot.z / scale)) * scale
format "Pivot pos: % moved to %
" selection[1].pivot piv
selection[1].pivot = piv
)
)
)
createDialog vertSnap
)