Assigning an expression fails...


#1

hi guys!

any guess what the problem is???

string $selection[] = ls -sl;
string $obj;

for ($obj in $selection){
addAttr -ln “switch” -at “float” -dv 0 -min 0 -max 1 -k 1;}
dynExpression -rad
-s “float $equo1 = sind (time*150)10;
float $equo2 = 150+(1.05
noise(rand(time)));
"
+$obj+ “.switch = 1-(smoothstep(-21,6,”+$obj+”.translateY));
"
+$obj+ “.rotateX = (” +$obj+ “.switch * $equo2) + ((1-(”+$obj+".switch)) * $equo1);
"
$obj;}


the error maya gives me looks like this

// Error: +($obj+ “.switch”)+" = 1-(smoothstep(-21,6,"+($obj+".translateY")+"));
" //
// Error: Syntax error //
// Error: ($obj);}; //
// Error: Syntax error //

i guess it has something to do how to query the attribute, but don’t know how to solve it.

thx inadvance,
badger


#2

the main problem you have here is that the expression you are trying to add isn’t in ()

dynExpression -rad -s (“float $equo1 = sind (time*150)10;
float $equo2 = 150+(1.05
noise(rand(time)));
“+$obj+”.switch = 1-(smoothstep(-21,6,”+$obj+".translateY));
“+$obj+”.rotateX = ("+$obj+".switch * $equo2) + ((1-("+$obj+".switch)) * $equo1);") $obj;

and your code is different than the error you put there. I guess you coppied the error, worked on the code, then posted on this forum? Because -

// Error: +($obj+ “.switch”)+" = 1-(smoothstep(-21,6,"+($obj+".translateY")+"));
" //

that +" isn’t in your code.


#3

yeah that was my fault…

well thanks to your advice im an error further :wink:

now he stucks here…

for ($obj in $selection){
addAttr -ln “switch” -at “float” -dv 0 -min 0 -max 1 -k 1;}
dynExpression -rad
-s (“float $equo1 = sind (time*150)10;
float $equo2 = 150+(1.05
noise(rand(time)));
"
+$obj+ “.switch = 1-(smoothstep(-21,6,”+$obj+”.translateY));
"
+$obj+ “.rotateX = (”+$obj+".switch * $equo2) + ((1-("+$obj+".switch)) * $equo1);")};

// Error: +$obj+ “.rotateX = (”+$obj+".switch * $equo2) + ((1-("+$obj+".switch)) * $equo1);")}; //
// Error: Syntax error //

i checked all brackets… clear.
and the maya help file again and found this example

dynExpression -rad -s “rgbPP = rgbPP * .9;” particleShape1;

so, technically the brackets are not the problem…


#4

see the } at the very end? take that off.

you -
+$obj+ “.rotateX = (”+$obj+".switch * $equo2) + ((1-("+$obj+".switch)) * $equo1);")};

should be
+$obj+ “.rotateX = (”+$obj+".switch * $equo2) + ((1-("+$obj+".switch)) * $equo1);")}


#5

omg…

i wondered why the semicolon appeared because in my script there isn’t one and that i should spend def more time checking my posts…

and then the lighting struck me. there isn’t ANY semicolon. to execute that piece of code. now it works.

me -
+$obj+ “.rotateX = (”+$obj+".switch * $equo2) + ((1-("+$obj+".switch)) * $equo1);");}

the bracket is necessary because of the for-loop.

thx for your help.


#6

and to confirm your first post. the ( ) are needed otherwise it won’t work, too.


#7

Well at least you got it, haha, forgot it was a loop running.


#8

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.