View Full Version : MEL: Snapping an object pivot to a joint.

09 September 2005, 03:05 PM
Hi there! I'm currently rigging up a character in MEL and am having trouble finding the code that will let met point snap the pivot of an object to a joint. If anybody can give me an answer to this it will be greatly appreciated.

09 September 2005, 01:41 AM
The script is quite long.

You have to store the xyz positions of the target in a variable,
store the xyz positions of the intial object in another.

I use a vector but you can use float if you want too.

Then move variable 1's pos to variable 2's pos.

09 September 2005, 01:57 AM
If you want to move the entire object to the joint then something like this should work:

float $test1[] = `xform -q -ws -rp joint2`;
xform -ws -t $test1[0] $test1[1] $test1[2] nurbsSphere1;

If you want to just move the pivot of the object then something like this:

float $test1[] = `xform -q -ws -rp joint2`;
xform -ws -rp $test1[0] $test1[1] $test1[2] nurbsSphere1;

09 September 2005, 03:05 AM
It's working. Thanks for that.

09 September 2005, 02:48 AM
Does it still work after you freeze the object and try to move it again?

09 September 2005, 12:22 AM
What I needed to have done was snap an empty group node to a joint. So what i ended up doing was just creating a brand new group node. Then I got the translates of the joint to the empty group node. This worked well.

09 September 2005, 07:22 PM
Don't forget to move the scalePivot too.

CGTalk Moderation
09 September 2005, 07:22 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.