def setupIK(self): #Create shoulder self.m_shoulderCtrl = cmds.spaceLocator( n=self.m_joints.m_shoulder.replace("_JNT", "_LOC") )[0] # Add to controls rc.addToControlDict(self.m_allControls, "%s_IKShoulder" %(self.m_baseName), self.m_shoulderCtrl) rc.addToLayer(self.m_sceneData, "hidden", self.m_shoulderCtrl) rc.orientControl(self.m_shoulderCtrl, self.m_joints.m_shoulder) rg.add3Groups(self.m_shoulderCtrl, ["_SDK", "_CONST", "_0"]) cmds.parent(self.m_shoulderCtrl+"_0", self.m_group, r=1) cmds.pointConstraint( self.m_shoulderCtrl, self.m_joints.m_shoulder, mo=1 ) desiredName = self.m_wristCtrl.replace("_CTRL", "_IK") self.m_ikHandle = cmds.ikHandle( n = desiredName, sj = self.m_joints.m_shoulder, ee = self.m_joints.m_wrist, sol = "ikRPsolver", see = True )[0] # deselect so we don't get errors cmds.select(d=1) rc.addToLayer(self.m_sceneData, "hidden", [self.m_ikHandle]) cmds.parent(self.m_ikHandle, self.m_wristCtrl) self.setupPoleVec()
def rigBlendControl(self, _parent): # Move and parent blend control rc.orientControl(self.m_blendControl, _parent) group = rg.addGroup(self.m_blendControl, "%s_0" %(self.m_blendControl)) moveValue = -2 if self.m_isMirrored: moveValue *= -1 cmds.setAttr("%s.t%s" %(self.m_blendControl, self.m_twistAxis), moveValue) cmds.parentConstraint(_parent, group, mo=1) rc.lockAttrs( self.m_blendControl, [ "tx", "ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz", "visibility" ], True, True )
def generate(self): self.m_fingers = [] names = ["indexFing", "middleFing", "ringFing", "pinkyFing", "thumb"] for i in range(len(names)): thumb = False if i == (len(names) - 1): thumb = True newFinger = fing.FingerRig( "%s_%s" %(self.m_name, names[i]), self.m_handJoints.getFinger(i), thumb ) newFinger.generate() cmds.parent(newFinger.getGroup(), self.m_group) self.m_fingers.append(newFinger) #create control self.m_control = cmds.spaceLocator(n="%s_CTRL" %(self.m_name))[0] rc.orientControl(self.m_control, self.m_fingers[3].getKnuckle()) group = rg.addGroup(self.m_control, "%s_0" %(self.m_control)) rc.lockAttrs(self.m_control, ["tx", "rotate", "scale"], True, False) cmds.parent(group, self.m_group) cmds.expression(n="%s_EXP" %(self.m_name), s=self.createExp())
def rigWrist(self): self.m_wristCtrl = rg.stripMiddle(self.m_joints.m_wrist, 0, 1)+"_CTRL" self.m_wristCtrl = cmds.spaceLocator(n = self.m_wristCtrl)[0] rc.orientControl(self.m_wristCtrl, self.m_joints.m_wrist) rg.add3Groups(self.m_wristCtrl, ["_SDK", "_CONST", "_0"]) cmds.parent(self.m_wristCtrl+"_0", self.m_group, r=1) # Add to controls rc.addToControlDict(self.m_allControls, "%s_IKWrist" %(self.m_baseName), self.m_wristCtrl) rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_wristCtrl)
def rigElbow(self): #Check that shoulder has been done if not self.m_isShoulder: self.rigShoulder() #Rig for stretch self.m_stretchCtrl = rc.changeExt( self.m_joints.m_elbow1, "_stretch_CTRL" ) self.m_stretchCtrl = cmds.spaceLocator( n = self.m_stretchCtrl )[0] rc.orientControl(self.m_stretchCtrl, self.m_joints.m_shoulder) elbowDisplace = cmds.getAttr("%s.tx" %(self.m_joints.m_elbow1)) groups = rg.add3Groups(self.m_stretchCtrl, ["_SDK", "_CONST", "_0"]) cmds.parent(groups[2], self.m_shoulderGBLCtrl) cmds.setAttr("%s.tx" %(groups[2]), elbowDisplace) cmds.pointConstraint(self.m_stretchCtrl, self.m_joints.m_elbow1) # --- Elbow --- # self.m_elbowCtrl = rc.makeCTRL( self.m_joints.m_elbow1, False, True, ["_SDK", "_CONST", "_0"] ) cmds.parent(self.m_elbowCtrl+"_0", self.m_stretchCtrl) #Connect up double rotations try: cmds.connectAttr( self.m_joints.m_elbow1+".rotate", self.m_joints.m_elbow2+".rotate", f=1 ) except: print "Warning, double joint rotations seem to already be connected" #- lock and hide unused attributes -# rc.lockAttrs( self.m_stretchCtrl, ["ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz"] ) rc.lockAttrs( self.m_elbowCtrl, ["tx", "ty", "tz", "sx", "sy", "sz"] ) rc.addToLayer(self.m_sceneData, "mainCtrl", [self.m_stretchCtrl, self.m_elbowCtrl]) #Add to controls rc.addToControlDict(self.m_allControls, "%s_FKElbowStretch" %(self.m_baseName), self.m_stretchCtrl) rc.addToControlDict(self.m_allControls, "%s_FKElbow" %(self.m_baseName), self.m_elbowCtrl) self.m_isElbow = True
def aimWrist(self, _fkWrist, _blendControlAttrs): error.assertType(_fkWrist, ["", u'']) error.assertList(_blendControlAttrs, ["", u'']) assert len(_blendControlAttrs) == 2, "_blendControls must contain two elements" # Make sure wrist is aimed right # create fix control that always aims as fk should. # this is used to help blend between ik and fk if (self.m_rigWrist): group = cmds.group(n="%s_wrist_blendFix_GRP" %(self.m_name), em=True) cmds.parent(group, self.m_group) rc.orientControl(group, self.m_wristCtrl) cmds.pointConstraint(self.m_joints.m_wrist, group, mo=1) # Create up locator wristAimFix = cmds.spaceLocator(n="%s_wristAimFix_LOC" %(self.m_name))[0] rc.addToLayer(self.m_sceneData, "hidden", wristAimFix) cmds.parent(wristAimFix, self.m_joints.m_elbow2, r=1) aimOffset = 1 if self.m_isMirrored: aimOffset *= -1 cmds.setAttr("%s.t%s" %(wristAimFix, self.m_twistAxis), aimOffset) aim = cmds.aimConstraint( self.m_joints.m_elbow2, group, worldUpType = "object", worldUpObject = wristAimFix, mo = True )[0] orient = cmds.orientConstraint( _fkWrist, "%s_SDK" %(self.m_wristCtrl), mo= True )[0] orient = cmds.orientConstraint( group, "%s_SDK" %(self.m_wristCtrl), mo= True )[0] cmds.setAttr("%s.interpType" %(orient), 2) cmds.connectAttr( _blendControlAttrs[0], "%s.%sW0" %(orient, _fkWrist) ) cmds.connectAttr( _blendControlAttrs[1], "%s.%sW1" %(orient, group) )
def setupPoleVec(self): middleName = rg.stripMiddle(self.m_joints.m_shoulder, 0, 3) desiredName = self.m_name+"PoleVec_LOC" self.m_poleVec = cmds.spaceLocator(n = desiredName)[0] # Add to controls rc.addToControlDict(self.m_allControls, "%s_IKPoleVec" %(self.m_baseName), self.m_poleVec) rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_poleVec) cmds.addAttr( self.m_poleVec, ln=self.m_poleVecPinAttr, min=0, max=1, k=True, dv=0 ) cmds.addAttr( self.m_poleVec, ln=self.m_maxStretchAttr, at = "float", min=0, dv=10, k=1 ) self.m_maxStretch = "%s.%s" %(self.m_poleVec, self.m_maxStretchAttr) rc.orientControl(self.m_poleVec, self.m_joints.m_elbow1) groups = rg.add3Groups(self.m_poleVec, ["_SDK", "_CONST", "_0"]) cmds.poleVectorConstraint(self.m_poleVec, self.m_ikHandle) cmds.parent(groups[-1], self.m_group, r=1) # Lock unused attributes rc.lockAttrs( self.m_poleVec, ["scale", "rotate"], True, False ) axis , offset = self.getPoleVecAxis(2) if axis != "": cmds.setAttr("%s.t%s" %(groups[1], axis), offset) #Create line midGroup = cmds.group(em=1, n=self.m_name+"PoleVec_GRP") cmds.parent(midGroup, self.m_group) cmds.pointConstraint(self.m_joints.m_elbow1, midGroup) cmds.pointConstraint(self.m_joints.m_elbow2, midGroup) lineNodes = rc.createLine([self.m_poleVec, midGroup], self.m_sceneData, "mainCtrl") cmds.parent(lineNodes[0], self.m_group)
def createToe(self): if not self.m_ankleGenerated: self.createAnkle() self.m_toeCtrl = cmds.circle( n="%s_toe_CTRL" %(self.m_name), nr=(1, 0, 0) )[0] rc.addToControlDict(self.m_allControls, "%s_FKToe" %(self.m_baseName), self.m_toeCtrl) rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_toeCtrl) rc.orientControl(self.m_toeCtrl, self.m_joints[1]) groups = rg.add3Groups(self.m_toeCtrl, ["_SDK", "_CONST", "_0"]) cmds.parentConstraint(self.m_toeCtrl, self.m_joints[1]) cmds.parent(groups[-1], self.m_ankleCtrl) self.m_toeGenerated = True #Lock unused attributes rc.lockAttrs(self.m_toeCtrl, ["translate", "scale"], True, False)
def rigWrist(self): #Check that shoulder has been done if not self.m_isElbow: self.rigElbow() # --- Wrist --- # self.m_wristCtrl = rc.makeCTRL( self.m_joints.m_wrist, False, False, ["_SDK", "_CONST", "_0"] ) # Sort orientation rc.orientControl(self.m_wristCtrl+"_0", self.m_joints.m_elbow2) rc.copyTranslation(self.m_wristCtrl+"_0", self.m_joints.m_wrist) #Parent for neatness cmds.parent(self.m_wristCtrl+"_0", self.m_elbowCtrl) #Connect up to previous joint cmds.parentConstraint( self.m_joints.m_elbow2, self.m_wristCtrl+"_CONST", mo=1 ) cmds.pointConstraint( self.m_wristCtrl, self.m_joints.m_wrist, skip=["y", "z"] ) rc.lockAttrs( self.m_wristCtrl, ["ty", "tz", "rotate", "scale"], True, False ) # Add to controls rc.addToControlDict(self.m_allControls, "%s_FKWrist" %(self.m_baseName), self.m_wristCtrl) rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_wristCtrl) self.m_isWrist = True
def generateAutoClav(_name, _shoulderSDK, _wristIK): print "doing something" error.assertString(_name) error.assertMayaObject(_shoulderSDK) error.assertMayaObject(_wristIK) cmds.select(clear=True) # Create joints joint1 = cmds.joint(n="%s_IK_JNT" %(_name)) rc.copyTranslation(joint1, _shoulderSDK) joint2 = cmds.joint(n="%s_IKEND_JNT" %(_name)) rc.copyTranslation(joint2, _wristIK) #cmds.parent(joint2, joint1) # Create IK ikControl = cmds.ikHandle( n="%s_IK" %(_name), sol="ikRPsolver", sj= joint1, ee=joint2 )[0] # deselect so we don't get warnings cmds.select(d=1) # Create pole vec locator = cmds.spaceLocator(n="%s_up_LOC" %(_name))[0] rc.orientControl(locator, _wristIK) locGroup = rg.addGroup(locator, "%s_0" %(locator)) cmds.setAttr("%s.ty" %(locator), 2) cmds.poleVectorConstraint(locator, ikControl) # Connect up to rig cmds.pointConstraint(_wristIK, locGroup, mo=1) cmds.pointConstraint(_wristIK, ikControl, mo=1) cmds.orientConstraint(joint1, _shoulderSDK, mo=1)
def setupElbowTwist(self): # Create joints cmds.select(d=1) joint1 = cmds.joint(n="%s_midTwist_JNT" %(self.m_name))#, s=[0.1, 0.1, 0.1]) cmds.setAttr("%s.radius" %(joint1), 0.15) rc.orientControl(joint1, self.m_joints.m_elbow1) joint2 = cmds.joint(n="%s_midTwistEnd_JNT" %(self.m_name))#, s=[0.1, 0.1, 0.1]) cmds.setAttr("%s.radius" %(joint2), 0.15) rc.orientControl(joint2, self.m_joints.m_elbow2) cmds.parent(joint1, self.m_group) self.m_elbowTwistJoints = [joint1, joint2] rc.addToLayer(self.m_sceneData, "ref", self.m_elbowTwistJoints) rc.addToSet(self.m_sceneData, "bind", self.m_elbowTwistJoints[0]) # sort out joint orientations tmpLocator = cmds.spaceLocator()[0] cmds.parent(tmpLocator, self.m_joints.m_elbow1, r=1) cmds.setAttr("%s.t%s" %(tmpLocator, self.m_twistAxis), 1) rc.reorientJoints(self.m_elbowTwistJoints, tmpLocator) cmds.delete(tmpLocator) # Create control self.m_elbowTwist = cmds.spaceLocator(n="%s_midTwist_CTRL" %(self.m_name))[0] rc.orientControl(self.m_elbowTwist, self.m_elbowTwistJoints[0]) cmds.parent(self.m_elbowTwist, self.m_group) groups = rg.add3Groups(self.m_elbowTwist, ["_SDK", "_CONST", "_0"]) # Create aim locator self.m_elbowTwistAimLoc = cmds.spaceLocator(n="%s_midTwistAim_LOC" %(self.m_name))[0] cmds.parent(self.m_elbowTwistAimLoc, self.m_elbowTwist, r=1) aimOffset = 1 if(self.m_isMirrored): aimOffset *=1 cmds.setAttr("%s.tx" %(self.m_elbowTwistAimLoc), aimOffset) rc.addToLayer(self.m_sceneData, "hidden", self.m_elbowTwistAimLoc) # Connect up joint cmds.pointConstraint(self.m_elbowTwist, self.m_elbowTwistJoints[0]) cmds.parentConstraint(self.m_joints.m_elbow1, groups[1]) self.m_twistAimConstraint = cmds.aimConstraint( self.m_elbowTwistAimLoc, self.m_elbowTwistJoints[0], mo=1 )
def generate(self): cmds.cycleCheck(e=False) # -- Duplicate joints and rename for IK-FK switch --- # self.m_bindJoints = self.duplicateJoints(self.m_startJoints, "BIND") rc.addToLayer(self.m_sceneData, "ref", self.m_bindJoints[0]) self.m_ikJoints = self.duplicateJoints(self.m_startJoints, "IK") rc.addToLayer(self.m_sceneData, "ref", self.m_ikJoints[0]) self.m_fkJoints = self.duplicateJoints(self.m_startJoints, "FK") rc.addToLayer(self.m_sceneData, "ref", self.m_fkJoints[0]) # -- Create shoulder locator -- # self.m_shoulderLocator = self.m_name+"_shoulder_CTRL" self.m_shoulderLocator = cmds.spaceLocator(n=self.m_shoulderLocator)[0] rc.addToLayer(self.m_sceneData, "detailCtrl", self.m_shoulderLocator) rc.orientControl(self.m_shoulderLocator, self.m_startJoints.m_shoulder) shoulderGRPs = rg.add3Groups( self.m_shoulderLocator, ["_SDK", "_CONST", "_0"] ) cmds.parent(shoulderGRPs[-1], self.m_group) # -- Setup FK rig -- # tmpList = self.m_fkJoints.getJointList() self.m_fkRig = fk.FKArmRig(self.m_sceneData, tmpList, self.m_name+"_FK", self.m_baseName) self.m_fkRig.generate() cmds.parent(self.m_fkRig.m_group, self.m_group) cmds.parentConstraint( self.m_shoulderLocator, self.m_fkRig.getMainTransform(), mo=True ) # -- Setup IK rig -- # tmpList = self.m_ikJoints.getJointList() self.m_ikRig = ik.IKArmRig( self.m_sceneData, tmpList, self.m_name+"_IK", self.m_baseName, self.m_isMirrored, self.m_twistAxis ) self.m_ikRig.generate() cmds.parent(self.m_ikRig.m_group, self.m_group) cmds.pointConstraint( self.m_shoulderLocator, self.m_ikRig.getMainTransform(), mo=True ) # -- Setup BIND rig -- # tmpList = self.m_bindJoints.getJointList() self.m_bindRig = bind.BINDArmRig( self.m_sceneData, tmpList, self.m_name+"_BIND", self.m_baseName, self.m_blendControl, self.m_numUpperControls, self.m_numLowerControls, self.m_numUpperJoints, self.m_numLowerJoints, self.m_upperStretchJoints, self.m_lowerStretchJoints, self.m_isMirrored, self.m_twistAxis, self.m_rigWrist ) self.m_bindRig.generate() cmds.parent(self.m_bindRig.m_group, self.m_group) cmds.pointConstraint( self.m_shoulderLocator, self.m_bindRig.getMainTransform(), mo=True ) # rig the blend control for aestethics if self.m_rigWrist: self.rigBlendControl(self.m_bindRig.getWristCtrl()) # -- Connect up rigs -- # try: tmp = self.m_blendControl except: self.m_blendControl = self.createBlendControl() self.connectIKFK() # -- Setup visibility -- # self.setupVisibility() cmds.cycleCheck(e=True) # Add all controls rc.addToControlDict( self.m_allControls, "%s_shoulderLocator" %(self.m_baseName), self.m_shoulderLocator ) rc.addDictToControlDict(self.m_allControls, self.m_fkRig.getAllControls()) rc.addDictToControlDict(self.m_allControls, self.m_ikRig.getAllControls()) rc.addDictToControlDict(self.m_allControls, self.m_bindRig.getAllControls()) self.m_isGenerated = True
def generate(self): # Generate controls self.m_heelRoll = cmds.spaceLocator( n="%s_heelRoll_CTRL" %(self.m_name) )[0] rc.addToControlDict( self.m_allControls, "%s_heelRoll" %(self.m_baseName), self.m_heelRoll ) self.m_insideRoll = cmds.spaceLocator( n="%s_insideRoll_CTRL" %(self.m_name) )[0] rc.addToControlDict( self.m_allControls, "%s_insideRoll" %(self.m_baseName), self.m_insideRoll ) self.m_outsideRoll = cmds.spaceLocator( n="%s_outsideRoll_CTRL" %(self.m_name) )[0] rc.addToControlDict( self.m_allControls, "%s_outsideRoll" %(self.m_baseName), self.m_outsideRoll ) self.m_toeRoll = cmds.spaceLocator( n="%s_toeRoll_CTRL" %(self.m_name) )[0] rc.addToControlDict( self.m_allControls, "%s_toeRoll" %(self.m_baseName), self.m_toeRoll ) self.m_ballRoll = cmds.spaceLocator( n="%s_ballRoll_CTRL" %(self.m_name) )[0] rc.addToControlDict( self.m_allControls, "%s_ballRoll" %(self.m_baseName), self.m_ballRoll ) self.m_toeFlap = cmds.spaceLocator( n="%s_toeFlap_CTRL" %(self.m_name) )[0] rc.addToControlDict( self.m_allControls, "%s_toeFlap" %(self.m_baseName), self.m_toeFlap ) rc.addToLayer( self.m_sceneData, "detailCtrl", [ self.m_heelRoll, self.m_insideRoll, self.m_outsideRoll, self.m_toeRoll, self.m_ballRoll, self.m_toeFlap ] ) self.m_mainCtrl = cmds.circle( n="%s_main_CTRL" %(self.m_name), nr=(1, 0, 0) )[0] rc.addToControlDict( self.m_allControls, "%s_mainCtrl" %(self.m_baseName), self.m_mainCtrl ) rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_mainCtrl) rc.orientControl(self.m_mainCtrl, self.m_footMainLoc) cmds.parent(self.m_mainCtrl, self.m_group) mainCtrlGroups = rg.add3Groups( self.m_mainCtrl, ["_SDK", "_CONST", "_0"] ) # Move everything into the right places rc.orientControl(self.m_heelRoll, self.m_heelPivotLoc) rc.orientControl(self.m_insideRoll, self.m_insidePivotLoc) rc.orientControl(self.m_outsideRoll, self.m_outsidePivotLoc) rc.orientControl(self.m_toeRoll, self.m_toePivotLoc) rc.orientControl(self.m_ballRoll, self.m_joints[1]) rc.orientControl(self.m_toeFlap, self.m_joints[1]) # Parent everything cmds.parent(self.m_heelRoll, self.m_mainCtrl) cmds.parent(self.m_insideRoll, self.m_heelRoll) cmds.parent(self.m_outsideRoll, self.m_insideRoll) cmds.parent(self.m_toeRoll, self.m_outsideRoll) cmds.parent(self.m_ballRoll, self.m_toeRoll) cmds.parent(self.m_toeFlap, self.m_toeRoll) # Create Groups above defaultExt = ["_SDK", "_CONST", "_0"] rg.add3Groups(self.m_heelRoll, defaultExt) rg.add3Groups(self.m_insideRoll, defaultExt) rg.add3Groups(self.m_outsideRoll, defaultExt) rg.add3Groups(self.m_toeRoll, defaultExt) rg.add3Groups(self.m_ballRoll, defaultExt) rg.add3Groups(self.m_toeFlap, defaultExt) # Create IKs self.m_footIK = cmds.ikHandle( sj=self.m_joints[0], ee=self.m_joints[1], sol="ikRPsolver" )[0] # deselect so we don't get warnings cmds.select(d=1) cmds.parent(self.m_footIK, self.m_ballRoll) self.m_toeIK = cmds.ikHandle( sj=self.m_joints[1], ee=self.m_joints[2], sol="ikRPsolver" )[0] # deselect so we don't get warnings cmds.select(d=1) cmds.parent(self.m_toeIK, self.m_toeFlap) rc.addToLayer(self.m_sceneData, "hidden", [self.m_footIK, self.m_toeIK]) # Sort ankle cmds.parentConstraint(self.m_ballRoll, self.m_ankleIK, mo=True) cmds.parentConstraint(self.m_ankleIK, self.m_joints[0], mo=True)
def generate(self): if self.m_isThumb: names = ["metacarpal", "knuckle", "tip", "tipEND"] else: names = ["metacarpal", "knuckle", "mid", "tip", "tipEND"] i = 0 parentControl = False self.m_controls = [] self.m_stretchControls = [] for joint in self.m_joints: # Create control newStretch = False if joint != self.m_joints[0]: #Create stretch control stretchName = "%s_%s_stretch_CTRL" %(self.m_name, names[i]) newStretch = cmds.spaceLocator(n=stretchName)[0] rc.setMultiAttrs( newStretch, ["localScaleX", "localScaleY", "localScaleZ"], 0.15 ) rc.orientControl(newStretch, cmds.listRelatives(joint, p=1)[0]) rc.copyTranslation(newStretch, joint) if parentControl: cmds.parent(newStretch, parentControl) else: cmds.parent(newStretch, self.m_group) rg.add3Groups( newStretch, ["_SDK", "_CONST", "_0"] ) # lock unused attrs rc.lockAttrs( newStretch, ["ty", "tz", "rotate", "scale"], True, False ) parentControl = newStretch if joint != self.m_joints[-1]: controlName = "%s_%s_CTRL" %(self.m_name, names[i]) newControl = cmds.circle( n=controlName, nr=(1, 0, 0), r=0.1 )[0] rc.orientControl(newControl, joint) if parentControl: cmds.parent(newControl, parentControl) else: cmds.parent(newControl, self.m_group) self.m_controls.append(newControl) groups = rg.add3Groups(newControl, ["_SDK", "_CONST", "_0"]) if newStretch: # Attach to stretch cmds.parentConstraint(newStretch, groups[1], mo=1) # Attach to joint cmds.parentConstraint(newControl, joint, mo=1) rc.lockAttrs( newControl, ["translate", "scale"], True, False ) parentControl = newControl i += 1 else: cmds.parentConstraint(newStretch, joint, mo=1) # Rig metacarpals if not self.m_isThumb: pass self.m_isGenerated = True
def createTwist(self): numJoints = len(self.m_bindJoints) if numJoints == 0: raise Exception, "No joints, cannot create twist setup" #Create twist controls # Twist 1 self.m_twistControl1 = cmds.spaceLocator( n="%s_upperTwist_CTRL" %(self.m_name) )[0] #cmds.parent(self.m_twistControl1, self.m_parent1, r=1) # Twist 2 self.m_twistControl2 = cmds.spaceLocator( n="%s_lowerTwist_CTRL" %(self.m_name) )[0] #cmds.parent(self.m_twistControl2, self.m_parent2, r=1) for control, parent in map( None, [self.m_twistControl1, self.m_twistControl2], [self.m_parent1, self.m_parent2] ): rc.orientControl(control, parent) groups = rg.add3Groups(control, ["_SDK", "_CONST", "_0"]) if self.m_isMirrored: cmds.setAttr( "%s.t%s" %(groups[0], self.m_twistAxis), 1 ) else: cmds.setAttr( "%s.t%s" %(groups[0], self.m_twistAxis), -1 ) if self.m_isParentTwist: cmds.parentConstraint(parent, groups[1], mo=1) cmds.parent(groups[2], self.m_group) rc.lockAttrs( control, ["rotate", "scale", "visibility"], True, False ) cmds.setAttr("%s.dTwistControlEnable" %(self.m_ikHandle), 1) cmds.setAttr("%s.dWorldUpType" %(self.m_ikHandle), 2) cmds.setAttr("%s.dTwistValueType" %(self.m_ikHandle), 1) if self.m_twistAxis == "y": if self.m_isMirrored: cmds.setAttr("%s.dWorldUpAxis" %(self.m_ikHandle), 0) else: cmds.setAttr("%s.dWorldUpAxis" %(self.m_ikHandle), 1) else: if self.m_isMirrored: cmds.setAttr("%s.dWorldUpAxis" %(self.m_ikHandle), 3) else: cmds.setAttr("%s.dWorldUpAxis" %(self.m_ikHandle), 4) cmds.connectAttr( "%s.worldMatrix[0]" %(self.m_twistControl1), "%s.dWorldUpMatrix" %(self.m_ikHandle), f = True ) cmds.connectAttr( "%s.worldMatrix[0]" %(self.m_twistControl2), "%s.dWorldUpMatrixEnd" %(self.m_ikHandle), f = True ) rc.addToLayer(self.m_sceneData, "detailCtrl", [self.m_twistControl1, self.m_twistControl2]) #Add to controls rc.addToControlDict(self.m_allControls, "%s_topTwist" %(self.m_baseName), self.m_twistControl1) rc.addToControlDict(self.m_allControls, "%s_lowTwist" %(self.m_baseName), self.m_twistControl2)