PDA

View Full Version : Why does this code have to be executed twice (all because I subtract some numbers?)


JaredTaylor
11-10-2011, 10:39 AM
Hi everyone,

This is my ik/fk matching script, but I have to click the button TWICE, I've isolated the problem to these lines in the code:

lKneeTX = lKneeGrpTX - lKneeTX
lKneeTY = lKneeGrpTY - lKneeTY
lKneeTZ = lKneeGrpTZ - lKneeTZ

I don't understand what is possibly wrong with that, that it has to be run twice. Any help appreciated.. cheers.



import maya.cmds as cmds

### matches IK to FK for the blender squirrel rig ###

# get translations

lKneeTX = cmds.getAttr('L_kneeAimSnap_LOC.translateX')
lKneeTY = cmds.getAttr('L_kneeAimSnap_LOC.translateY')
lKneeTZ = cmds.getAttr('L_kneeAimSnap_LOC.translateZ')

lAnkleTX = cmds.getAttr('L_ankleAimSnap_LOC.translateX')
lAnkleTY = cmds.getAttr('L_ankleAimSnap_LOC.translateY')
lAnkleTZ = cmds.getAttr('L_ankleAimSnap_LOC.translateZ')

# set translations

lKneeGrpTX = cmds.getAttr('L_kneeIK_CTRL_GRP.translateX')
lKneeGrpTY = cmds.getAttr('L_kneeIK_CTRL_GRP.translateY')
lKneeGrpTZ = cmds.getAttr('L_kneeIK_CTRL_GRP.translateZ')

lKneeTX = lKneeGrpTX - lKneeTX
lKneeTY = lKneeGrpTY - lKneeTY
lKneeTZ = lKneeGrpTZ - lKneeTZ

cmds.setAttr('L_kneeIK_CTRL.translateX', lKneeTX)
cmds.setAttr('L_kneeIK_CTRL.translateY', lKneeTY)
cmds.setAttr('L_kneeIK_CTRL.translateZ', lKneeTZ)

cmds.setAttr('L_footIK_CTRL.translateX', lAnkleTX)
cmds.setAttr('L_footIK_CTRL.translateY', lAnkleTY)
cmds.setAttr('L_footIK_CTRL.translateZ', lAnkleTZ)

CGTalk Moderation
11-10-2011, 10:39 AM
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.