def switchToFk( control, handle=None, attrName='ikBlend', onValue=1, offValue=0, key=False, joints=None ): if handle is None: handle = control if handle is None or not objExists( handle ): printWarningStr( "no ikHandle specified" ) return #if we weren't passed in joints - discover them now if joints is None: joints = getJointsFromIkHandle( handle ) #make sure ik is on before querying rotations setAttr( '%s.%s' % (control, attrName), onValue ) rots = [] for j in joints: rot = getAttr( "%s.r" % j )[0] rots.append( rot ) #now turn ik off and set rotations for the joints setAttr( '%s.%s' % (control, attrName), offValue ) for j, rot in zip( joints, rots ): for ax, r in zip( ('x', 'y', 'z'), rot ): if getAttr( '%s.r%s' % (j, ax), se=True ): setAttr( '%s.r%s' % (j, ax), r ) alignFast( joints[2], handle ) if key: setKeyframe( joints ) setKeyframe( '%s.%s' % (control, attrName) )
def switchToIk(control, poleControl=None, handle=None, attrName='ikBlend', onValue=1, key=False, joints=None, _isBatchMode=False): if handle is None: handle = control if handle is None or not objExists(handle): printWarningStr("no ikHandle specified") return #if we weren't passed in joints - discover them now if joints is None: joints = getJointsFromIkHandle(handle) alignFast(control, joints[2]) if poleControl: if objExists(poleControl): pos = findPolePosition(joints[2], joints[1], joints[0]) move(pos[0], pos[1], pos[2], poleControl, a=True, ws=True, rpr=True) setKeyframe(poleControl) setAttr('%s.%s' % (control, attrName), onValue) if key: setKeyframe(control, at=('t', 'r')) if not _isBatchMode: setKeyframe(control, at=attrName)
def switchToFk(control, handle=None, attrName='ikBlend', onValue=1, offValue=0, key=False, joints=None): if handle is None: handle = control if handle is None or not objExists(handle): printWarningStr("no ikHandle specified") return #if we weren't passed in joints - discover them now if joints is None: joints = getJointsFromIkHandle(handle) #make sure ik is on before querying rotations setAttr('%s.%s' % (control, attrName), onValue) rots = [] for j in joints: rot = getAttr("%s.r" % j)[0] rots.append(rot) #now turn ik off and set rotations for the joints setAttr('%s.%s' % (control, attrName), offValue) for j, rot in zip(joints, rots): for ax, r in zip(('x', 'y', 'z'), rot): if getAttr('%s.r%s' % (j, ax), se=True): setAttr('%s.r%s' % (j, ax), r) alignFast(joints[2], handle) if key: setKeyframe(joints) setKeyframe('%s.%s' % (control, attrName))
def switchToIk( control, poleControl=None, handle=None, attrName='ikBlend', onValue=1, key=False, joints=None, _isBatchMode=False ): if handle is None: handle = control if handle is None or not objExists( handle ): printWarningStr( "no ikHandle specified" ) return #if we weren't passed in joints - discover them now if joints is None: joints = getJointsFromIkHandle( handle ) alignFast( control, joints[2] ) if poleControl: if objExists( poleControl ): pos = findPolePosition( joints[2], joints[1], joints[0] ) move( pos[0], pos[1], pos[2], poleControl, a=True, ws=True, rpr=True ) setKeyframe( poleControl ) setAttr( '%s.%s' % (control, attrName), onValue ) if key: setKeyframe( control, at=('t', 'r') ) if not _isBatchMode: setKeyframe( control, at=attrName )