string $sel[] = `ls -selection`;
float $m[] = `xform -ws -q -t $sel[1]`;
I have two objects. I want to copy the translation coordinates of one object to other.
In above mentioned code,
I would store the translation coordinates of second object in $m[].
How can I tranfer it to first object? Basically to $sel[0]. HELP!!!
Replies
Select the item you want to move first, then select the item you want it to move to. Then in the Channel Box, select the translate X value and hit tab 3 times.
In case you want MEL anyway:
This'll move all selected objects to the last selected object.
@sukhpreet I would recommend Oglu's answer over mine. It works on multiple objects in exactly the same way as my script but it's an internal Maya command which means it's probably slightly more performant.
If you need to call this from MEL, it's simply: MatchTranslation;