Matt Leishman
05-22-2003, 04:20 PM
ok everyone, I'm really showing off my inexperience and "noob"ness with MEL scripting here (I'm just learning, and teaching myself isn't always a clean process :) ), but any help anyone can give with this little script I'm trying to write is really appreciated.
This script has probably already been written by someone, but I couldn't find it, and its something I do alot of in character rigging, so I figured it would be a good tool to start with in my early beginnings of learning MEL.
The idea behind it is that I'd like to snap the pivot point of one object to the pivot point of another object. Yes, I realize that this is a rather quick thing to do in Maya manually, but I do it so much that having a hotkey, or shelf button to speed it up would be great in the long run.
How I thought it could work is that first you would pick the object whose pivot you would like to snap somewhere, and then pick the object whose pivot you are snapping the previous pivot to. Then run the mel script and the first object's pivot snaps to the second objects pivot point. here is what I have so far:
// get a list of the selected objects
string $selected[0];
$selected = `ls -sl`;
//find out the pivot point of the second selected object
vector $pivot = `xform -q -piv $selected[1]`;
//move pivot of object 1 to pivot of object 2
move $pivot $selected[0].scalePivot $selected[0].rotatePivot;
Looking at it, it makes sense to me, but obviously i'm not getting it to work properly. I just don't know enough. Any direction any of you guru's can give would be awsome. Thanks for your time.
This script has probably already been written by someone, but I couldn't find it, and its something I do alot of in character rigging, so I figured it would be a good tool to start with in my early beginnings of learning MEL.
The idea behind it is that I'd like to snap the pivot point of one object to the pivot point of another object. Yes, I realize that this is a rather quick thing to do in Maya manually, but I do it so much that having a hotkey, or shelf button to speed it up would be great in the long run.
How I thought it could work is that first you would pick the object whose pivot you would like to snap somewhere, and then pick the object whose pivot you are snapping the previous pivot to. Then run the mel script and the first object's pivot snaps to the second objects pivot point. here is what I have so far:
// get a list of the selected objects
string $selected[0];
$selected = `ls -sl`;
//find out the pivot point of the second selected object
vector $pivot = `xform -q -piv $selected[1]`;
//move pivot of object 1 to pivot of object 2
move $pivot $selected[0].scalePivot $selected[0].rotatePivot;
Looking at it, it makes sense to me, but obviously i'm not getting it to work properly. I just don't know enough. Any direction any of you guru's can give would be awsome. Thanks for your time.
