PDA

View Full Version : expressions / evaluation


svenip
01-27-2003, 09:10 AM
hi,

i have a problem with expressions.

in generall i wanna put a command into a for loop.

so my command normal would read :
object_1.translateX = $value[$i];

the problem is that i wanna react on each object : object_1,object_2 etc etc.

so in mel i would do this with a string

$cmd = ("object_"+$i+".translateX = "+$value[$i]+";");
eval $cmd;

but the expression doesn't seem to evaluate this cmd.

any idea ?

dwalden74
01-27-2003, 10:41 AM
OK, figured it out. Itīs because your expression syntax is in MEL, *not* in the normal expression syntax. Iīll expain:

Try using it in a MEL script:

$cmd = ("object_"+$i+".translateX = "+$value[$i]+";");
eval $cmd;

This wonīt work because your mixing expression and MEL syntax. You have to use the "setAttr" command to get this to work.

This should work in your expression:

$cmd = ("setAttr object_"+$i+".translateX = "+$value[$i]+";");
eval $cmd;

However the setAttr command can slow down expression evaluation. Try to avoid it if you can! Got it?

:beer:
David

svenip
01-27-2003, 11:03 AM
yeah thought about that too. but what should i say. didn't work out in my case.:D

CGTalk Moderation
01-14-2006, 06: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.