View Full Version : particle runtime expr - getting the particle name

05 May 2006, 02:28 PM
Simple question. How do I get the name of the particle object in a runtime expression to which particle it belongs to?

05 May 2006, 03:40 PM
Afaik, it's unfortunately not possible to do that (you usually don't need it since maya's expressions take care of renaming and stuff when you duplicate or change the name of an object connected to an expression). In some cases you need the name of the object explicitly however, e.g. when using a mel command, e.g. getParticleAttr, inside an expression. In these situations I usually make a string variable holding the name of the object at the top of the expression code (so it's easy to find if you need to change it). Here's an example:string $theParentParticle = "particleShape1";

// some code

int $parentId = parentId;
float $parentAge [] = `getParticleAttr -at ageNormalized -array true ($theParentParticle + ".pt[" + $parentId + "]")`;

05 May 2006, 05:59 PM
That's what I thought too but wanted to ask anyway. The situation i'm working on is rather unusual. I'm creating curves that follow the particle paths and wanted to keep the naming of the curves consistent using the particle name as the prefix. It's an ugly hack anyway so I might just use your suggestion... Thanks.

05 May 2006, 09:09 AM
maybe U can use the ParticleID for that ? so U get the ID and put it in the prefix of the curveName?

05 May 2006, 08:55 AM
Yeah, too bad there isn't a "this" keyword for particle expressions. It's understandable why there can't be for common expressions since they don't really belong to an object, but are just connected to them, but particle expressions always belong to particle shape, so it would be possible there. Maybe there is a less hacky way around it (it might be possible to trace connections to/within the particle, I don't know).

Anyway, your particle effect sounds really cool, do the curves appear at each particle's creation, and if so do you have any trick to get rid of them when you rewind the animation? What will happen when you cache the particles?

Would be cool if you could share some thoughts on this.

CGTalk Moderation
05 May 2006, 08:55 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.