Downloads

Non-Flip Elbow Match Script

import maya.cmds as cmds
import math

#--- No-Flip PV ---
min = 0
max = 360
fkPos = cmds.xform('L_elbow_FKCTRL', q=True, ws=True, rp=True)

for i in xrange(0, 50, 1):
    #Set min and max on elbow_twist to find correct value:
    cmds.setAttr('L_wrist_IKCTRL.elbow_twist', min)
    ikPos = cmds.xform('L_elbow_IKJNT', q=True, ws=True, rp=True)

    ikVecX = ikPos[0]    
    ikVecY = ikPos[1]    
    ikVecZ = ikPos[2]

    fkVecX = fkPos[0]    
    fkVecY = fkPos[1]    
    fkVecZ = fkPos[2]

    vecX = ikVecX - fkVecX
    vecY = ikVecY - fkVecY
    vecZ = ikVecZ - fkVecZ

    minDist = math.sqrt(vecX**2 + vecY**2 + vecZ**2)

    cmds.setAttr('L_wrist_IKCTRL.elbow_twist', max)
    ikPos = cmds.xform('L_elbow_IKJNT', q=True, ws=True, rp=True)

    ikVecX = ikPos[0]
    ikVecY = ikPos[1]
    ikVecZ = ikPos[2]

    fkVecX = fkPos[0]
    fkVecY = fkPos[1]
    fkVecZ = fkPos[2]

    vecX = ikVecX - fkVecX
    vecY = ikVecY - fkVecY
    vecZ = ikVecZ - fkVecZ

    maxDist = math.sqrt(vecX**2 + vecY**2 + vecZ**2)

    avg = ((max - min)/2 + min)

    if (minDist > maxDist):
        min = avg
    elif (minDist < maxDist): 
        max = avg 
    else: #min == max 
        min = min + .00001 

    #Check elbow_twist value:
    twistVal = cmds.getAttr('L_wrist_IKCTRL.elbow_twist') 
    if (twistVal > 180):
        cmds.setAttr('L_wrist_IKCTRL.elbow_twist', twistVal - 360)
    elif (twistVal < -180):
        cmds.setAttr('L_wrist_IKCTRL.elbow_twist', twistVal + 360)

Eclipse Color Themes

JGaines_Dark