View Full Version : Expression Execution Issue

10 October 2006, 08:13 PM
Hi Guys...
I'm hit with an issue here.. I have my expressions setup for my character's neck, spine & head controls which switch between the IK & FK selections by the animator.. my script gets executed fine & the expressiosn are created... but for some reason.. only when I enable the IK from the nurbs control's custom attribute, and then only after I go to the expression editor & open the respective expression & hit on the EDIT button.... only after these 2 steps... does my expression get activated... & then the rig works fine...

Is there anyway I can have my expression enabled by default after loading my cript on my rig..? I am including the expression section below for your reference...

expression -s "\r\n int $IkCond = `getAttr C_A_MainNeckCtrl_1.IkEnable`;
\r\n int $NumJoints = `getAttr C_A_MainNeckCtrl_1.dummyJointTotal`;
\r\n if ($IkCond == 1)
\r\n {
\r\n select -r[4];
\r\n cluster -bs 1 -n C_A_NeckCluster_4 -wn C_A_HeadCtrl_1 C_A_HeadCtrl_1;
\r\n }
\r\n else if($IkCond < 1)
\r\n {
\r\n pointConstraint -mo -weight 1 (\"C_j_NeckFk_\"+ $NumJoints) C_A_HeadCtrl_1 ;
\r\n }"
-o C_A_HeadCtrl_1 -n "HeadCtrlExp" -ae 1 -uc all ;



Robert Bateman
10 October 2006, 09:45 AM
dont use getAttr in expressions, just use something of the form : $var = object.attr

if you use getAttr, then Maya will not know when the expression needs to be updated

10 October 2006, 04:47 PM
Hi Robert...
For some reason I still have the same problem... Based on wht u said, Here is what I did...

$IkCond = `getAttr C_A_MainNeckCtrl_1.IkEnable`
was changed to
$IkCond = C_A_MainNeckCtrl_1.IkEnable

int $NumJoints = `getAttr C_A_MainNeckCtrl_1.dummyJointTotal`;
was changed to
int $NumJoints = C_A_MainNeckCtrl_1.dummyJointTotal;

the thing is.. that the dummy joint total attribute, its value is known at the time of exectution of the script... But the IK Enable is an attribute which the user/animator has the ability to change its value at runtime, whenever it is required to turn on or turn off the IK Enable.

CGTalk Moderation
10 October 2006, 04:47 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.