So in Maya, I have two objects, and I’d like to move the target object to the destination object’s world space transform. Short of tracing all the transforms up to the world, is there a way I can do this more elegantly?
I’ve been using this method in my rigging scripts that creates a locator, parent constrains it to the destination object, and parents the target object to that locator and zeroes out the transforms. I then delete the parent constraint and the locator and move on to whatever I have to with the target object. This has been working fine, but I’m wondering if there isn’t an analogous way to move one object (whose transforms are frozen) to the exact world space transforms of another object, which may itself be frozen or in the hierarchy of another transform.
I’ve tried using xform, move, the setTranslation/setTransform methods of the PyNode… nothing seems to work, and I’m wondering if I’m doing something wrong because it just seems like such a common use case.
If I’m trying to avoid using constraints (for instance, if the object I need to move is keyframed), I use setTranslation on the pynodes. There’s a handy worldSpace flag, just like the xform command, I just feel that it reads a little more straightforward than xform at a glance:
God how many times has this been asked on the Autodesk Beta forum and yet STILL Maya ships with no simple snap function!! All methods above are valid, one issue you may get is that if you have offset pivots on controllers and you’re trying to align them. If you want a simple snap function then there’s one in the Red9 pack, also capable of snapping entire rigs to other rig world space transforms which is damn handy some times.