View Full Version : How to merge an expression

05 May 2005, 10:03 AM
I try to create an expression to particles with the command dynExpression, like this:

dynExpression -c -s "identite=trunc(rand(1,3));" $nom_part;

But it's replace the existing creation expression in the particleShape.

It is possible to "merge" my expression after the existing expression?

05 May 2005, 10:19 AM
You have to use the + operator.
For example:

expression -s ("$herdvar = "+ (rand(1) - 0.5) +" * "+$leader+".rnds + "+$objnum+";\n"
+ "$randfac = " + $leader + ".stry;\n"
+ "$foc = "+$leader+".lf;\n" );

05 May 2005, 11:19 AM
Thank's drGonzo, but now how I can save the existing expression in a variable to add my expression after?

05 May 2005, 12:20 PM
Like so:
string $Expression = `dynExpression -c -s "mass=trunc(rand(1,3))\n;"`;

if you need inspiration for a good expression script, dissect SnowMaker. You can find it at he3D.

05 May 2005, 12:53 PM
thank a lot drGonzo

05 May 2005, 10:42 PM
I'm not sure that DrGonzo's scripts do what you want.

What you'll need to do is get the existing expression using dynExpression -q (to query it) and then add your existing expression to the end with +, then use dynExpression like you already have to put the merged expression back in.

At least, I think that will work, assuming dynExpression -q does what I think it does.

-- Mark

05 May 2005, 04:24 AM
Aha. The Master put me on the right track ;-)

Like this then:

//put an expression in editor
string $originalExpression = `dynExpression -c -s "particleShape1.mass=trunc(rand(1,3));\n"`;

//put additional expression in variable
string $additionalExpression= "particleShape1.lifespanPP=rand(1,3);\n";

//query content of creation expression
string $creationContent = `dynExpression -q -c`;

//compile result of query and additional expression
string $compiledExpression = $creationContent + $additionalExpression;
//print $compiledExpression;

//put compilation in editor
dynExpression -c -s $compiledExpression;

05 May 2005, 05:54 PM
Yes it's work :)

Thank you for your help.

CGTalk Moderation
05 May 2005, 05:54 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.