problems with expression scripting


#1

ok i have been having some problems scripting this expression…

 the idea is that i have a bunch of files that i want to run a script in to add some noise to the basic animation.....
 
 the basic code here:
{
     string $sel[]=`ls -sl`;
     for ($node in $sel)
     	{
     	string $nGroup = `group -em -n ($node+"_noiseAnimGrp")`;
     	parent -r $nGroup $node;
     
     	addAttr -ln "amp_T_X" -at double -dv 0 $node;
     	setAttr -k 1 -l 0 ($node+".amp_T_X");
     
     	addAttr -ln "freq_T_X" -at double -dv 1 $node;
     	setAttr -k 1 -l 0 ($node+".freq_T_X");
     
     	expression -s "($nGroup+\".translateX\") = (noise(time*($node+\".freq_T_X\")))*($node+\".amp_T_X\");
)"  -o $node -ae 1 -uc all ;
     	}
     }
 basic usage is that i have an animated locator, i am making a null parented under it, that null is being animated via expression. the expression  is driven by attrs that i added to the locator like amplitude and frequency....
 
 the problem is in the expression code somewhere.... gives me 

     // Error:  // 
     // Error: Line 0.2: Syntax error // 
     // Error: ); // 
     // Error: Line 1.1: Syntax error // 

the acutal mel comand that was returned to me after i made the expression in the editor that i then replaced names with variables was this:

expression -s "locator1_noiseAnimGrp.translateX = (noise(time*locator1.freq_T_X))*locator1.amp_T_X;
" -o "locator1" -ae 1 -uc all ;
   
 anyone know what i am doing wrong?

#2

Hey sporked,

Like the error says, its simply just a syntactical error. One of those errors has to deal with the extra “)” you have at the end of the string for the expression. The other error has to do with the general syntax of the string + variables that you have incorporated. As of now, your expression is not receiving those variables at all, you have them within the quotes of the string so therefore making your variables into string characters instead of a container of data. You need to separate your variables outside of the quote marks and add them into the string expression…

expression -s ( $nGroup + ".translateX = (noise(time*(" + $node + ".freq_T_X)))*(" + $node + ".amp_T_X);
")  -o $node -ae 1 -uc all ;

This way it is grabbing the physical data from the variable through each loop and processing that into the expression. Hope i clarified this enough for ya, Good Luck, Nick


#3

NPuetz,
thanks man, yea i was trying to concatenate the variables into the string before too but i was still getting the syntax errors so i gave up and went home… but your section seems to work i guess it was the extra parentheses that were messing me up…i must have been looking at it too long.
thanks a million


#4

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.