PDA

View Full Version : query all non-default attributes that have been added to a particle


rxgeez
11-24-2009, 01:43 AM
I want to know if there is a way to query all of a particles attributes...but only ones created or added (so all attributes other then the default ones)

The only thing I can think of is to get all the attrs of a fresh newly created particle and then use that list to compare against all the attributes of the other particle.

Basically I want to be able to select a particle and get all the custom attributes the user has added including the rgb or opacity or any of the attributes in the "add Dynamic Attribute" list under the particle tab.........any ideas?




{
*edit* this looks like it will return all the possible attributes i'd want...now i would just have to compare these to a list of the default attributes.

$ppd = `particle -q -perParticleDouble particle1`;
$ppv = `particle -q -perParticleVector particle1`;


does anyone know of a better or more efficient way?
}


{
**edit 2** Heres what I've come up with:

$ppd1 = `nParticle -q -perParticleDouble nParticle1`;
$ppv1 = `nParticle -q -perParticleVector nParticle1`;
$ppAll1 = `sort (stringArrayCatenate($ppd1, $ppv1))`;

$ppd2 = `nParticle -q -perParticleDouble nParticle2`;
$ppv2 = `nParticle -q -perParticleVector nParticle2`;
$ppAll2 = `sort (stringArrayCatenate($ppd2, $ppv2))`;


for($each in $ppAll2){
int $found = stringArrayContains($each, $ppAll1);
if (!$found){
print ("no -- " + $each + "\n");
}
}

}

Derek Wolfe
12-01-2009, 07:07 PM
You could use a convention where all of your added attributes contain an identifiable string within them that is not in any of the default attributes. Then sort based on that string.
For the standard added attributes like rgbPP, you could simply compare against a list.

rxgeez
12-01-2009, 07:41 PM
yeah thanks for the response....but I'd like to be able to get all those attributes from any particle in any scene.

Basically the main reason for this is I'm writing a tool that would ultimately create a template txt file that would contain all the attrs, expressions, connections, ect of a selected particle so that it can be recreated at anytime.



I managed to come up with something that works for me. A combination of 3 commands:

//get all float pp attrs
string $ppdAttrsDefault[] = `nParticle -q -perParticleDouble nParticleShape1`;

//get all vector pp attrs
string $ppvAttrsDefault[] = `nParticle -q -perParticleVector nParticleShape1`;

//get all scalar attrs
string $scalarAttrsDefault[] = `listAttr -output nParticleShape1`;

stooch
12-01-2009, 08:35 PM
cmds.listAttr(userDefined=1) (python syntax)

check out the docs for more info.

Derek Wolfe
12-01-2009, 10:24 PM
Oh. Perhaps create the particle setup as you want it to be, with the attributes and connections required, then save it as a .ma file. It is a text file that maya is able to read to recreate your scene at any time in the future.

CGTalk Moderation
12-01-2009, 10:24 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.