You are on page 1of 2

// removeinitialstate.

mel
// patrick palmer, ppalmer@aw.sgi.com
// february 1, 1998
//

// removeinitialstate() takes all of the selected


// particle objects are removes the initial state. this
// is done by setattr'in the initial state attributes to
// zero.
// to add an entry to the maya initial state menu at startup
// place the following mel segment into $home/maya/scripts/usersetup.mel
// (removing the comments).
//
//// adding menus to dynamics working mode
//global proc adddynamicsmenus() {
//
// global string $gmaindynsettingsmenu;
//
// if (! `menu -q -ni $gmaindynsettingsmenu` )
// dynsettingsmenu $gmaindynsettingsmenu;
//
// // add "remove initial state for particles
// menuitem -l "remove for particle" -parent "initialstatemenu"
// -annotation "remove initial state on current particle object"
// -c "removeinitialstate" removestateall;
//}
//
//scriptjob -runonce true -cf "busy" "adddynamicsmenus";

global proc removeinitialstate() {

string $sellist[] = `ls -sl`;


string $sel;
int $count = 0;
string $shape, $shapes[];
string $attr, $attrs[];

for ($sel in $sellist) {

clear $shapes;
if (`objecttype $sel` == "particle")
$shapes[0] = $sel;
else if (`objecttype $sel` == "transform")
$shapes = `listrelatives -shapes $sel`;

for ($shape in $shapes) {

// make sure this is a particle shape


if (`objecttype $shape` != "particle")
continue;

// clear out all of the double arrays


$attrs = `particle -q -ppd $shape`;
for ($attr in $attrs) {
if (`attributequery -exists -n $shape ($attr +
"0")`)
setattr ($shape+"."+$attr+"0") -type
"doublearray" 0;
}

// clear out all of the vector arrays


$attrs = `particle -q -ppv $shape`;
for ($attr in $attrs) {
if (`attributequery -exists -n $shape ($attr +
"0")`)
setattr ($shape+"."+$attr+"0") -type
"vectorarray" 0;
}

// other attributes that need to be cleared


setattr ($shape+".nid0") 0;
setattr ($shape+".particleid0") -type "doublearray" 0;
setattr ($shape+".age0") -type "doublearray" 0;

// one more particle shape


$count++;
}
}

// if there wasn't any particle shapes selected, send error


if ($count == 0)
error "need to select a particle object";

You might also like