def handCleanUp(self, handOffsetCtrl, fkFingerOffsetCtrls, leftRight, jntPalmBase, jntPalm, jntFingersUnsorted, grpConPalm, conLocFKOffsetCtrl, conLocIKOffsetCtrl, *args): grpRigArm = mc.group(n="GRP_rig{0}arm".format(leftRight), w=True, em=True) # For the sake of not having a bazillion entries for the input text, I'm hardcoding things here mc.parent("GRP_CTRL_IK{0}arm".format(leftRight), "GRP_jnt{0}arm".format(leftRight), "OFFSET_CTRL{0}shoulder".format(leftRight), jntPalmBase, handOffsetCtrl[0], grpConPalm, grpRigArm) CRU.lockHideCtrls(handOffsetCtrl[1], translate=True, scale=True, visible=True) for i in range(len(fkFingerOffsetCtrls)): for j in range(len(fkFingerOffsetCtrls[i])): CRU.lockHideCtrls(fkFingerOffsetCtrls[i][j][1], scale=True, translate=True, visible=True) mc.setAttr("{0}.visibility".format(conLocFKOffsetCtrl[1]), False) mc.setAttr("{0}.visibility".format(conLocIKOffsetCtrl[1]), False) CRU.layerEdit(jntPalm, bndLayer=True, noRecurse=True) CRU.layerEdit(jntFingersUnsorted, bndLayer=True, noRecurse=True)
def footCleanUp(self, locAutoKneeFollow, leftRight, offsetFoot, kneeOffsetCtrl, ctrlIKLeg, colourTU, *args): # rename the GRP_LOC_worldFollow to GRP_LOC_follow if not already try: grpFollowWorld = mc.ls("GRP_LOC_worldFollow")[0] except: try: grpFollowWorld = mc.ls("GRP_LOC_follow")[0] except: mc.warning("Your follow locator is not properly named") return pass # replace "GRP_LOC_worldFollow" with "GRP_LOC_follow" grpFollowWorldRename = grpFollowWorld.replace("worldFollow", "follow") try: # rename if necessary mc.rename(grpFollowWorld, grpFollowWorldRename) except: pass # parents the follow control under the world follow group mc.parent(locAutoKneeFollow, grpFollowWorldRename) # makes invisible the locator for the world follow and the locators under the foot mc.setAttr("{0}.visibility".format(locAutoKneeFollow), False) mc.setAttr("{0}.visibility".format(offsetFoot), False) # groups the knee under the leg rig grpRigLeg = "GRP_rig_" + leftRight + "leg" mc.parent(kneeOffsetCtrl[0], grpRigLeg) # makes our colours the corresponding side values mc.setAttr('{0}.overrideEnabled'.format(kneeOffsetCtrl[0]), 1) mc.setAttr("{0}.overrideColor".format(kneeOffsetCtrl[0]), colourTU) mc.setAttr('{0}.overrideEnabled'.format(offsetFoot), 1) mc.setAttr("{0}.overrideColor".format(offsetFoot), colourTU) mc.connectAttr("{0}.v".format(ctrlIKLeg), "{0}.v".format(kneeOffsetCtrl[1])) # lock and hide stuff at the end CRU.lockHideCtrls(kneeOffsetCtrl[1], scale=True, rotate=True, visible=True)
def fingersCleanup(self, ctrlFingers, ctrlPalm, colourTU, *args): mc.parent(ctrlFingers, ctrlPalm) checkList = mc.listRelatives(ctrlFingers) for i in range(len(checkList)): if mc.objectType(checkList[i]) == "transform": CRU.lockHideCtrls(checkList[i], translate=True, rotate=True, scale=True, toHide=True, visible=True, toLock=False) mc.makeIdentity(ctrlFingers, apply=True, translate=True, rotate=True, scale=True) # get the non-shape values lockValues = mc.listRelatives(ctrlFingers, c=True, s=False, type="transform") lockValues.append(ctrlFingers) for i in range(len(lockValues)): CRU.lockHideCtrls(lockValues[i], translate=True, rotate=True, scale=True, visible=True) mc.setAttr('{0}.overrideEnabled'.format(lockValues[i]), 1) mc.setAttr("{0}.overrideColor".format(lockValues[i]), colourTU)
def neckCleanUp(self, headOffsetCtrls, eyeCtrlArray, eyesCtrl, *args): for i in range(len(headOffsetCtrls)): CRU.lockHideCtrls(headOffsetCtrls[i][1], scale=True, visible=True) for i in range(len(eyeCtrlArray)): CRU.lockHideCtrls(eyeCtrlArray[i], scale=True, visible=True) CRU.lockHideCtrls(eyesCtrl, scale=True, visible=True) CRU.layerEdit(self.jointArray, bndLayer=True, noRecurse=True)
def toesCleanup(self, ctrlToes, jntMasterToes, jntAnkleTwist, fkJntOffsetCtrls, grpCtrlFoot, grpLegs, colourTU, *args): mc.parent(ctrlToes, jntAnkleTwist) checkList = mc.listRelatives(ctrlToes) for i in range(len(checkList)): if mc.objectType(checkList[i]) == "transform": CRU.lockHideCtrls(checkList[i], translate=True, rotate=True, scale=True, toHide=True, visible=True, toLock=False) mc.makeIdentity(ctrlToes, apply=True, translate=True, rotate=True, scale=True) # get the non-shape values lockValues = mc.listRelatives(ctrlToes, c=True, s=False, type="transform") lockValues.append(ctrlToes) for i in range(len(lockValues)): CRU.lockHideCtrls(lockValues[i], translate=True, rotate=True, scale=True, visible=True) mc.setAttr('{0}.overrideEnabled'.format(lockValues[i]), 1) mc.setAttr("{0}.overrideColor".format(lockValues[i]), colourTU) # toeGrpName = "GRP_CTRL_{0}toes".format(leftRight) # toeGrp = mc.group(name=toeGrpName, w=True) for i in range(len(fkJntOffsetCtrls)): for j in range(len(fkJntOffsetCtrls[i])): CRU.lockHideCtrls(fkJntOffsetCtrls[i][j][1], translate=True, scale=True, visible=True) mc.parent(grpCtrlFoot, grpLegs) CRU.layerEdit(jntMasterToes, bndLayer=True, noRecurse=True)
def tgpCreateMirror(self, ctrlFingers, leftRightReplace, leftRightReplaceMirror): # when you make a duplicate, the order of the duplicated children will get reversed. This reverses the reverse. ctrlFingersMirrorWork = mc.duplicate(ctrlFingers, rc=True) ctrlFingersMirrorWork[1:] = ctrlFingersMirrorWork[-1:0:-1] ctrlFingersMirror = [] offsetCtrlStuffMirror = [] for i in range(len(ctrlFingersMirrorWork)): # switch the l/r, toRename = ctrlFingersMirrorWork[i].replace( leftRightReplace, leftRightReplaceMirror)[:-1] mc.rename(ctrlFingersMirrorWork[i], toRename) ctrlFingersMirror.append(toRename) ctrlFingersMirrorTop = ctrlFingersMirror[0] # takes the initial offset value, duplicates it, flips the values around, then freezes the transformation # translates everything into place mirrorTrans = mc.xform(ctrlFingersMirrorTop, q=True, ws=True, rotatePivot=True) mirrorRot = mc.xform(ctrlFingersMirrorTop, q=True, ws=True, rotation=True) mirrorTransX = mirrorTrans[0] * -1 mirrorTransY = mirrorTrans[1] mirrorTransZ = mirrorTrans[2] mirrorRotX = mirrorRot[0] * 1 mirrorRotY = mirrorRot[1] * -1 mirrorRotZ = mirrorRot[2] * -1 mirrorXScal = mc.getAttr("{0}.sx".format(ctrlFingersMirrorTop)) * -1 # mirrors the values mc.xform(ctrlFingersMirrorTop, translation=(mirrorTransX, mirrorTransY, mirrorTransZ)) mc.xform(ctrlFingersMirrorTop, scale=(mirrorXScal, 1, 1)) mc.xform(ctrlFingersMirrorTop, rotation=(mirrorRotX, mirrorRotY, mirrorRotZ)) checkList = mc.listRelatives(ctrlFingersMirrorTop) for i in range(len(checkList)): if mc.objectType(checkList[i]) == "transform": CRU.lockHideCtrls(checkList[i], translate=True, rotate=True, scale=True, toHide=True, visible=True, toLock=False) # mc.scale(-1, ctrlFingersMirrorTop, x=True, pivot=(0,0,0), a=True) mc.makeIdentity(ctrlFingersMirrorTop, apply=True, translate=True, scale=True) return ctrlFingersMirror, ctrlFingersMirrorTop
def tgpCreateMirrorCtrl(self, ctrlToes, leftRightReplace, leftRightReplaceMirror): ctrlToesMirrorWork = mc.duplicate(ctrlToes, rc=True) # we want this to be at the world try: mc.parent(ctrlToesMirrorWork[0], w=True) except: pass ctrlToesMirror = [] offsetCtrlStuffMirror = [] for i in range(len(ctrlToesMirrorWork)): # switch the l/r, toRename = ctrlToesMirrorWork[i].replace( leftRightReplace, leftRightReplaceMirror)[:-1] mc.rename(ctrlToesMirrorWork[i], toRename) ctrlToesMirror.append(toRename) ctrlToesMirrorTop = ctrlToesMirror[0] # takes the initial offset value, duplicates it, flips the values around, then freezes the transformation # translates everything into place mirrorTrans = mc.xform(ctrlToesMirrorTop, q=True, ws=True, t=True, a=True) mirrorRot = mc.xform(ctrlToesMirrorTop, q=True, ws=True, rotation=True) mirrorTransX = mirrorTrans[0] * -1 mirrorTransY = mirrorTrans[1] mirrorTransZ = mirrorTrans[2] mirrorRotX = mirrorRot[0] * 1 mirrorRotY = mirrorRot[1] * -1 mirrorRotZ = mirrorRot[2] * -1 mirrorXScal = mc.getAttr("{0}.sx".format(ctrlToesMirrorTop)) * -1 # mirrors the values '''mc.setAttr("{0}.tx".format(ctrlToesMirrorTop), mirrorTransX) mc.setAttr("{0}.sx".format(ctrlToesMirrorTop), mirrorXScal) mc.setAttr("{0}.rx".format(ctrlToesMirrorTop), mirrorRotX) mc.setAttr("{0}.ry".format(ctrlToesMirrorTop), mirrorRotY) mc.setAttr("{0}.rz".format(ctrlToesMirrorTop), mirrorRotZ)''' mc.xform(ctrlToesMirrorTop, translation=(mirrorTransX, mirrorTransY, mirrorTransZ), ws=True, a=True) mc.xform(ctrlToesMirrorTop, scale=(mirrorXScal, 1, 1)) mc.xform(ctrlToesMirrorTop, rotation=(mirrorRotX, mirrorRotY, mirrorRotZ)) checkList = mc.listRelatives(ctrlToesMirrorTop) for i in range(len(checkList)): if mc.objectType(checkList[i]) == "transform": CRU.lockHideCtrls(checkList[i], translate=True, rotate=True, scale=True, toHide=True, visible=True, toLock=False) # mc.scale(-1, ctrlToesMirrorTop, x=True, pivot=(0,0,0), a=True) # mc.makeIdentity(ctrlToesMirrorTop, apply=True, translate=True, scale=True) return ctrlToesMirrorTop
def spineCleanup(self, fkHipOffsetCtrl, offsetCtrlFKJnts, spineIKs, spineIKCtrls, cogOffsetCtrl, crvSpine, ikSpine, fkHip, fkJnts, *args): # lock attributes CRU.lockHideCtrls(fkHipOffsetCtrl[1], translate=True, scale=True, visible=True) for i in range(len(offsetCtrlFKJnts)): CRU.lockHideCtrls(offsetCtrlFKJnts[i][1], translate=True, scale=True, visible=True) for i in range(len(spineIKs)): CRU.lockHideCtrls(spineIKCtrls[i][1], scale=True, visible=True) CRU.lockHideCtrls(cogOffsetCtrl[1], scale=True, visible=True) mc.setAttr('{0}.v'.format(crvSpine), False) mc.setAttr('{0}.v'.format(ikSpine), False) CRU.lockHideCtrls(crvSpine, visible=True) CRU.lockHideCtrls(ikSpine, visible=True) CRU.layerEdit(spineIKs, ikLayer=True, noRecurse=True) CRU.layerEdit(self.jointArray, bndLayer=True, noRecurse=True) CRU.layerEdit(fkHip, fkLayer=True, noRecurse=True) CRU.layerEdit(fkJnts, fkLayer=True, noRecurse=True)
myVals = ["tx", "ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz", "v"] sels = mc.ls(sl=True) sel = sels[0] print(sel) if len(sels) == 1: if CRU.checkObjectType(sel) == "mesh": print("I got here") dupMesh = mc.duplicate(sel, rc=True)[0] try: mc.parent(dupMesh, w=True) except: pass mc.select(dupMesh) CRU.lockHideCtrls(dupMesh, translate=True, rotate=True, scale=True, toHide=True, visible=True, toLock=False) if mc.objExists(nameSet): mc.sets(dupMesh, include=nameSet) else: mc.sets(dupMesh, n=nameSet) mc.move(0, 0, -100, dupMesh) else: print("Please select a geometry") else: print("Please select a single object")
def armCleanUp(self, fkJnts, ikJnts, ikJntsDrive, bndJnts, jntShoulderRoot, jntScapula, jntClavicle, checkboxSpine, shoulderOffsetCtrl, scapulaOffsetCtrl, clavicleOffsetCtrl, ikOffsetCtrl, elbowOffsetCtrl, ikArms, jntSpine6, ikSide, fkJntOffsetCtrls, ctrlFKIK, ctrlFKIKAttr, *args): mc.parent(fkJnts[0], ikJnts[0], ikJntsDrive[0], jntShoulderRoot) if checkboxSpine: mc.parentConstraint(jntSpine6, shoulderOffsetCtrl[0], mo=True) mc.pointConstraint(shoulderOffsetCtrl[1], jntShoulderRoot) # group OFFSET_CTRL_IK_l_arm, OFFSET_CTRL_l_elbow into GRP_CTRL_IK_l_arm ikGrpCtrlName = "GRP_CTRL_IK_" + ikSide ikGrpCtrl = mc.group(n=ikGrpCtrlName, w=True, em=True) mc.parent(ikOffsetCtrl[0], elbowOffsetCtrl[0], ikGrpCtrl) # group IK_l_arm, JNT_l_shouder into GRP_jnt_l_arm armGrpRigName = "GRP_jnt_" + ikSide armRigGrp = mc.group(n=armGrpRigName, w=True, em=True) mc.parent(ikArms[0], jntShoulderRoot, armRigGrp) # creating lists to set invisible fksToVisible = [fkJntOffsetCtrls[0][1], fkJnts[0]] iksToVisible = [ ikOffsetCtrl[1], ikJnts[0], ikJntsDrive[0], elbowOffsetCtrl[1] ] tangentToUse = ["linear", "step"] visMin = 0.001 # set the FK to visible when not ctrlFKIK not 1 for arm attribute for i in range(len(fksToVisible)): CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, fksToVisible[i], "visibility", drivenValue=True, driverValue=0, modifyInOut=tangentToUse) CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, fksToVisible[i], "visibility", drivenValue=True, driverValue=1 - visMin, modifyInOut=tangentToUse) CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, fksToVisible[i], "visibility", drivenValue=False, driverValue=1, modifyInOut=tangentToUse) tangentToUse = ["linear", "step"] # set the IK to visible when not ctrlFKIK not 0 for arm attribute for i in range(len(iksToVisible)): CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, iksToVisible[i], "visibility", drivenValue=False, driverValue=0, modifyInOut=tangentToUse) CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, iksToVisible[i], "visibility", drivenValue=True, driverValue=visMin, modifyInOut=tangentToUse) CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, iksToVisible[i], "visibility", drivenValue=True, driverValue=1, modifyInOut=tangentToUse) # locking and hiding the IK controls CRU.lockHideCtrls(ikOffsetCtrl[1], rotate=True, scale=True, visible=True) for fkJntOC in fkJntOffsetCtrls: CRU.lockHideCtrls(fkJntOC[1], translate=True, scale=True) CRU.lockHideCtrls(fkJntOC[1], visible=True, toLock=False) CRU.lockHideCtrls(shoulderOffsetCtrl[1], translate=True, scale=True, visible=True) CRU.lockHideCtrls(scapulaOffsetCtrl[1], translate=True, scale=True, visible=True) CRU.lockHideCtrls(clavicleOffsetCtrl[1], translate=True, scale=True, visible=True) CRU.lockHideCtrls(elbowOffsetCtrl[1], rotate=True, scale=True, visible=True) # hiding the visibility for the FK # locking and hiding the effectors and IK # to delete: May need to not have this hidden mc.setAttr("{0}.visibility".format(ikArms[0]), False) CRU.lockHideCtrls(ikArms[0], visible=True) CRU.lockHideCtrls(ikArms[1], visible=True) CRU.layerEdit(ikJnts, ikLayer=True, noRecurse=True) CRU.layerEdit(fkJnts, fkLayer=True, noRecurse=True) CRU.layerEdit(ikJntsDrive, ikdriveLayer=True, noRecurse=True) CRU.layerEdit(bndJnts, bndLayer=True, noRecurse=True) CRU.layerEdit(jntShoulderRoot, bndLayer=True, noRecurse=True) CRU.layerEdit(jntScapula, bndLayer=True, noRecurse=True) CRU.layerEdit(jntClavicle, bndLayer=True, noRecurse=True)
def legCleanUp(self, fkJnts, ikJnts, ikJntsDrive, bndJnts, ikOffsetCtrl, fkJntOffsetCtrls, hipIKOffsetCtrl, ctrlFKHip, leftRight, ctrlFKIK, ctrlFKIKAttr, checkboxHip, footCtrlsOffsetCtrl, *args): # group the root leg joints and the IK control grpLegRigName = "GRP_rig_" + leftRight + "leg" grpLegJntName = "GRP_JNT_" + leftRight + "leg" grpLegRig = mc.group(n=grpLegRigName, w=True, em=True) grpLegJnt = mc.group(n=grpLegJntName, w=True, em=True) mc.parent(fkJnts[0], ikJnts[0], ikJntsDrive[0], bndJnts[0], grpLegJnt) mc.parent(grpLegJnt, ikOffsetCtrl[0], footCtrlsOffsetCtrl[0], grpLegRig) # attach objects to the hip if checkboxHip: mc.parent(fkJntOffsetCtrls[0][0], hipIKOffsetCtrl[0], ctrlFKHip) # Hiding the visibility of the joints mc.setAttr("{0}.visibility".format(ikJnts[0]), False) mc.setAttr("{0}.visibility".format(ikJntsDrive[0]), False) mc.setAttr("{0}.visibility".format(fkJnts[0]), False) mc.setAttr("{0}.visibility".format(hipIKOffsetCtrl[1]), False) # locking and hiding the IK controls # my custom control shouldn't be moved by the animator CRU.lockHideCtrls(footCtrlsOffsetCtrl[1], translate=True, rotate=True, scale=True, visible=True) # locking and hiding the CTRL_IK_l_hip CRU.lockHideCtrls(hipIKOffsetCtrl[1], scale=True, visible=True) # set the FK to visible when not ctrlFKIK not 1 for leg attribute tangentToUse = ["linear", "step"] visMin = 0.001 CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, fkJntOffsetCtrls[0][1], "visibility", drivenValue=True, driverValue=0, modifyInOut=tangentToUse) CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, fkJntOffsetCtrls[0][1], "visibility", drivenValue=True, driverValue=1 - visMin, modifyInOut=tangentToUse) CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, fkJntOffsetCtrls[0][1], "visibility", drivenValue=False, driverValue=1, modifyInOut=tangentToUse) tangentToUse = ["linear", "step"] # set the IK to visible when not ctrlFKIK not 0 for leg attribute CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, ikOffsetCtrl[1], "visibility", drivenValue=False, driverValue=0, modifyInOut=tangentToUse) CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, ikOffsetCtrl[1], "visibility", drivenValue=True, driverValue=visMin, modifyInOut=tangentToUse) CRU.setDriverDrivenValues(ctrlFKIK, ctrlFKIKAttr, ikOffsetCtrl[1], "visibility", drivenValue=True, driverValue=1, modifyInOut=tangentToUse) CRU.layerEdit(fkJnts, fkLayer=True, noRecurse=True) CRU.layerEdit(ikJnts, ikLayer=True, noRecurse=True) CRU.layerEdit(ikJntsDrive, ikdriveLayer=True, noRecurse=True) CRU.layerEdit(bndJnts, bndLayer=True, noRecurse=True) CRU.lockHideCtrls(ikOffsetCtrl[1], rotate=True, scale=True, visible=True) for fkOC in fkJntOffsetCtrls: CRU.lockHideCtrls(fkOC[1], translate=True, scale=True, visible=True)