PDA

View Full Version : simple-ish variable question


bonsai_kittenz
10-13-2006, 12:33 AM
hey folks,

so i have to set up a zillion 2d fluid emitters, with very precise settings. i'll paste a bit of the preset params and then explain;

create2DFluid 120 120 100 100 1;

fluidEmitter -pos 0 0 0 -type omni -der 1 -her 1 -fer 1 -fdr 2 -r 100.0 -cye none -cyi 1 -mxd 1 -mnd 0 ;

connectDynamic -em fluidEmitter1 fluidShape1;

select -r fluid1 ;

move -r 0 45 0 ;

setAttr "fluidEmitter1.fluidDensityEmission" 600;

setAttr "fluidShape1.color[0].color_Color" -type double3 0.16 0.16 0.16 ;

setAttr "fluidShape1.color[0].color_Color" -type double3 0.121 0.121 0.121 ;

setAttr "fluidShape1.color[0].color_Color" -type double3 0.058 0.058 0.058 ;


...and it goes for another page or so with the settings. ideally what i'd love to be able to do, is declare a string at the top, which would basically be a number. then instead of manually going in and changing each 'fluidshape1' to 'fluidshape2' each time, it would grab the variable... so like fluidshape'$variable'.....although i know this syntax is wrong. i've tried every variation i can think of, the var in brackets, the var in parentheses, always returns a syntax error...also can't find something coherent in the maya help...

i know it also seems like there are easier ways around this problem than finding this variable trick out, but later in the settings it matters, that it has to be done this way unfortunately.

thank you x1000000 for any help in advance

jay

goleafsgo
10-13-2006, 12:51 AM
There will probably end up being a few ways to do what you want...but what you are probably looking for is the "eval" command. This lets you build up a command in a string variable and then execute it. So you could have a string with the base part of your object name, and then keep appending numbers to the end and execute it.

Read about it in the MEL command doc's and give it a shot...post back if you have problems.

bonsai_kittenz
10-13-2006, 04:50 PM
ah that's perfect, thank you very very much ; totally pointed me in the right direction

cheers,

jay

Nihilists
10-15-2006, 07:05 PM
Here is the code converted to use varaibles instead of hard code names:


string $fShape = `create2DFluid 120 120 100 100 1`;
string $fEmitter[] = `fluidEmitter -pos 0 0 0 -type omni -der 1 -her 1 -fer 1 -fdr 2 -r 100.0 -cye none -cyi 1 -mxd 1 -mnd 0 `;
connectDynamic -em $fEmitter2[0] $fShape;
move -r 0 45 0 $fShape;
setAttr ($fEmitter[0] + ".fluidDensityEmission") 600;
setAttr ($fShape + ".color[0].color_Color") -type double3 0.16 0.16 0.16 ;
setAttr ($fShape + ".color[0].color_Color") -type double3 0.121 0.121 0.121 ;
setAttr ($fShape + ".color[0].color_Color") -type double3 0.058 0.058 0.058 ;


-Brian
www.meljunky.com (http://www.meljunky.com)

CGTalk Moderation
10-15-2006, 07:05 PM
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.