PDA

View Full Version : Script job


mennalur
12-21-2012, 10:46 AM
Hi everyone,

I created this script job and it does exactly what I want it to do. The only thing is.. it executes when I stop animation playback. I've tried setting the script job on demand but this didnt help because it stopped doing anything.
How do I prevent this from happening? Should I add an kind of kill comands?

global proc L_arm_spaceSwitch(){ global string $L_arm_switch_space = "L_switch_CTRL.Space";

string $L_arm_switch_control ="L_switch_CTRL";

string $L_arm_object_control = "L_armIK_null_GRP";

string $L_arm_attribute;

string $selection[] = {"World", "L_shoulder", "Hips", "Custom"};

int $ParentVal = `getAttr $L_arm_switch_space`;

float $PosDP[] = `xform -q -ws -rp $L_arm_object_control`;

float $RotDP[] = `xform -q -ws -ro $L_arm_object_control`;

int $i=0;

for ($i = 0; $i < 4; $i++){

setAttr ($L_arm_switch_control+"."+$selection[$i]) 0;

}

setAttr ($L_arm_switch_control+"."+$selection[$ParentVal]) 1;

move -rpr $PosDP[0] $PosDP[1] $PosDP[2] $L_arm_object_control;

rotate -a -ws $RotDP[0] $RotDP[1] $RotDP[2] $L_arm_object_control;

print "L_arm_spaceSwitch = ";

print $selection[$ParentVal];

print "\n";

}

Nyro
12-21-2012, 05:18 PM
Are you the same person as 'Terratsumetai'??

If so, why did you post the same question with almost identical code under two different accounts at the same time?

mennalur
12-21-2012, 05:26 PM
trying to delete this one

mennalur
12-21-2012, 05:45 PM
Yes a friend posted it for me, sadly I cannot delete posts but I've already notified them that it could be deleted.

I'm using -attributeChanged in the script job.
scriptJob -killWithScene -attributeChange "L_switch_CTRL.Space" "L_arm_spaceSwitch()";

I changed the code and it is almost working. The script will only run when it is not playing back. The down side is that the script will not automaticly start when I hopen maya due to the fact that I'm missing this line:
$job = `scriptJob -killWithScene -attributeChange "L_switch_CTRL.Space" "L_arm_spaceSwitch()"`;
When I add this line it will again run when the animation is playing. Which is not what I want.

global int $job = 0; proc playCallback()

{

global int $job = 0;

scriptJob -kill $job;

}

scriptJob -ct "playingBack" playCallback;

proc stopCallback()

{

global int $job;

$job = `scriptJob -killWithScene -attributeChange "L_switch_CTRL.Space" "L_arm_spaceSwitch()"`;

}

scriptJob -cf "playingBack" stopCallback;

global proc L_arm_spaceSwitch(){

global string $L_arm_switch_space = "L_switch_CTRL.Space";

string $L_arm_switch_control ="L_switch_CTRL";

string $L_arm_object_control = "L_armIK_null_GRP";

string $L_arm_attribute;

string $selection[] = {"World", "L_shoulder", "Hips", "Custom"};

int $ParentVal = `getAttr $L_arm_switch_space`;

float $PosDP[] = `xform -q -ws -rp $L_arm_object_control`;

float $RotDP[] = `xform -q -ws -ro $L_arm_object_control`;

int $i=0;

for ($i = 0; $i < 4; $i++){

setAttr ($L_arm_switch_control+"."+$selection[$i]) 0;

}

setAttr ($L_arm_switch_control+"."+$selection[$ParentVal]) 1;

move -rpr $PosDP[0] $PosDP[1] $PosDP[2] $L_arm_object_control;

rotate -a -ws $RotDP[0] $RotDP[1] $RotDP[2] $L_arm_object_control;

}

CGTalk Moderation
12-21-2012, 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.