View Full Version : help with proper syntex

10 October 2005, 03:57 PM
i'm pretty new to mel... i'm just trying to do the simplest thing but having a hard time.
wonder if anybody can help. i don't even know where to start for looking up a proper syntex. anyways... here's what i'm trying to do.

i'm trying to move an effector to a specified place using a value from a locator

getAttr locator1.t;

and get a vaule of say 5 0 0. what i'm trying to do is subsitute that value for the move,

move 5 0 0 effector1.scalePivot effector1.rotatePivot;

i figured... doing something like this would work... but it doesn't,

move `getAttr locator1.t` effector1.scalePivot effector1.rotatePivot;

i have no idea what i'm doing.
if anybody can recommend me any good books on mel for a starter or shine some light on this thing it'd be very much appreciated. thank you. =]

help a noob out. eh?

10 October 2005, 05:35 PM
I was once in your shoes, and getting started with Mel can be strange especially if you have never coded before.

First, a very good way to learn the syntax is to open the script editor and go to (Script/Echo All Commands. Then actually do things in maya and watch the mel commands execute in the script editor.

Seccond, if you go to the help menu and open the Mel Command Reference, you have acccess to mel commands, flags, descriptions and samples of how to use them. Great resource.

Third, downloading other peoples scripts and going through them to see how they did certain things is a great way to learn.

Fourth, tutorials... you can find tutorials on, etc. Just Google them and see what you come up with.

Fifth, Check out these books:
MEL scripting for maya animators


Complete Maya Programming

great books,

hope this will help point you in the right direction to learning Mel


10 October 2005, 12:23 AM
float $translate[] = `getAttr locator.t`;
print $translate[0];

// this will print your x woorld position.
// When you use getAttr on the locator.t it will return 3 values but into an // array which is represented by $array[0] $array[1] $array[3] where
// $array is the variable that name.
// So to move to the locator in question try

float $translate[] = `getAttr locator.t`;
move --absolute $translate[0] $translate[1] $translate[2];
// Remember that arrays always start with 0 as the first part.

try lots of great notes there.

good luck

10 October 2005, 12:53 AM
float $translate[] = `getAttr locator.t`;
move --absolute $translate[0] $translate[1] $translate[2];

i dont have maya open right now but im pretty sure you mean this because the -- should error out for a flag. and youd have to put the name of the effector unless it was selected.

move -absolute $translate[0] $translate[1] $translate[2] effector1;

otherwise it should work fine.

CGTalk Moderation
10 October 2005, 12:53 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.