View Full Version : eval() in expression?

12 December 2011, 06:26 AM
I would like to copy attributes of the fluidEmiter1 to fluidEmitter2, fluidEmitter3 ....
but I don't know how to use eval in expression.
please help!

for ( $i =2; $i<6; $i ++ ){

eval("fluidEmitter" + $i).fluidDensityEmission = fluidEmitter1.fluidDensityEmission;


12 December 2011, 09:14 AM
this code seems to be working,

for ( $i =2; $i<6; $i ++ ){
eval("fluidEmitter" + $i +".fluidDensityEmission = fluidEmitter1.fluidDensityEmission");


but now i get this error
Error: Invalid use of Maya object "fluidEmitter1.fluidDensityEmission".

12 December 2011, 09:35 AM
because eval() is a mel, and you are using expression syntax inside mel, which is not supported.

you shouldn't do that kind of evaluation inside expression, anyway. A better method would be initializing the expression using mel, so that your expression would look like:

fluidEmitter1.fluidDensityEmission = fluidEmitter1.fluidDensityEmission;
fluidEmitter2.fluidDensityEmission = fluidEmitter1.fluidDensityEmission;
fluidEmitter3.fluidDensityEmission = fluidEmitter1.fluidDensityEmission;
fluidEmitter4.fluidDensityEmission = fluidEmitter1.fluidDensityEmission;
fluidEmitter5.fluidDensityEmission = fluidEmitter1.fluidDensityEmission;

12 December 2011, 11:14 AM
and why connecting stuff via connection editor, or helper script with several "connectAttr" commands, is not a viable option for you?

CGTalk Moderation
12 December 2011, 11:14 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.