Origin snap to nearest grid point

Hey guys,

I would like to move the origin (pivot) of edit poly object to the nearest grid point in 3d. To break it down; i would select the origin of the object only, and in the x, y, z viewports move the origin to the nearest grid point. Is it possible to script this behaviour, and run it over several selected objects?

Thanks,

Jose

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Garp's picture

This should do the trick: gs

This should do the trick:

gs = getGridSpacing()
for obj in selection where classOf obj == editable_poly do
(
pPos = obj.pivot
for i = 1 to 3 do
pPos[i] = floor(pPos[i] / gs + 0.5) * gs
obj.pivot = pPos

resetXForm obj
convertTo obj editable_poly
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.