View Full Version : help a MEL newbee
dan1el 06-22-2007, 06:09 AM I want to make a function an if/else function.
I wrote this but it doesn't work
//Inputs
float $a=GearTrain_Driver_1.rotateX*(Spur_GearMain_GrpN_1.RotateSpeed*.5)-108.5;
//Function
{
String $b;
if (big_lever.Engaged==0)
$b=$a
else
$b=0;
return $b;
}
//Result
Spur_GearMain_GrpN_2.rotateX=$b;
the input and the result part works by itself, there is something wrong with my function part, but what it's rather simple I would say.
|
|
Don't know if you really typed this way, or if this was just some parts of your code, but this would never work this way... the syntax is all wrong...
correct way would be:
//Function
proc string find_b(string $a){
string $b;
if (big_lever.Engaged==0){
$b=$a;
}else{
$b=0;
}
return $b;
}
//Inputs
float $a=GearTrain_Driver_1.rotateX*(Spur_GearMain_GrpN_ 1.RotateSpeed*.5)-108.5;
//Result
string $b = find_b($a);
//then you can use in your setAttr function the value of $b...
setAttr -e Spur_GearMain_GrpN_2.rotateX $b;
try it out....
Daniel
trancor
06-22-2007, 05:45 PM
Don't know if what nier said worked, but this line -
float $a=GearTrain_Driver_1.rotateX*(Spur_GearMain_GrpN_ 1.RotateSpeed*.5)-108.5;
is probably causing your problems, you need to get attr before you can just call it up in code.
$geartrainRotateX=`getAttr GearTrain_Driver_1.rotateX`;
$spurRotateSpd=`getAttr Spur_GearMain_GrpN_ 1.RotateSpeed`;
float $a=$geartrainRotateX*($spurRotateSpd*.5)-108.5;
CGTalk Moderation
06-22-2007, 05:45 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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.