ScriptSpot home

Forum topic · Scripts Wanted

Origin snap to nearest grid point

By joh-vyonyx · 2010-01-21

Description

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 (1)
Garp

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
)