tbh its mel counterpart is slightly quicker (around 5% over 1000 iterations), but thats just me being picky, but good to know for heavier scripts, using python only really when its doing something mel cant do or if it does it faster than mel (ie file handling) - which is just personal preference.
and for small useful scripts like this, i like sticking them into for loops, giving options for use, ie to set same pivot for all selected objects from the ‘tallest’ one, or to give each object its own new pivot. personally i like having a choice in scripts, i find i use them more then
oh and 1 more thing the “makeIdentity” command, you’ll want to define the translate flag, as at the mo its using the users prefs.
ie
makeIdentity -apply true -t 1 ;
or
mc.makeIdentity(apply=True,t=True)
[QUOTE=ldunham1;11749]oh and 1 more thing the “makeIdentity” command, you’ll want to define the translate flag, as at the mo its using the users prefs.
ie
makeIdentity -apply true -t 1 ;
or
mc.makeIdentity(apply=True,t=True)[/QUOTE] @idunham1 :Thanks…
but this is used in our project to quickly move the pivot for those objects will be populated in the engine and snapped on the terrain. There will be variations inside the engine with scale and rotation, that’s why i made it to freeze all the attributes.
I can add a choice as you mentioned in the previous comment.
This works too, it just centers the pivot then moves it to the bottom =)
from pymel.all import *
selection = ls(sl=True)
for selected in selection:
# center the pivot
xform(selected, cp=True)
# determine the bounding box so we know where to put our pivot
# bounding_box = xmin ymin zmin xmax ymax zmax.
bounding_box = xform(selected, q=True, boundingBox=True, ws=True)
xmin, ymin, zmin, xmax, ymax, zmax = bounding_box
# move the pivot points in the Y direction to the bottom Y point
move(ymin, [selected.scalePivot,selected.rotatePivot], y=True, absolute=True)
[QUOTE=nIcardo;11758]@idunham1 :Thanks…
but this is used in our project to quickly move the pivot for those objects will be populated in the engine and snapped on the terrain. There will be variations inside the engine with scale and rotation, that’s why i made it to freeze all the attributes.
I can add a choice as you mentioned in the previous comment.[/QUOTE]
sorry…
for some reason I was under the impression that makeIdentity -apply true would use the users freezeTrans optionVar to determine what attributes to freeze.