View Full Version : Assigning an expression fails...


BadG3r
07 July 2007, 11:31 AM
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; \n float $equo2 = 150+(1.05*noise(rand(time))); \n"
+$obj+ ".switch = 1-(smoothstep(-21,6,"+$obj+".translateY)); \n"
+$obj+ ".rotateX = (" +$obj+ ".switch * $equo2) + ((1-("+$obj+".switch)) * $equo1); \n"
$obj;}

-----

the error maya gives me looks like this

// Error: +($obj+ ".switch")+" = 1-(smoothstep(-21,6,"+($obj+".translateY")+")); \n" //
// 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

trancor
07 July 2007, 04:57 PM
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; \r\nfloat $equo2 = 150+(1.05*noise(rand(time)));\r\n"+$obj+".switch = 1-(smoothstep(-21,6,"+$obj+".translateY));\r\n"+$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")+")); \n" //

that +" isn't in your code.

BadG3r
07 July 2007, 07:04 PM
yeah that was my fault...

well thanks to your advice im an error further ;)

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; \n float $equo2 = 150+(1.05*noise(rand(time))); \n"
+$obj+ ".switch = 1-(smoothstep(-21,6,"+$obj+".translateY)); \n"
+$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....

trancor
07 July 2007, 07:19 PM
+$obj+ ".rotateX = ("+$obj+".switch * $equo2) + ((1-("+$obj+".switch)) * $equo1);")};
// Error: +$obj+ ".rotateX = ("+$obj+".switch * $equo2) + ((1-("+$obj+".switch)) * $equo1);")}; //

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);")}

BadG3r
07 July 2007, 07:30 PM
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);")}

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.

BadG3r
07 July 2007, 07:33 PM
and to confirm your first post. the ( ) are needed otherwise it won't work, too.

trancor
07 July 2007, 07:34 PM
Well at least you got it, haha, forgot it was a loop running.

CGTalk Moderation
07 July 2007, 07:34 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.


1