loop help

I have four particle Shapes in My scene. the lines below switch them all off in dynamics, then one by one write out a cache named after the particle. I'm gonna have to do a quite a bit of this...

setAttr "fuelParticleLShape.isDynamic" 0;
setAttr "fuelParticleRShape.isDynamic" 0;
setAttr "airParticleLShape.isDynamic" 0;
setAttr "airParticleRShape.isDynamic" 0;

setAttr "fuelParticleLShape.isDynamic" 1;
select -r fuelParticleL ;
dynExport -path "fuelParticleL" -f cache -mnf 1 -mxf 140;
setAttr "fuelParticleLShape.isDynamic" 0;

setAttr "fuelParticleRShape.isDynamic" 1;
select -r fuelParticleR ;
dynExport -path "fuelParticleR" -f cache -mnf 1 -mxf 140;
setAttr "fuelParticleRShape.isDynamic" 0;

setAttr "airParticleLShape.isDynamic" 1;
select -r airParticleL ;
dynExport -path "airParticleL" -f cache -mnf 1 -mxf 140;
setAttr "airParticleLShape.isDynamic" 0;

it would be nice to be have a script which will do this for whatever particle shapes I have selected, using the frames start/end from the time line.. this kinda thing:

setAttr 0;

for do
{
setAttr "thisParticle.isDynamic" 1;
select -r thisParticle ;
dynExport -path "thisParticle" -f cache -mnf -mxf ;
setAttr "thisParticle.isDynamic" 0;
}

i dont know MEL and I dont have time to figure it out, so perhaps some script wizzard could oblige - you'll get a friend for life, fame, fortune* and peace of mind, and It'll help me along the road to Mel happyness

cheers!

  • fortune may not be included.

"It's so obvious, it's bound to be a trap" - Cato

//********************************
global proc dynExportSelection()
{
//get start and end-frame
float $startTime = playbackOptions -q -min;
float $endTime = playbackOptions -q -max;

//check selection
string $selection[] = ls -sl;
if ($selection[1] != "") error "more than one object selected";
if ($selection[0] == "") error "nothing selected";
$selection = ls -sl -st;
if ($selection[1] == "transform")
{
pickWalk -d "down";
$selection = ls -sl -st;
if ($selection[1] != "particle") error "please select a particle-object";
}
else if ($selection[1] != "particle") error "please select a particle-object";

string $particleName = $selection[0];

//export
setAttr ($particleName + ".isDynamic") 1;
dynExport -path $particleName -f cache -mnf $startTime -mxf $endTime;
setAttr ($particleName + ".isDynamic") 0;
}
//********************************

enjoy

Nice 1...

This'll help me on the long (and goodreference book-less) road to learning Mel. In production its always been a toss-up between a) do i devote a day to trying to figure out a good Mel script to solve my probs, or find a half assed workaround, and Mel is gonna have to wait.

Usualy It ends up with 'b' which is a shame, because I realise that a half decent knowledge of mel will open Maya right up.

thanks for your time m8.


"It's so obvious, it's bound to be a trap" - Cato