Hi,
I have a script that combines NURBS curves. Curves with transforms, however won’t freeze their transformations before parenting.
For example, I create two NURBS curves. I scale one down. I select the outer Curve (with no scale), then the inner Curve with a scale transformation.
Then I run this script.
import pymel.core as pm
#creating a list of the selected Curves' transforms
transforms = pm.ls( selection=True, type="transform")
#freezing transformations on all Curves transforms
pm.makeIdentity( apply=True, translate=1, rotate=1, scale=1 )
#seems to have worked at this point...
for x in transforms:
print (x.getTranslation(),x.getRotation(),x.getScale())
#(dt.Vector([0.0, 0.0, 0.0]), dt.EulerRotation([0.0, 0.0, 0.0]), [1.0, 1.0, 1.0])
#(dt.Vector([0.0, 0.0, 0.0]), dt.EulerRotation([0.0, 0.0, 0.0]), [1.0, 1.0, 1.0])
#selecting the shapes within the Curves transforms
pm.pickWalk( type='nodes', direction='down')
#creating a list of the shapes
shapes = pm.ls( selection = True )
#reselecting the transforms
pm.select( transforms )
#removing the first shape from the list so it doesn't get parented to its own transform
shapes.pop(0)
#selecting the shapes list
pm.select( shapes )
#selecting the first transform last so it will be the parent transform
pm.select( transforms[0], add=True )
#parenting the selected shapes to the selected transform
pm.parent( relative=True, shape=True )
For some reason, the makeIdentity (AKA Freeze Transformations) doesn’t happen before the parenting and any NURBS curve with a transform, rotation, or scale selected AFTER a curve with a different transform gets resized.
If I freeze transformations, then run this script, it works correctly.
How can I make sure that makeIdentity has been run before I run the parent command? Thank you!