Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 17-06-2016 , 03:00 PM
Registered User
Join Date: May 2012
Posts: 3

MEL getAttr and setAttr help - Extreme Newby

Hey guys,
I'm a new user to maya and extremely new to MEL. I have a nurbs curve and a gravitational field affecting a particle system. I want to link the direction of graviational field to the roration attributes of nurbs curve. I tried the following in the create new expression tab for "direction" attribute of the gravitational field:
{
float $X = 'getAttr nurbsCircle1.rotateX';
float $Z = 'getAttr nurbsCircle1.rotateZ';

gravityField1.directionX = -1*sind($Z);
gravityField1.directionY = cosd($X)+cosd($Z);
gravityField1.directionZ = sind($X);
}

I get tons of errors:
// Error: float $X = 'getAttr nurbsCircle1.rotateX'; //
// Error: Line 1.12: Syntax error //
// Error: float $Z = 'getAttr nurbsCircle1.rotateZ'; //
// Error: Line 2.12: Syntax error //

Please help user added image

# 2 17-06-2016 , 06:18 PM
EduSciVis-er
Join Date: Dec 2005
Location: Toronto
Posts: 3,374
You need to use the back tick symbol (above the tab) instead of the single quote. ` instead of '.

Also note that that's not tons of errors, it's just two (well, one really). The first line shows you what line of code has the error, and the second tells you where exactly (line 1, position 12) and what kind of error it is. So you know there is a syntax error around the 12th character which turns out to be the ' character.


Last edited by stwert; 17-06-2016 at 06:25 PM.
# 3 18-06-2016 , 08:00 AM
Registered User
Join Date: May 2012
Posts: 3

You need to use the back tick symbol (above the tab) instead of the single quote. ` instead of '.

Also note that that's not tons of errors, it's just two (well, one really). The first line shows you what line of code has the error, and the second tells you where exactly (line 1, position 12) and what kind of error it is. So you know there is a syntax error around the 12th character which turns out to be the ' character.

Thanks a lot mate. As I told you, I'm really really new to this. Solved my problem. I owe you one...

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads