TechnicallyArtistic
10-25-2010, 07:03 PM
Hey. I'm trying to set up the FK IK arm matching script, and I'm trying to set up a script job to run when an enum attribute is changed from "FK" to "IK"
I figured I set up a global proc for when the FK matches to IK, then when they IK matches to FK, then make one that's an if statement, so if the enum is switched to FK, is run the FK script, or if it's switched to IK, it runs the IK script. But for some reason I'm getting stopped at the if statement part and I'm sure it's something stupid I missed, but right now I can't figure out what it is, and the if statement doesn't work.
So if anybody has any ideas here, help would be appreciated right now.
Here's what I've got so far, with the if statement as just a test. I've been looking around for more info on this, but it's not the easiest term to search for.
Global Proc fk2ik()
{
//Start of fk to ik matching code
// Get the XYZ Rotation values of the ik shoulder joint
float $L_ShoulderRX = `getAttr l_shoulder_a_ikRIG.rx`;
float $L_ShoulderRY = `getAttr l_shoulder_a_ikRIG.ry`;
float $L_ShoulderRZ = `getAttr l_shoulder_a_ikRIG.rz`;
// Get the Y Rotation value of the ik Elbow joint
float $L_ElbowRX = `getAttr l_elbow_a_ikRIG.rx`;
float $L_ElbowRY = `getAttr l_elbow_a_ikRIG.ry`;
float $L_ElbowRZ = `getAttr l_elbow_a_ikRIG.rz`;
// Get the XYZ Rotation values of the ik wrist joint
float $L_WristRX = `getAttr l_hand_a_ikRIG.rx`;
float $L_WristRY = `getAttr l_hand_a_ikRIG.ry`;
float $L_WristRZ = `getAttr l_hand_a_ikRIG.rz`;
//Apply those values to the fk bones and that will “snap” the fk arm to the ik arm
// Match the XYZ Rotation values for the fk shoulder joint
setAttr lf_shoulder_fkCTRL.rx $L_ShoulderRX;
setAttr lf_shoulder_fkCTRL.ry $L_ShoulderRY;
setAttr lf_shoulder_fkCTRL.rz $L_ShoulderRZ;
// Match the Y Rotation value for the fk elbow joint
setAttr lf_elbow_fkCTRL.rx $L_ElbowRX;
setAttr lf_elbow_fkCTRL.ry $L_ElbowRY;
setAttr lf_elbow_fkCTRL.rz $L_ElbowRZ;
// Match the XYZ Rotation values for the fk wrist joint
setAttr lf_Hand_CTRL.rx 0;
setAttr lf_Hand_CTRL.ry 0;
setAttr lf_Hand_CTRL.rz 0;
// End of fk to ik matching code
}
Global Proc ik2fk()
{
//Start of ik to fk matching code
//Left Arm ik controls--> fk controls snap
// Get the XYZ Translation values from the left arm pole vector "dummy" node
// We don’t care about the rotation from the “dummy” node
float $LelbowDummyTX = `getAttr lf_Elbow_pv_ikLOC.tx`;
float $LelbowDummyTY = `getAttr lf_Elbow_pv_ikLOC.ty`;
float $LelbowDummyTZ = `getAttr lf_Elbow_pv_ikLOC.tz`;
// Get the XYZ Translation values from the left Arm ik Control "dummy"
float $LwristDummyX = `getAttr lf_Hand_pv_ikLOC.tx`;
float $LwristDummyY = `getAttr lf_Hand_pv_ikLOC.ty`;
float $LwristDummyZ = `getAttr lf_Hand_pv_ikLOC.tz`;
//Move the Left arm Pole Vector control to the "dummy" position
setAttr lf_Hand_pv_ikLOC.tx $LelbowDummyTX;
setAttr lf_Hand_pv_ikLOC.ty $LelbowDummyTY;
setAttr lf_Hand_pv_ikLOC.tz $LelbowDummyTZ;
// Move and rotate the left arm ik control to the "dummy" position
setAttr lf_Hand_CTRL.tx $LwristDummyX;
setAttr lf_Hand_CTRL.ty $LwristDummyY;
setAttr lf_Hand_CTRL.tz $LwristDummyZ;
//End of ik to fk matching code
}
Global Proc test()
{
if (lf_Hand_CTRL.fkIkSwith = 0)
print "worked"
}
I figured I set up a global proc for when the FK matches to IK, then when they IK matches to FK, then make one that's an if statement, so if the enum is switched to FK, is run the FK script, or if it's switched to IK, it runs the IK script. But for some reason I'm getting stopped at the if statement part and I'm sure it's something stupid I missed, but right now I can't figure out what it is, and the if statement doesn't work.
So if anybody has any ideas here, help would be appreciated right now.
Here's what I've got so far, with the if statement as just a test. I've been looking around for more info on this, but it's not the easiest term to search for.
Global Proc fk2ik()
{
//Start of fk to ik matching code
// Get the XYZ Rotation values of the ik shoulder joint
float $L_ShoulderRX = `getAttr l_shoulder_a_ikRIG.rx`;
float $L_ShoulderRY = `getAttr l_shoulder_a_ikRIG.ry`;
float $L_ShoulderRZ = `getAttr l_shoulder_a_ikRIG.rz`;
// Get the Y Rotation value of the ik Elbow joint
float $L_ElbowRX = `getAttr l_elbow_a_ikRIG.rx`;
float $L_ElbowRY = `getAttr l_elbow_a_ikRIG.ry`;
float $L_ElbowRZ = `getAttr l_elbow_a_ikRIG.rz`;
// Get the XYZ Rotation values of the ik wrist joint
float $L_WristRX = `getAttr l_hand_a_ikRIG.rx`;
float $L_WristRY = `getAttr l_hand_a_ikRIG.ry`;
float $L_WristRZ = `getAttr l_hand_a_ikRIG.rz`;
//Apply those values to the fk bones and that will “snap” the fk arm to the ik arm
// Match the XYZ Rotation values for the fk shoulder joint
setAttr lf_shoulder_fkCTRL.rx $L_ShoulderRX;
setAttr lf_shoulder_fkCTRL.ry $L_ShoulderRY;
setAttr lf_shoulder_fkCTRL.rz $L_ShoulderRZ;
// Match the Y Rotation value for the fk elbow joint
setAttr lf_elbow_fkCTRL.rx $L_ElbowRX;
setAttr lf_elbow_fkCTRL.ry $L_ElbowRY;
setAttr lf_elbow_fkCTRL.rz $L_ElbowRZ;
// Match the XYZ Rotation values for the fk wrist joint
setAttr lf_Hand_CTRL.rx 0;
setAttr lf_Hand_CTRL.ry 0;
setAttr lf_Hand_CTRL.rz 0;
// End of fk to ik matching code
}
Global Proc ik2fk()
{
//Start of ik to fk matching code
//Left Arm ik controls--> fk controls snap
// Get the XYZ Translation values from the left arm pole vector "dummy" node
// We don’t care about the rotation from the “dummy” node
float $LelbowDummyTX = `getAttr lf_Elbow_pv_ikLOC.tx`;
float $LelbowDummyTY = `getAttr lf_Elbow_pv_ikLOC.ty`;
float $LelbowDummyTZ = `getAttr lf_Elbow_pv_ikLOC.tz`;
// Get the XYZ Translation values from the left Arm ik Control "dummy"
float $LwristDummyX = `getAttr lf_Hand_pv_ikLOC.tx`;
float $LwristDummyY = `getAttr lf_Hand_pv_ikLOC.ty`;
float $LwristDummyZ = `getAttr lf_Hand_pv_ikLOC.tz`;
//Move the Left arm Pole Vector control to the "dummy" position
setAttr lf_Hand_pv_ikLOC.tx $LelbowDummyTX;
setAttr lf_Hand_pv_ikLOC.ty $LelbowDummyTY;
setAttr lf_Hand_pv_ikLOC.tz $LelbowDummyTZ;
// Move and rotate the left arm ik control to the "dummy" position
setAttr lf_Hand_CTRL.tx $LwristDummyX;
setAttr lf_Hand_CTRL.ty $LwristDummyY;
setAttr lf_Hand_CTRL.tz $LwristDummyZ;
//End of ik to fk matching code
}
Global Proc test()
{
if (lf_Hand_CTRL.fkIkSwith = 0)
print "worked"
}
