View Full Version : how to get a vector pos or rot in MEL?
RobTheRigger 12-27-2002, 01:46 AM I have Looked through the Maya help and i am yet to find what i am looking for..
I want to find the position and or the rotation vector of an object in Maya now i am very
new to Maya and in max i was only just making some headway in Maxscript but i am having
trouble doing some of the elementary things in MEL script.
to find the position vector of an object in max this is how I would do it in Maxscript
$Sphere01.pos
//then it would return
[32.342,-28.1644,0]
//to get only one dimension it is like this
$Sphere01.pos.x
32.342
//now in MEL script the one dimension is easy
Sphere01.translateX
32.342
but HOW DO I FIND THE VECTOR
?? Sphere01.translateXYZ
?? Sphere01.translate
i am looking for
<<32.342,-28.1644,0>>
this should be a one line thing and very easy, i could go
vector $Sphere01_trans = <<Sphere01.translateX, Sphere01.translateY, Sphere01.translateZ>>
but this is very messy compared to the Maxscript way of "$Sphere01.pos" so i must be
missing something.
|
|
RobTheRigger
12-27-2002, 02:23 AM
this is for expressions mainly
then i mite advance to Mel scripts
dmcgrath
12-27-2002, 03:41 AM
in MEL script you would use the getAttr and setAttr commands for many of your menial tasks. Here's something I whipped up for you.
Its just a couple of global procs that do all the work for you.
When using getAttr and setAttr (etc.) you have to type the syntax a little more exactly than maxscrpit but the result is the same.
like: getAttr nurbSphere1.tx;
getAttr nurbSphere1.ty;
getAttr nurbSphere1.tz;
The script I have here is in procedures that you can call on when you have something selected. It plugs them all into a single vector and prints it out for you in the feedback line.
This should help a little.
global proc getTrans ()
{
string $this[] = `ls -sl`;
float $tx = `getAttr $this.tx`;
float $ty = `getAttr $this.ty`;
float $tz = `getAttr $this.tz`;
vector $attrs = << $tx, $ty, $tz>>;
print $attrs;
}
global proc getRot ()
{
string $this[] = `ls -sl`;
float $rx = `getAttr $this.rx`;
float $ry = `getAttr $this.ry`;
float $rz = `getAttr $this.rz`;
vector $attrs = << $rx, $ry, $rz>>;
print $attrs;
}
//select somethign and just type getTrans or getRot and the
//result should give you a vector in the command feedback line
//enjoy
RobTheRigger
12-27-2002, 04:03 AM
dose this work for expressions as well ?
or do i need to have this script exzist on a node somwere?
dmcgrath
12-27-2002, 05:05 AM
The script above is meant only for MEL. You can save it in a text editor and then name it (like: vectorProcs.mel) and put it in your scripts folder. Maya will read it next time you start and then you can call on the procs anytime you need them.
For expressios:
Expressions are different because they are elvaluated over time in an animation. The E-editor has all the listed funcitons and a pretty good help menu to work from.
But I think you need to let me know exactly what you want to do with and expression for having me help you more. I don't know really what you are trying do.
RobTheRigger
12-27-2002, 05:33 AM
Ok at the moment i am just getting acquainted with Mel script but i am a rigger and want to get up to speed quickly so i can start working with things that are more advanced.
For instance i would like to have a script that did the job of many objects and constraints in the leg so i could make the leg script and have the script drive most of the constraints and instead of having extra system objects i just blend the positions and vectors of verabiels and then apply them to only a few objects. In animation master i had 18 bones in a leg with about 15 constraints, now this leg behaved beautifully but i want to get into even more control and keep it tidy and fast
this is one of my intermedeat goles. for now i am just trying to learn a bit of mel script
For the above Leg example were would the script exist? would it be a slower way to constrain a leg using a script or many bones?
dmcgrath
12-27-2002, 07:45 PM
Well, I'll do my best to answer your questions. Mel is great to learn and its perfect to set as an intermediate goal. Since having a deep working knowledge of Maya's toolset will be very helpful when it comes time to start scripting.
Almost every thing you mentioned, if I understood correctly, you would do quicker by hand for now. Try using set driven keys for some of the more automated things. And there are loads of constraints adnthings to play with, as well as dynamic attributes.
Also look for scripts in High End 3D (http://www.highend3d.com/) and there are a few threads around here with other links to good websites for automated scripts and stuff.
Good luck,:beer:
CGTalk Moderation
01-14-2006, 01:00 AM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.