Maya for 3D Printing - Rapid Prototyping
In this course we're going to look at something a little different, creating technically accurate 3D printed parts.
# 1 25-10-2012 , 08:51 PM
Registered User
Join Date: Sep 2010
Location: Iran
Posts: 17

mel question

Hi,
Why the following script generate a syntax error?
(the problem doesn't connected to having ident)

If (particleId % 2 == 0 )
{
goalWeight0PP=1;
goalWeight1PP=0;
}
else
{
goalWeight0PP=0;
goalWeight1PP=1;
}

# 2 25-10-2012 , 09:36 PM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
Please copy and paste the output from the script editor and show more of the code. It would help to see a larger selection of the code and the exact message in the script editor.

One thing that stands out is that ALL variables in Maya mel are prefixed by $. Therefore all of what look like variables in your example would be syntactically incorrect.

Next weights are generally expresses as fractional or floating point values between 0.0 and 1.0 you are assigning them as integers (which is really okay because they will / should be automatically cast) but for code readability you should present them as floating point values.

All variables in mel should be defined. I do not see where any of your variables are declared but once again I am assuming what are variables only based on context since syntactically you have NO variables in that snippet of code.


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675

Last edited by ctbram; 25-10-2012 at 10:55 PM.
# 3 26-10-2012 , 05:00 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Quick guess, but I'd say it's because of the capitalized I in the "If". It must be lowercase.

You also need to place the object's name in front of the attribute you wish to edit.

Eg: particle1.goalWeight0PP = ...

Note that objects names don't need to be prefixed with the $.


Imagination is more important than knowledge.

Last edited by NextDesign; 26-10-2012 at 05:03 AM.
# 4 26-10-2012 , 06:08 AM
ctbram's Avatar
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,998
I realize that object names do not need to be prefixed with $ ND; however, since I do not program in mel regularly I did not recognize those as object attributes without the object name in front of them; so to me they look like variables without the required $ prefix. More of the code would have helped.

Good call though. I did not notice the capitalized "I" in the "if" statement.


"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675

Last edited by ctbram; 26-10-2012 at 06:16 AM.
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