particleShape name in expression

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2008   #1
Angry particleShape name in expression

Hi everybody,
I have a big trouble on my particle expression and I'm not able to figure out how to fix it. So I hope you will help me to find the way...
Actually, I put all my expressions (creation, rbd and rad) in 3 differents files. It's pretty usefull 'cause these are long expression scripts.

Using a script I build my dynamics setup (particle, emitter, goal and fields) and afterwards I call each files separetly (store the result in a string) to create each expression using the dynExpression command.
Sometimes Maya is pretty smart , for instance in the creation of the particles expression is able to replace the attribute "position" or "rgbPP" by the name "particleShape.position" or "particleShape.rgbPP". That's usefull because I don't want to use any particleShape in my expressions files... it's better for kinda dynamic setup.

But...I guess this is the but you waiting for... if I use the attribute name as command parameters (`listConnections goalGeometry[0]`)... it's not working and I'm affraid there's no way for Maya to replace it.

This is an example of an expression file :

 // maya will replace "position" by "particleShape.position"
  vector $pos = position;
  vector $vel = velocity;
  
  goalPP = 1;
  
  // here I need to retrieve the goal Shape in order to send it to an inhouse plug... but it's not working because maya don't replace goalGeometry[0] by particleShape.goalGeometry[0]
  string $buf[] = `listConnections -p 1 goalGeometry[0]`;
  string $goalShape = plugNode($buf[0]);
  
  // so I'd like to use this syntax... If I set the valid name it works but i don't know how to retrieve it as string inside the expression.
  string $pShape = THE_PARTICLE_SHAPE_NAME
  string $buf[] = `listConnections -p 1 ($pShape+".goalGeometry[0]")`;
   string $goalShape = plugNode($buf[0]);
  
  string $eConnect[] = `listConnections ($pShape+".newParticles[0]")`;
  string $emitter = $eConnect[0];


Some people propose me to store the shape name, the emitter name and the goal shape name in attributes but it's not a dynamic way and I really don't like this way. If the user change the particle Shape name it will crash :-/

so if anyone have some tips to share.. I will appreciate ;-)
thanks.
 
Old 07 July 2008   #2
Maybe you could use a little simple script that you launch before your simulation. To store the name of your particle shape in a string... And then call this string in your expression.
__________________
www.zoo-prod.new.fr
 
Old 07 July 2008   #3
So you have a call something like this?
dynExpression -c -s $theFileString paritcleShape1;


Right before that couldn't you run a substitute command with a simple regular expression to replace a unique word with the correct current particle name? You might then have:

string $file; // your file you read in
 string $regularExpr = "@@@@"; // what we replace
 string $pExp; // the adjusted particle expression
 
 for ($node in $particleShapeNodes) {
     	string $pExp = `substitute $regularExpr $file $node`;
     	dynExpression -c -s $pExp $node;
     }


And that line in your file would look like:
string $buf[] = `listConnections -p 1 @@@@.goalGeometry[0]`;
__________________
twitter | vimeo
 
Old 07 July 2008   #4
Then capture the particle shape by having to select the particle first and write this code in the beginning of your script.

pickWalk -d down;
string $particle[] = `ls -sl`;
print $particle;

or use a global proc where you write in your particle as in

global proc yourMel( string $particleShape )

Either way would work and is more flexible than your way because yours assumes there is only one particle shape in your scene at one time. The above code means you can have many particle shapes but because you are specifying which one, maya knows where to apply the expression.
__________________
www.jeremyraven.co.nz
Vimeo

Last edited by Aikiman : 07 July 2008 at 11:47 PM.
 
Old 07 July 2008   #5
ok so... I think there was some misunderstanding of my explanations.

Boris, heureux de te voir ici ;-)... alors la Nouvelle Zelande c'est cool ?
In fact, use a simple string to store the particleShape name in the particle expression will not resolve the trouble.

YourDaftPunk, I already tried your tips (with "substituteAllString" command) but it will also not resolve the maya errors. Let's try this example in maya.

seed(particleShape1.particleId);
 
 vector $pos = particleShape1.position;
 vector $vel = particleShape1.velocity;
 
 string $buf[] = `listConnections -p 1 particleShape1.goalGeometry[0]`;


If you change the name of your particle (so the shape name as-well)... the expression make some failures because Maya don't replace the shape name in the last line. That's why I need to retrieve "dynamically" the particle shape name in a string and not like a simple string in order to change the particle name as I want.

thanks for your replys ;-)
 
Old 07 July 2008   #6
Ah! I see what you are saying. So the user is changing the name of the particle shape nodes after the script is run and the expressions are built... How about attaching a script job which can run when the particles are renamed?
__________________
twitter | vimeo
 
Old 07 July 2008   #7
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:56 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.