def IKFK(*args): #Mirror Joints cmds.select ( 'L_RF_Heel', 'L_RF_Fingers', 'L_RF_Ankle', 'L_Leg_JJ', 'L_Knee_JJ', 'L_Ankle_JJ', 'L_Ball_JJ', 'L_Fingers_JJ','L_RF_Ball') HideAxis = cmds.ls( selection=True ) for jnt in HideAxis: cmds.setAttr (jnt + ".displayLocalAxis", 0) cmds.duplicate ("L_Leg_JJ", rc = True) cmds.duplicate ("L_Leg_JJ", rc = True) cmds.rename ("L_Leg_JJ1", "L_Leg_FK") cmds.rename ("L_Knee_JJ1", "L_Knee_FK") cmds.rename ("L_Ankle_JJ1", "L_Ankle_FK") cmds.rename ("L_Ball_JJ1", "L_Ball_FK") cmds.rename ("L_Fingers_JJ1", "L_Fingers_FK") cmds.rename ("L_Leg_JJ2", "L_Leg_IK") cmds.rename ("L_Knee_JJ2", "L_Knee_IK") cmds.rename ("L_Ankle_JJ2", "L_Ankle_IK") cmds.rename ("L_Ball_JJ2", "L_Ball_IK") cmds.rename ("L_Fingers_JJ2", "L_Fingers_IK") cmds.mirrorJoint ('L_Leg_JJ',mirrorYZ = True, mirrorBehavior = True, searchReplace=('L_', 'R_')) cmds.mirrorJoint ('L_RF_Heel',mirrorYZ = True, mirrorBehavior = True, searchReplace=('L_', 'R_')) cmds.mirrorJoint ('L_Leg_FK',mirrorYZ = True, mirrorBehavior = True, searchReplace=('L_', 'R_')) cmds.mirrorJoint ('L_Leg_IK',mirrorYZ = True, mirrorBehavior = True, searchReplace=('L_', 'R_')) #IK GlobalMult = cmds.floatSliderGrp (RadioControlador, q = True, value = 2) radio = GlobalMult cmds.ikHandle (n="L_LegIKrp", sj="L_Leg_IK", ee= "L_Ankle_IK", sol='ikRPsolver') cmds.ikHandle (n="L_AnkleIKsch", sj="L_Ankle_IK", ee= "L_Ball_IK", sol = 'ikSCsolver') cmds.ikHandle (n="L_BallIKsch", sj="L_Ball_IK", ee= "L_Fingers_IK", sol = 'ikSCsolver') cmds.ikHandle (n="R_LegIKrp", sj="R_Leg_IK", ee= "R_Ankle_IK", sol='ikRPsolver') cmds.ikHandle (n="R_AnkleIKsch", sj="R_Ankle_IK", ee= "R_Ball_IK", sol = 'ikSCsolver') cmds.ikHandle (n="R_BallIKsch", sj="R_Ball_IK", ee= "R_Fingers_IK", sol = 'ikSCsolver') cmds.curve(n="L_LegIK_CC" , d=1, p=[(1, 1, 1),(1,1,-1) ,(1, -1, -1) ,(1, -1, 1) ,(-1, -1, 1) ,(-1, 1, 1) ,(1, 1, 1) ,(1, -1, 1) ,(-1, -1, 1) ,(-1, -1, -1) ,(-1, 1, -1) ,(1, 1, -1) ,(1, -1, -1) ,(-1, -1, -1) ,(-1, 1, -1) ,(-1, 1, 1)], k = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) cmds.group ("L_LegIK_CC", n= "L_LegIK_GRP") cmds.pointConstraint ("L_Ball_JJ", "L_LegIK_GRP") cmds.delete ("L_LegIK_GRP_pointConstraint1") cmds.orientConstraint ("L_Ball_JJ", "L_LegIK_GRP") cmds.delete ("L_LegIK_GRP_orientConstraint1") cmds.duplicate ('L_LegIK_CC',n='R_LegIK_CC') cmds.group ("R_LegIK_CC", n= "R_LegIK_GRP") cmds.parent ('R_LegIK_GRP', w = True) cmds.group(n = 'R_LegIK_GRP2', em = True) cmds.parent ('R_LegIK_GRP','R_LegIK_GRP2') cmds.setAttr('R_LegIK_GRP2.scaleX',-1) cmds.scale(GlobalMult,GlobalMult,GlobalMult,'L_LegIK_GRP', r = True) cmds.scale(GlobalMult,GlobalMult,GlobalMult,'R_LegIK_GRP', r = True) cmds.setAttr ("L_LegIK_CC.overrideEnabled", 1) cmds.setAttr ("R_LegIK_CC.overrideEnabled", 1) cmds.setAttr ("L_LegIK_CC.overrideColor", 6) cmds.setAttr ("R_LegIK_CC.overrideColor", 13) #FK GlobalMult = cmds.floatSliderGrp (RadioControlador, q = True, value = 2) radio = GlobalMult cmds.select ( 'L_Leg_FK', 'L_Knee_FK', 'L_Ankle_FK', 'R_Leg_FK', 'R_Knee_FK' ,'R_Ankle_FK','L_Ball_FK','R_Ball_FK') FKCircle = cmds.ls( selection=True ) for FK in FKCircle: cmds.circle (n= FK + str ('_CC'), r= radio, nr=(0, 1, 0)) cmds.group (n= FK + str ('_CC') + str ('GRP')) cmds.pointConstraint (FK, FK + str ('_CC') + str ('GRP'), mo= False) cmds.orientConstraint (FK, FK + str ('_CC') + str ('GRP'), mo= False) cmds.delete (FK + str ('_CC') + str ('GRP')+str('_pointConstraint1')) cmds.delete (FK + str ('_CC') + str ('GRP')+str('_orientConstraint1')) cmds.orientConstraint (FK + str ('_CC'),FK , mo= True) cmds.pointConstraint (FK + str ('_CC'),FK , mo= True) cmds.setAttr (FK + str ('_CC')+ str ('Shape.overrideEnabled'), 1) cmds.setAttr (FK + str ('_CC')+ str ('Shape.overrideColor'), 6) cmds.setAttr ('R_Leg_FK_CCShape.overrideColor',13) cmds.setAttr ('R_Knee_FK_CCShape.overrideColor',13) cmds.setAttr ('R_Ankle_FK_CCShape.overrideColor',13) cmds.setAttr ('R_Ball_FK_CCShape.overrideColor',13) cmds.parent ('L_Knee_FK_CCGRP','L_Leg_FK_CC') cmds.parent ('L_Ankle_FK_CCGRP','L_Knee_FK_CC') cmds.parent ('L_Ball_FK_CCGRP','L_Ankle_FK_CC') cmds.parent ('R_Knee_FK_CCGRP','R_Leg_FK_CC') cmds.parent ('R_Ankle_FK_CCGRP','R_Knee_FK_CC') cmds.parent ('R_Ball_FK_CCGRP','R_Ankle_FK_CC') #ReverseFoot cmds.parent ('L_RF_Heel','L_LegIK_CC') cmds.parent ('L_LegIKrp','L_RF_Ankle') cmds.parent ('L_AnkleIKsch','L_RF_Ball') cmds.parent ('L_BallIKsch','L_RF_Fingers') cmds.parent ('R_RF_Heel','R_LegIK_CC') cmds.parent ('R_LegIKrp','R_RF_Ankle') cmds.parent ('R_AnkleIKsch','R_RF_Ball') cmds.parent ('R_BallIKsch','R_RF_Fingers') cmds.addAttr ('L_LegIK_CC', ln= 'RollHeel', at= 'double' , dv = 0 ) cmds.setAttr ('L_LegIK_CC.RollHeel', k = True) cmds.connectAttr ('L_LegIK_CC.RollHeel','L_RF_Heel.rotateZ') cmds.addAttr ('L_LegIK_CC', ln= 'TwistHeel', at= 'double' , dv = 0 ) cmds.setAttr ('L_LegIK_CC.TwistHeel', k = True) cmds.connectAttr ('L_LegIK_CC.TwistHeel','L_RF_Heel.rotateY') cmds.addAttr ('L_LegIK_CC', ln= 'RollBall', at= 'double' , dv = 0 ) cmds.setAttr ('L_LegIK_CC.RollBall', k = True) cmds.connectAttr ('L_LegIK_CC.RollBall','L_RF_Ball.rotateZ') cmds.addAttr ('L_LegIK_CC', ln= 'TwistBall', at= 'double' , dv = 0 ) cmds.setAttr ('L_LegIK_CC.TwistBall', k = True) cmds.connectAttr ('L_LegIK_CC.TwistBall','L_RF_Ball.rotateY') cmds.addAttr ('L_LegIK_CC', ln= 'RollToe', at= 'double' , dv = 0 ) cmds.setAttr ('L_LegIK_CC.RollToe', k = True) cmds.connectAttr ('L_LegIK_CC.RollToe','L_RF_Fingers.rotateZ') cmds.addAttr ('R_LegIK_CC', ln= 'RollHeel', at= 'double' , dv = 0 ) cmds.setAttr ('R_LegIK_CC.RollHeel', k = True) cmds.connectAttr ('R_LegIK_CC.RollHeel','R_RF_Heel.rotateZ') cmds.addAttr ('R_LegIK_CC', ln= 'TwistHeel', at= 'double' , dv = 0 ) cmds.setAttr ('R_LegIK_CC.TwistHeel', k = True) cmds.connectAttr ('R_LegIK_CC.TwistHeel','R_RF_Heel.rotateY') cmds.addAttr ('R_LegIK_CC', ln= 'RollBall', at= 'double' , dv = 0 ) cmds.setAttr ('R_LegIK_CC.RollBall', k = True) cmds.connectAttr ('R_LegIK_CC.RollBall','R_RF_Ball.rotateZ') cmds.addAttr ('R_LegIK_CC', ln= 'TwistBall', at= 'double' , dv = 0 ) cmds.setAttr ('R_LegIK_CC.TwistBall', k = True) cmds.connectAttr ('R_LegIK_CC.TwistBall','R_RF_Ball.rotateY') cmds.addAttr ('R_LegIK_CC', ln= 'RollToe', at= 'double' , dv = 0 ) cmds.setAttr ('R_LegIK_CC.RollToe', k = True) cmds.connectAttr ('R_LegIK_CC.RollToe','R_RF_Fingers.rotateZ') #Pole Vector cmds.polyPlane (n="LLeg_PV_Plane", sh = 1, sw= 1) cmds.delete ("LLeg_PV_Plane.vtx[3]") cmds.cluster ("LLeg_PV_Plane.vtx[0]", n= "LegCluster") cmds.cluster ("LLeg_PV_Plane.vtx[1]" ,n= "KneeCluster") cmds.cluster ("LLeg_PV_Plane.vtx[2]", n= "AnkleCluster") cmds.pointConstraint ("L_Leg_JJ","LegClusterHandle") cmds.pointConstraint ("L_Knee_JJ","KneeClusterHandle") cmds.pointConstraint ("L_Ankle_JJ","AnkleClusterHandle") P01X = cmds.getAttr("L_Leg_JJ.translateX") P01Y = cmds.getAttr("L_Leg_JJ.translateY") P01Z = cmds.getAttr("L_Leg_JJ.translateZ") P02X = cmds.getAttr("L_Knee_JJ.translateX") + P01X P02Y = cmds.getAttr("L_Knee_JJ.translateY") + P01Y P02Z = cmds.getAttr("L_Knee_JJ.translateZ") + P01Z P03X = cmds.getAttr("L_Ankle_JJ.translateX") + P02X P03Y = cmds.getAttr("L_Ankle_JJ.translateY") + P02Y P03Z = cmds.getAttr("L_Ankle_JJ.translateZ") + P02Z P04X = cmds.getAttr("L_Fingers_JJ.translateX") + P03X P04Y = cmds.getAttr("L_Fingers_JJ.translateY") + P03Y P04Z = cmds.getAttr("L_Fingers_JJ.translateZ") + P03Z cmds.moveVertexAlongDirection ("LLeg_PV_Plane.vtx[1]", v= P02X+(P02X/2)) PVposition = cmds.pointPosition ("LLeg_PV_Plane.vtx[1]") cmds.circle (n="LLeg_PV01",nr=(0, 0, 1),r = radio/2) cmds.circle (n="LLeg_PV02",nr=(0, 1, 0),r = radio/2) cmds.circle (n="LLeg_PV03",nr=(1, 0, 0),r = radio/2) cmds.parent ("LLeg_PV02Shape","LLeg_PV01",r= True, s= True) cmds.parent ("LLeg_PV03Shape","LLeg_PV01",r= True, s= True) cmds.delete ("LLeg_PV02","LLeg_PV03") cmds.select ("LLeg_PV01") cmds.group (n= "LLeg_PV01_GRP", r= True) cmds.xform (t=PVposition) cmds.duplicate ("LLeg_PV01_GRP", n= "RLeg_PV_GRP") cmds.rename ("RLeg_PV_GRP|LLeg_PV01", "RLeg_PV01") cmds.rename ("LLeg_PV01_GRP", "LLeg_PV0_GRP") cmds.move(0, 0, 0, ".scalePivot",".rotatePivot", absolute=True) cmds.setAttr ("RLeg_PV_GRP.scaleX", -1) cmds.select ("LLeg_PV01","L_LegIKrp") cmds.PoleVectorConstraint () cmds.select ("RLeg_PV01","R_LegIKrp") cmds.PoleVectorConstraint () cmds.setAttr("RLeg_PV01Shape.overrideEnabled", True ) cmds.setAttr("RLeg_PV01Shape.overrideColor", 13 ) cmds.setAttr("RLeg_PV02Shape1.overrideEnabled", True ) cmds.setAttr("RLeg_PV02Shape1.overrideColor", 13 ) cmds.setAttr("RLeg_PV03Shape1.overrideEnabled", True ) cmds.setAttr("RLeg_PV03Shape1.overrideColor", 13 ) cmds.setAttr("LLeg_PV01Shape.overrideEnabled", True ) cmds.setAttr("LLeg_PV01Shape.overrideColor", 6 ) cmds.setAttr("LLeg_PV02Shape.overrideEnabled", True ) cmds.setAttr("LLeg_PV02Shape.overrideColor", 6 ) cmds.setAttr("LLeg_PV03Shape.overrideEnabled", True ) cmds.setAttr("LLeg_PV03Shape.overrideColor", 6 ) cmds.group ("LLeg_PV_Plane","LegClusterHandle","KneeClusterHandle","AnkleClusterHandle", n= "ExtrasAutoLegs") cmds.setAttr ("ExtrasAutoLegs.visibility", 0) #Switch IK FK if cmds.objExists ("IK_FK_CC"): print "CurveControl IKFK Exists" else: if cmds.objExists('makeTextCurves1'): cmds.rename ('makeTextCurves1','makeTextCurves1LOL') Texto = 'IK-FK' Color = 16 Text = cmds.textCurves (n= Texto, t = Texto, o = True) Lista= cmds.listRelatives (Text, ad = True) Shape = Lista[1] cmds.delete ('makeTextCurves1') for Curva in Lista: if cmds.objectType(str(Curva), isType='nurbsCurve'): curvaPapa = cmds.listRelatives(Curva, p = True) curvaAbuelo = cmds.listRelatives(curvaPapa, p = True) DobleCurva = cmds.listRelatives(curvaAbuelo) if len(DobleCurva)==2: LetrasDobles.append (Curva) else: if not Shape == curvaPapa[0]: cmds.makeIdentity (curvaAbuelo, a = True, t = True , r = True) cmds.parent (Curva, Shape, r = True, s = True) #Colores cmds.setAttr (Curva+'.overrideEnabled', 1) cmds.setAttr (Curva+'.overrideColor', Color) cmds.parent (Shape,w=True) cmds.rename(Shape, 'IK_FK_CC') cmds.setAttr ("IK_FK_CC.overrideEnabled", 1) cmds.setAttr ("IK_FK_CC.overrideColor", 16) cmds.setAttr ('IK_FK_CC.rotateX', -90) cmds.xform(cp= True) cmds.setAttr ('IK_FK_CC.scaleX', GlobalMult) cmds.setAttr ('IK_FK_CC.scaleY', GlobalMult) cmds.setAttr ('IK_FK_CC.scaleZ', GlobalMult) cmds.makeIdentity(a=True, t = True, r = True, s=True) cmds.select ("IK_FK_CC") cmds.addAttr (ln= "LeftLegIKFK", min=0, max=1) cmds.setAttr ("IK_FK_CC.LeftLegIKFK", keyable = True) cmds.select ("IK_FK_CC") cmds.addAttr (ln= "RightLegIKFK", min=0, max=1) cmds.setAttr ("IK_FK_CC.RightLegIKFK", keyable = True) cmds.expression (n="L_Leg_Switch", s = "L_Leg_JJ.rotateX = (L_Leg_FK.rotateX* IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.rotateX*(1- IK_FK_CC.LeftLegIKFK)); \nL_Leg_JJ.rotateY = (L_Leg_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Leg_JJ.rotateZ = (L_Leg_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.rotateX = (L_Knee_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.rotateY = (L_Knee_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.rotateZ = (L_Knee_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.rotateX = (L_Ankle_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.rotateY = (L_Ankle_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.rotateZ = (L_Ankle_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.rotateX = (L_Ball_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.rotateY = (L_Ball_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.rotateZ = (L_Ball_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.rotateX = (L_Fingers_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.rotateY = (L_Fingers_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.rotateZ = (L_Fingers_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \n \nL_Leg_JJ.translateX = (L_Leg_FK.translateX* IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.translateX*(1- IK_FK_CC.LeftLegIKFK)); \nL_Leg_JJ.translateY = (L_Leg_FK.translateY*IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Leg_JJ.translateZ = (L_Leg_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.translateX = (L_Knee_FK.translateX*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.translateY = (L_Knee_FK.translateY*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.translateZ = (L_Knee_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.translateX = (L_Ankle_FK.translateX*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.translateY = (L_Ankle_FK.translateY*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.translateZ = (L_Ankle_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.translateX = (L_Ball_FK.translateX*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.translateY = (L_Ball_FK.translateY*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.translateZ = (L_Ball_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.translateX = (L_Fingers_FK.translateX*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.translateY = (L_Fingers_FK.translateY*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.translateZ = (L_Fingers_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \n \n \nL_Leg_FK_CC.visibility = IK_FK_CC.LeftLegIKFK; \nL_LegIK_CC.visibility = (1-IK_FK_CC.LeftLegIKFK); \nLLeg_PV01.visibility = (1-IK_FK_CC.LeftLegIKFK);" ) cmds.expression (n="R_Leg_Switch", s = "R_Leg_JJ.rotateX = (R_Leg_FK.rotateX* IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.rotateX*(1- IK_FK_CC.LeftLegIKFK)); \nR_Leg_JJ.rotateY = (R_Leg_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Leg_JJ.rotateZ = (R_Leg_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.rotateX = (R_Knee_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.rotateY = (R_Knee_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.rotateZ = (R_Knee_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.rotateX = (R_Ankle_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.rotateY = (R_Ankle_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.rotateZ = (R_Ankle_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.rotateX = (R_Ball_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.rotateY = (R_Ball_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.rotateZ = (R_Ball_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.rotateX = (R_Fingers_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.rotateY = (R_Fingers_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.rotateZ = (R_Fingers_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \n \nR_Leg_JJ.translateX = (R_Leg_FK.translateX* IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.translateX*(1- IK_FK_CC.LeftLegIKFK)); \nR_Leg_JJ.translateY = (R_Leg_FK.translateY*IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Leg_JJ.translateZ = (R_Leg_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.translateX = (R_Knee_FK.translateX*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.translateY = (R_Knee_FK.translateY*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.translateZ = (R_Knee_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.translateX = (R_Ankle_FK.translateX*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.translateY = (R_Ankle_FK.translateY*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.translateZ = (R_Ankle_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.translateX = (R_Ball_FK.translateX*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.translateY = (R_Ball_FK.translateY*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.translateZ = (R_Ball_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.translateX = (R_Fingers_FK.translateX*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.translateY = (R_Fingers_FK.translateY*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.translateZ = (R_Fingers_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \n \n \nR_Leg_FK_CC.visibility = IK_FK_CC.RightLegIKFK; \nR_LegIK_CC.visibility = (1-IK_FK_CC.RightLegIKFK); \nRLeg_PV01.visibility = (1-IK_FK_CC.RightLegIKFK);" ) # Grouping and Organizing cmds.group ('L_Leg_JJ', 'L_Leg_FK', 'L_Leg_IK ','L_Leg_FK_CCGRP', n = 'L_Leg_Joints') cmds.group ('R_Leg_JJ', 'R_Leg_FK', 'R_Leg_IK ','R_Leg_FK_CCGRP', n = 'R_Leg_Joints') cmds.group ("L_LegIK_GRP", "LLeg_PV0_GRP", n="L_IKLeg_GRP") cmds.group ("R_LegIK_GRP", "RLeg_PV_GRP", n="R_IKLeg_GRP") cmds.group ("L_IKLeg_GRP", "R_IKLeg_GRP",'L_Leg_Joints','R_Leg_Joints',n= "Connect this to the rest of the rig") cmds.group ('ExtrasAutoLegs',"Connect_this_to_the_rest_of_the_rig", n="RdM_AutoLEGS" ) cmds.select ('L_Ball_JJ', 'L_Ankle_JJ', 'L_Knee_JJ', 'L_Leg_JJ','R_Ball_JJ', 'R_Leg_JJ', 'R_Knee_JJ', 'R_Ankle_JJ') cmds.sets (n= 'BindThisToLegs') cmds.delete('R_LegIK_GRP2') #Locking Attr #FK cmds.select ('R_Leg_FK_CC','R_Knee_FK_CC','R_Ankle_FK_CC','R_Ball_FK_CC','L_Leg_FK_CC','L_Knee_FK_CC','L_Ankle_FK_CC','L_Ball_FK_CC') FK = cmds.ls(sl=True) for T in FK: cmds.setAttr(str(T)+'.translateX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.translateY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.translateZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.visibility',lock = True, keyable = False, channelBox = False) #IK, Clavicule cmds.select ('L_LegIK_CC', 'R_LegIK_CC') IK = cmds.ls(sl=True) for T in IK: cmds.setAttr(str(T)+'.scaleX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.visibility',lock = True, keyable = False, channelBox = False) #Pole Vector cmds.select ('LLeg_PV01', 'RLeg_PV01') PV = cmds.ls(sl=True) for T in PV: cmds.setAttr(str(T)+'.rotateX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.rotateY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.rotateZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.visibility',lock = True, keyable = False, channelBox = False) print ('Legs DONE')
def ik_fk_switch(blend_objs, ik_objs, fk_objs, switch_obj, pole_vector_obj): """ creates an ik fk switch between the given objects :param blend_objs: the objs to be driven by the ik and fk :type: list :param ik_objs: list of the ik objs :type: list :param fk_objs: list of fk objs :type: list :param switch_obj: name of object to get the ik fk switch :type: str :param pole_vector_obj: name of the obj to be the pole vector :type: str """ #first create the ik handle cmds.select(ik_objs[0], replace=True) cmds.select(ik_objs[-1], add=True) ik_names = cmds.ikHandle() #rename the objs that the ik handle makes base = ik_objs[-1].rsplit('_', 1)[0] ik_handle = cmds.rename(ik_names[0], base + '_RPIK') cmds.rename(ik_names[1], base + '_Effector') #parent the ik handle to the cc and the pv to the ik ik_cc = base + '_IK' + NamingConventionEnums.CONTROL_CURVE_SUFFIX cmds.parent(ik_handle, ik_cc) cmds.select(pole_vector_obj, replace=True) cmds.select(ik_handle, add=True) cmds.PoleVectorConstraint() #orient the wrist to the IK control so the rotation follows it orient_const(ik_cc, ik_objs[-1], base + 'IK_' + NamingConventionEnums.CONSTRAIN_SUFFIX) #set the visibility of the ik control lock_channels(ik_cc, 'visibility', to_lock=False) lock_channels(pole_vector_obj, 'visibility', to_lock=False) cmds.connectAttr(switch_obj + '.ikFkSwitch', ik_cc + '.visibility') cmds.connectAttr(switch_obj + '.ikFkSwitch', pole_vector_obj + '.visibility') #create the FK controls for fk_jnt in fk_objs: create_fk_control(fk_jnt) #set the vis of the FK controls rev = cmds.shadingNode('reverse', asUtility=True, name=blend_objs[-1] + '_REV') cmds.connectAttr(switch_obj + '.ikFkSwitch', rev + '.inputX') cmds.connectAttr(rev + '.outputX', fk_objs[0] + '.visibility') #blend the ik and fk joints to the main chain for i in range(len(blend_objs)): #create the blend colors bc = cmds.shadingNode('blendColors', asUtility=True, name=blend_objs[i] + '_BC') #connect everything cmds.connectAttr(fk_objs[i] + '.rotate', bc + '.color2') cmds.connectAttr(ik_objs[i] + '.rotate', bc + '.color1') cmds.connectAttr(bc + '.output', blend_objs[i] + '.rotate') #connect the switch obj cmds.connectAttr(switch_obj + '.ikFkSwitch', bc + '.blender') group_name = blend_objs[0].replace(NamingConventionEnums.JOINT_SUFFIX, NamingConventionEnums.GROUP_SUFFIX) group_name = group_name.replace('hip', 'leg_jnts') group_name = group_name.replace('shoulder', 'arm_jnts') cmds.group([blend_objs[0], ik_objs[0], fk_objs[0]], name=group_name) #parent the controls to the rig hierarchy #get the buffer group above the ik cc and the pv cc ik_buffer = cmds.listRelatives(ik_cc, parent=True)[0] pv_buffer = cmds.listRelatives(pole_vector_obj, parent=True)[0] cmds.parent(ik_buffer, NamingConventionEnums.RIG_HIERARCHY[8]) cmds.parent(pv_buffer, NamingConventionEnums.RIG_HIERARCHY[8]) #hide the ik handles cmds.setAttr(ik_handle + '.visibility', 0)
def IKFK(*args): for X in range (1,jointsNum + 1): cmds.setAttr ("L_arm_" + str(X) + ".displayLocalAxis", 0) cmds.setAttr ("R_arm_" + str(X) + ".displayLocalAxis", 0) cmds.duplicate ("L_arm_2", rc = True) cmds.duplicate ("L_arm_2", rc = True) cmds.rename ("L_arm_5", "L_arm_01_IK") cmds.rename ("L_arm_6", "L_arm_02_IK") cmds.rename ("L_arm_7", "L_arm_03_IK") cmds.rename ("L_arm_8", "L_arm_01_FK") cmds.rename ("L_arm_9", "L_arm_02_FK") cmds.rename ("L_arm_10", "L_arm_03_FK") if cmds.objExists('R_arm_1'): print 'Mirror already aplied' cmds.duplicate ("R_arm_2", rc = True) cmds.duplicate ("R_arm_2", rc = True) cmds.rename ("R_arm_5", "R_arm_01_IK") cmds.rename ("R_arm_6", "R_arm_02_IK") cmds.rename ("R_arm_7", "R_arm_03_IK") cmds.rename ("R_arm_8", "R_arm_01_FK") cmds.rename ("R_arm_9", "R_arm_02_FK") cmds.rename ("R_arm_10", "R_arm_03_FK") else: cmds.select("L_arm_1") cmds.mirrorJoint (mirrorYZ = True, mirrorBehavior = True, searchReplace=('L_', 'R_') ) cmds.ikHandle (n="L_ArmIKrp", sj="L_arm_01_IK", ee= "L_arm_03_IK") cmds.ikHandle (n="R_ArmIKrp", sj="R_arm_01_IK", ee= "R_arm_03_IK") #Controladores ############################ GlobalMult = cmds.floatSliderGrp (RadioControlador, q = True, value = 2) ############################ #Clavicule cmds.circle (r= 3*GlobalMult,nr=(1, 0, 0), n= "L_clavicule_01_CC", ch= 0 ) cmds.group ("L_clavicule_01_CC", n="L_clavicule_01_GRP") cmds.parentConstraint ("L_arm_1", "L_clavicule_01_GRP" ) cmds.delete ("L_clavicule_01_GRP_parentConstraint1" ) cmds.makeIdentity ("L_clavicule_01_CC", apply = True, t = True) cmds.setAttr("L_clavicule_01_CC" + "Shape.overrideEnabled", True ) cmds.setAttr("L_clavicule_01_CC" + "Shape.overrideColor", 6 ) cmds.duplicate ('L_clavicule_01_CC',n= "R_clavicule_01_CC") cmds.group ("R_clavicule_01_CC", n="R_clavicule_01_GRP") cmds.parentConstraint ("R_arm_1", "R_clavicule_01_GRP" ) cmds.delete ("R_clavicule_01_GRP_parentConstraint1" ) cmds.makeIdentity ("R_clavicule_01_CC", apply = True, t = True) cmds.setAttr("R_clavicule_01_CC" + "Shape.overrideEnabled", True ) cmds.setAttr("R_clavicule_01_CC" + "Shape.overrideColor", 13 ) #cmds.orientConstraint ('L_clavicule_01_CC','L_arm_1') #cmds.orientConstraint ('R_clavicule_01_CC','R_arm_1') #FK for P in range (1,jointsNum): cmds.circle (r= 2*GlobalMult ,nr=(1, 0, 0), n= "L_armFK_0" +str(P) + "_CC", ch= 0 ) cmds.group ("L_armFK_0" +str(P) + "_CC", n="L_armFK_0" +str(P) + "_GRP") cmds.parentConstraint ("L_arm_0" +str(P) + "_FK", "L_armFK_0" +str(P) + "_GRP" ) cmds.delete ("L_armFK_0"+str(P)+ "_GRP_parentConstraint1" ) cmds.makeIdentity ("L_armFK_0" +str(P) + "_CC", apply = True, t = True) cmds.setAttr("L_armFK_0" + str(P) + "_CCShape.overrideEnabled", True ) cmds.setAttr("L_armFK_0" + str(P) + "_CCShape.overrideColor", 6 ) cmds.circle (r= 2*GlobalMult ,nr=(1, 0, 0), n= "R_armFK_0" +str(P) + "_CC", ch= 0 ) cmds.group ("R_armFK_0" +str(P) + "_CC", n="R_armFK_0" +str(P) + "_GRP") cmds.parentConstraint ("R_arm_0" +str(P) + "_FK", "R_armFK_0" +str(P) + "_GRP" ) cmds.delete ("R_armFK_0"+str(P)+ "_GRP_parentConstraint1" ) cmds.makeIdentity ("R_armFK_0" +str(P) + "_CC", apply = True, t = True) cmds.setAttr("R_armFK_0" + str(P) + "_CCShape.overrideEnabled", True ) cmds.setAttr("R_armFK_0" + str(P) + "_CCShape.overrideColor", 13 ) cmds.parent ("L_armFK_01_GRP", "L_clavicule_01_CC") cmds.parent ( "L_armFK_02_GRP","L_armFK_01_CC") cmds.parent ( "L_armFK_03_GRP","L_armFK_02_CC") cmds.parent ("R_armFK_01_GRP", "R_clavicule_01_CC") cmds.parent ( "R_armFK_02_GRP","R_armFK_01_CC") cmds.parent ( "R_armFK_03_GRP","R_armFK_02_CC") cmds.parentConstraint ("L_clavicule_01_CC","L_arm_1") cmds.parentConstraint ("L_armFK_01_CC","L_arm_01_FK") cmds.parentConstraint ("L_armFK_02_CC","L_arm_02_FK") cmds.parentConstraint ("L_armFK_03_CC","L_arm_03_FK") cmds.parentConstraint ("R_clavicule_01_CC","R_arm_1") cmds.parentConstraint ("R_armFK_01_CC","R_arm_01_FK") cmds.parentConstraint ("R_armFK_02_CC","R_arm_02_FK") cmds.parentConstraint ("R_armFK_03_CC","R_arm_03_FK") #IK cmds.curve(n="L_armIK_CC" , d=1, p=[(1, 1, 1),(1,1,-1) ,(1, -1, -1) ,(1, -1, 1) ,(-1, -1, 1) ,(-1, 1, 1) ,(1, 1, 1) ,(1, -1, 1) ,(-1, -1, 1) ,(-1, -1, -1) ,(-1, 1, -1) ,(1, 1, -1) ,(1, -1, -1) ,(-1, -1, -1) ,(-1, 1, -1) ,(-1, 1, 1)], k = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) cmds.group ("L_armIK_CC", n= "L_armIK_GRP") cmds.pointConstraint ("L_arm_03_IK", "L_armIK_GRP") cmds.delete ("L_armIK_GRP_pointConstraint1") cmds.orientConstraint ("L_arm_02_IK", "L_armIK_GRP") cmds.delete ("L_armIK_GRP_orientConstraint1") cmds.curve(n="R_armIK_CC" , d=1, p=[(1, 1, 1),(1,1,-1) ,(1, -1, -1) ,(1, -1, 1) ,(-1, -1, 1) ,(-1, 1, 1) ,(1, 1, 1) ,(1, -1, 1) ,(-1, -1, 1) ,(-1, -1, -1) ,(-1, 1, -1) ,(1, 1, -1) ,(1, -1, -1) ,(-1, -1, -1) ,(-1, 1, -1) ,(-1, 1, 1)], k = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) cmds.group ("R_armIK_CC", n= "R_armIK_GRP") cmds.pointConstraint ("R_arm_03_IK", "R_armIK_GRP") cmds.delete ("R_armIK_GRP_pointConstraint1") cmds.orientConstraint ("R_arm_02_IK", "R_armIK_GRP") cmds.delete ("R_armIK_GRP_orientConstraint1") cmds.parent ("L_ArmIKrp", "L_armIK_CC") cmds.parent ("R_ArmIKrp", "R_armIK_CC") cmds.orientConstraint ("L_armIK_CC","L_arm_03_IK", mo= True) cmds.orientConstraint ("R_armIK_CC","R_arm_03_IK", mo= True) cmds.scale(GlobalMult,GlobalMult,GlobalMult,'L_armIK_GRP', r = True) cmds.scale(GlobalMult,GlobalMult,GlobalMult,'R_armIK_GRP', r = True) cmds.setAttr ("L_armIK_CC.overrideEnabled", 1) cmds.setAttr ("R_armIK_CC.overrideEnabled", 1) cmds.setAttr ("L_armIK_CC.overrideColor", 6) cmds.setAttr ("R_armIK_CC.overrideColor", 13) #Pole Vector cmds.polyPlane (n="L_PV_Plane", sh = 1, sw= 1) cmds.delete ("L_PV_Plane.vtx[3]") cmds.cluster ("L_PV_Plane.vtx[0]", n= "ShoulderCluster") cmds.cluster ("L_PV_Plane.vtx[1]" ,n= "ElbowCluster") cmds.cluster ("L_PV_Plane.vtx[2]", n= "WristCluster") cmds.pointConstraint ("L_arm_2","ShoulderClusterHandle") cmds.pointConstraint ("L_arm_3","ElbowClusterHandle") cmds.pointConstraint ("L_arm_4","WristClusterHandle") P01X = cmds.getAttr("L_arm_1.translateX") P01Y = cmds.getAttr("L_arm_1.translateY") P01Z = cmds.getAttr("L_arm_1.translateZ") P02X = cmds.getAttr("L_arm_2.translateX") + P01X P02Y = cmds.getAttr("L_arm_2.translateY") + P01Y P02Z = cmds.getAttr("L_arm_2.translateZ") + P01Z P03X = cmds.getAttr("L_arm_3.translateX") + P02X P03Y = cmds.getAttr("L_arm_3.translateY") + P02Y P03Z = cmds.getAttr("L_arm_3.translateZ") + P02Z P04X = cmds.getAttr("L_arm_4.translateX") + P03X P04Y = cmds.getAttr("L_arm_4.translateY") + P03Y P04Z = cmds.getAttr("L_arm_4.translateZ") + P03Z cmds.moveVertexAlongDirection ("L_PV_Plane.vtx[1]", u= P02X+(P02X/2)) PVposition = cmds.pointPosition ("L_PV_Plane.vtx[1]") cmds.circle (n="L_PV01",nr=(0, 0, 1), r = GlobalMult) cmds.circle (n="L_PV02",nr=(0, 1, 0), r = GlobalMult) cmds.circle (n="L_PV03",nr=(1, 0, 0), r = GlobalMult) cmds.parent ("L_PV02Shape","L_PV01",r= True, s= True) cmds.parent ("L_PV03Shape","L_PV01",r= True, s= True) cmds.delete ("L_PV02","L_PV03") cmds.select ("L_PV01") cmds.group (n= "L_PV01_GRP", r= True) cmds.xform (t=PVposition) cmds.duplicate ("L_PV01_GRP", n= "R_PV_GRP") cmds.rename ("R_PV_GRP|L_PV01", "R_PV01") cmds.rename ("L_PV01_GRP", "L_PV0_GRP") cmds.move(0, 0, 0, ".scalePivot",".rotatePivot", absolute=True) cmds.setAttr ("R_PV_GRP.scaleX", -1) cmds.xform('R_PV_GRP', cp = True) cmds.select ("L_PV01","L_ArmIKrp") cmds.PoleVectorConstraint () cmds.select ("R_PV01","R_ArmIKrp") cmds.PoleVectorConstraint () cmds.setAttr("R_PV01Shape.overrideEnabled", True ) cmds.setAttr("R_PV01Shape.overrideColor", 13 ) cmds.setAttr("R_PV02Shape1.overrideEnabled", True ) cmds.setAttr("R_PV02Shape1.overrideColor", 13 ) cmds.setAttr("R_PV03Shape1.overrideEnabled", True ) cmds.setAttr("R_PV03Shape1.overrideColor", 13 ) cmds.setAttr("L_PV01Shape.overrideEnabled", True ) cmds.setAttr("L_PV01Shape.overrideColor", 6 ) cmds.setAttr("L_PV02Shape.overrideEnabled", True ) cmds.setAttr("L_PV02Shape.overrideColor", 6 ) cmds.setAttr("L_PV03Shape.overrideEnabled", True ) cmds.setAttr("L_PV03Shape.overrideColor", 6 ) #SwitchIKFK if cmds.objExists ("IK_FK_CC"): print "CurveControl IKFK Exists" else: if cmds.objExists('makeTextCurves1'): cmds.rename ('makeTextCurves1','makeTextCurves1LOL') Texto = 'IK-FK' Color = 16 Text = cmds.textCurves (n= Texto, t = Texto, o = True) Lista= cmds.listRelatives (Text, ad = True) Shape = Lista[1] cmds.delete ('makeTextCurves1') for Curva in Lista: if cmds.objectType(str(Curva), isType='nurbsCurve'): curvaPapa = cmds.listRelatives(Curva, p = True) curvaAbuelo = cmds.listRelatives(curvaPapa, p = True) DobleCurva = cmds.listRelatives(curvaAbuelo) if len(DobleCurva)==2: LetrasDobles.append (Curva) else: if not Shape == curvaPapa[0]: cmds.makeIdentity (curvaAbuelo, a = True, t = True , r = True) cmds.parent (Curva, Shape, r = True, s = True) #Colores cmds.setAttr (Curva+'.overrideEnabled', 1) cmds.setAttr (Curva+'.overrideColor', Color) cmds.parent (Shape,w=True) cmds.rename(Shape, 'IK_FK_CC') cmds.setAttr ("IK_FK_CC.overrideEnabled", 1) cmds.setAttr ("IK_FK_CC.overrideColor", 16) cmds.setAttr ('IK_FK_CC.rotateX', -90) cmds.xform(cp= True) cmds.setAttr ('IK_FK_CC.scaleX', GlobalMult) cmds.setAttr ('IK_FK_CC.scaleY', GlobalMult) cmds.setAttr ('IK_FK_CC.scaleZ', GlobalMult) cmds.makeIdentity(a=True, t = True, r = True, s=True) if cmds.objExists("IK_FK_CC.LeftArmIKFK") : print 'existe Attr' else: cmds.select ("IK_FK_CC") cmds.addAttr (ln= "LeftArmIKFK", min=0, max=1) cmds.setAttr ("IK_FK_CC.LeftArmIKFK", keyable = True) if cmds.objExists("IK_FK_CC.RightArmIKFK") : print 'existe Attr' else: cmds.select ("IK_FK_CC") cmds.addAttr (ln= "RightArmIKFK", min=0, max=1) cmds.setAttr ("IK_FK_CC.RightArmIKFK", keyable = True) cmds.expression (n="L_Arms_Switch", s = "L_arm_2.rotateX = (L_arm_01_FK.rotateX*IK_FK_CC.LeftArmIKFK)+(L_arm_01_IK.rotateX*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_2.rotateY = (L_arm_01_FK.rotateY*IK_FK_CC.LeftArmIKFK)+(L_arm_01_IK.rotateY*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_2.rotateZ = (L_arm_01_FK.rotateZ*IK_FK_CC.LeftArmIKFK)+(L_arm_01_IK.rotateZ*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_3.rotateX = (L_arm_02_FK.rotateX*IK_FK_CC.LeftArmIKFK)+(L_arm_02_IK.rotateX*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_3.rotateY = (L_arm_02_FK.rotateY*IK_FK_CC.LeftArmIKFK)+(L_arm_02_IK.rotateY*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_3.rotateZ = (L_arm_02_FK.rotateZ*IK_FK_CC.LeftArmIKFK)+(L_arm_02_IK.rotateZ*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_4.rotateX = (L_arm_03_FK.rotateX*IK_FK_CC.LeftArmIKFK)+(L_arm_03_IK.rotateX*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_4.rotateY = (L_arm_03_FK.rotateY*IK_FK_CC.LeftArmIKFK)+(L_arm_03_IK.rotateY*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_4.rotateZ = (L_arm_03_FK.rotateZ*IK_FK_CC.LeftArmIKFK)+(L_arm_03_IK.rotateZ*(1-IK_FK_CC.LeftArmIKFK));\nL_armFK_03_CC.visibility = IK_FK_CC.LeftArmIKFK;\nL_armFK_02_CC.visibility = IK_FK_CC.LeftArmIKFK;\nL_armFK_01_CC.visibility = IK_FK_CC.LeftArmIKFK;\nL_armIK_CC.visibility = (1-IK_FK_CC.LeftArmIKFK);") cmds.expression (n="R_Arms_Switch", s = "R_arm_2.rotateX = (R_arm_01_FK.rotateX*IK_FK_CC.RightArmIKFK)+(R_arm_01_IK.rotateX*(1-IK_FK_CC.RightArmIKFK));\nR_arm_2.rotateY = (R_arm_01_FK.rotateY*IK_FK_CC.RightArmIKFK)+(R_arm_01_IK.rotateY*(1-IK_FK_CC.RightArmIKFK));\nR_arm_2.rotateZ = (R_arm_01_FK.rotateZ*IK_FK_CC.RightArmIKFK)+(R_arm_01_IK.rotateZ*(1-IK_FK_CC.RightArmIKFK));\nR_arm_3.rotateX = (R_arm_02_FK.rotateX*IK_FK_CC.RightArmIKFK)+(R_arm_02_IK.rotateX*(1-IK_FK_CC.RightArmIKFK));\nR_arm_3.rotateY = (R_arm_02_FK.rotateY*IK_FK_CC.RightArmIKFK)+(R_arm_02_IK.rotateY*(1-IK_FK_CC.RightArmIKFK));\nR_arm_3.rotateZ = (R_arm_02_FK.rotateZ*IK_FK_CC.RightArmIKFK)+(R_arm_02_IK.rotateZ*(1-IK_FK_CC.RightArmIKFK));\nR_arm_4.rotateX = (R_arm_03_FK.rotateX*IK_FK_CC.RightArmIKFK)+(R_arm_03_IK.rotateX*(1-IK_FK_CC.RightArmIKFK));\nR_arm_4.rotateY = (R_arm_03_FK.rotateY*IK_FK_CC.RightArmIKFK)+(R_arm_03_IK.rotateY*(1-IK_FK_CC.RightArmIKFK));\nR_arm_4.rotateZ = (R_arm_03_FK.rotateZ*IK_FK_CC.RightArmIKFK)+(R_arm_03_IK.rotateZ*(1-IK_FK_CC.RightArmIKFK));\nR_armFK_03_CC.visibility = IK_FK_CC.RightArmIKFK;\nR_armFK_02_CC.visibility = IK_FK_CC.RightArmIKFK;\nR_armFK_01_CC.visibility = IK_FK_CC.RightArmIKFK;\nR_armIK_CC.visibility = (1-IK_FK_CC.RightArmIKFK);") cmds.setAttr ("IK_FK_CC.overrideEnabled", 1) cmds.setAttr ("IK_FK_CC.overrideColor", 18) #Twist cmds.moveVertexAlongDirection ("L_PV_Plane.vtx[1]", u= -(P02X+(P02X/2))) V03position = cmds.pointPosition ("L_PV_Plane.vtx[2]") V02position = cmds.pointPosition ("L_PV_Plane.vtx[1]") V01position = cmds.pointPosition ("L_PV_Plane.vtx[0]") cmds.curve (n= "L_UpArmTwist",d=1, p=[(0,0,0),(10,0,0)], k = (0,1)) cmds.curve (n= "L_DownArmTwist",d=1, p=[(0,0,0),(10,0,0)], k = (0,1)) cmds.xform ("L_UpArmTwist.cv[0]" ,t=V01position) cmds.xform ("L_UpArmTwist.cv[1]" ,t=V02position) cmds.xform ("L_DownArmTwist.cv[0]" ,t=V02position) cmds.xform ("L_DownArmTwist.cv[1]" ,t=V03position) cmds.duplicate ("L_UpArmTwist", n="R_UpArmTwist") cmds.duplicate ("L_DownArmTwist", n="R_DownArmTwist") cmds.scale (-1,1,1, "R_UpArmTwist", a= True) cmds.scale (-1,1,1, "R_DownArmTwist", a= True) def FuckingSwitch (side): cmds.duplicate (str(side)+ "_arm_2", n= str(side)+"_UpArmTwist01") cmds.parent (str(side)+ "_UpArmTwist01", world = True) cmds.rename (str(side)+ "_UpArmTwist01|"+str(side)+"_arm_3",str(side)+ "_UpArmTwist03") cmds.duplicate (str(side)+ "_UpArmTwist03", n= str(side)+ "_DownArmTwist01") cmds.delete (str(side)+ "_UpArmTwist03|"+str(side)+"_arm_4") cmds.rename (str(side)+ "_DownArmTwist01|"+str(side)+"_arm_4",str(side)+"_DownArmTwist03") cmds.parent (str(side)+ '_DownArmTwist01', w = True) cmds.duplicate (str(side)+ "_UpArmTwist03",n= str(side)+ "_UpArmTwist02") cmds.duplicate (str(side)+ "_DownArmTwist03",n= str(side)+ "_DownArmTwist02") cmds.pointConstraint (str(side)+ "_UpArmTwist03",str(side)+ "_UpArmTwist01",str(side)+ "_UpArmTwist02", mo = False) cmds.pointConstraint (str(side)+ "_DownArmTwist03",str(side)+ "_DownArmTwist01",str(side)+ "_DownArmTwist02", mo = False) cmds.orientConstraint (str(side)+ "_UpArmTwist03",str(side)+ "_UpArmTwist01",str(side)+ "_UpArmTwist02", mo = True) cmds.orientConstraint (str(side)+ "_DownArmTwist03",str(side)+ "_DownArmTwist01",str(side)+ "_DownArmTwist02", mo = True) cmds.delete(str(side)+ "_UpArmTwist02_pointConstraint1",str(side)+ "_DownArmTwist02_pointConstraint1") cmds.delete(str(side)+ "_UpArmTwist02_orientConstraint1",str(side)+ "_DownArmTwist02_orientConstraint1") cmds.parent (str(side)+ "_UpArmTwist03",str(side)+ "_UpArmTwist02") cmds.parent (str(side)+ "_DownArmTwist03",str(side)+ "_DownArmTwist02") FuckingSwitch("L") FuckingSwitch("R") cmds.group ("L_PV_Plane","ShoulderClusterHandle","ElbowClusterHandle","WristClusterHandle", n= "ExtrasAutoArms") cmds.setAttr ("ExtrasAutoArms.visibility", 0) cmds.duplicate ("L_PV_Plane", n="R_PV_Plane") cmds.setAttr ("R_PV_Plane.scaleX", -1) cmds.duplicate ("L_arm_2",n= "L_NoRot") cmds.duplicate ("R_arm_2",n= "R_NoRot") cmds.delete ("L_NoRot|L_arm_3") cmds.delete ("R_NoRot|R_arm_3") cmds.duplicate("L_arm_2", n= "L_TwistShoulder_JJ" ) cmds.parent ("L_TwistShoulder_JJ", world = True) cmds.rename ("L_TwistShoulder_JJ|L_arm_3","L_TwistElbow_JJ") cmds.rename ("L_TwistElbow_JJ|L_arm_4","L_TwistWrist_JJ") cmds.duplicate("R_arm_2", n= "R_TwistShoulder_JJ" ) cmds.parent ("R_TwistShoulder_JJ", world = True) cmds.rename ("R_TwistShoulder_JJ|R_arm_3","R_TwistElbow_JJ") cmds.rename ("R_TwistElbow_JJ|R_arm_4","R_TwistWrist_JJ") cmds.ikHandle (n= "L_UpTwist_IK", sj="L_UpArmTwist01", ee="L_UpArmTwist03", sol = "ikSplineSolver", ccv= 0, pcv = 0, c="L_UpArmTwist" ) cmds.ikHandle (n= "L_DownTwist_IK", sj="L_DownArmTwist01", ee="L_DownArmTwist03", sol = "ikSplineSolver", ccv= 0, pcv = 0, c="L_DownArmTwist" ) cmds.ikHandle (n= "R_UpTwist_IK", sj="R_UpArmTwist01", ee="R_UpArmTwist03", sol = "ikSplineSolver", ccv= 0, pcv = 0, c="R_UpArmTwist" ) cmds.ikHandle (n= "R_DownTwist_IK", sj="R_DownArmTwist01", ee="R_DownArmTwist03", sol = "ikSplineSolver", ccv= 0, pcv = 0, c="R_DownArmTwist" ) #Twist Connections Stuff cmds.rebuildCurve ("L_UpArmTwist", s = 2, d = 1) cmds.rebuildCurve ("L_DownArmTwist", s = 2, d = 1) cmds.rebuildCurve ("R_UpArmTwist", s = 2, d = 1) cmds.rebuildCurve ("R_DownArmTwist", s = 2, d = 1) cmds.skinCluster("L_TwistShoulder_JJ","L_TwistElbow_JJ", "L_UpArmTwist", tsb= True, bm=0, sm=0, nw=1 ) cmds.skinCluster("L_TwistElbow_JJ","L_TwistWrist_JJ", "L_DownArmTwist", tsb= True, bm=0, sm=0, nw=1 ) cmds.skinCluster("R_TwistShoulder_JJ","R_TwistElbow_JJ", "R_UpArmTwist", tsb= True, bm=0, sm=0, nw=1 ) cmds.skinCluster("R_TwistElbow_JJ","R_TwistWrist_JJ", "R_DownArmTwist", tsb= True, bm=0, sm=0, nw=1 ) cmds.parentConstraint ("L_arm_2","L_TwistShoulder_JJ", mo = True) cmds.parentConstraint ("L_arm_3","L_TwistElbow_JJ", mo = True) cmds.parentConstraint ("L_arm_4","L_TwistWrist_JJ", mo = True) cmds.parentConstraint ("R_arm_2","R_TwistShoulder_JJ", mo = True) cmds.parentConstraint ("R_arm_3","R_TwistElbow_JJ", mo = True) cmds.parentConstraint ("R_arm_4","R_TwistWrist_JJ", mo = True) #Advance Twist Controls cmds.setAttr ("L_UpTwist_IK.dTwistControlEnable", 1) cmds.setAttr ("L_UpTwist_IK.dWorldUpType", 4) cmds.setAttr ("L_UpTwist_IK.dForwardAxis", 0) cmds.setAttr ("L_UpTwist_IK.dWorldUpAxis", 1) cmds.setAttr ("R_UpTwist_IK.dTwistControlEnable", 1) cmds.setAttr ("R_UpTwist_IK.dWorldUpType", 4) cmds.setAttr ("R_UpTwist_IK.dForwardAxis", 0) cmds.setAttr ("R_UpTwist_IK.dWorldUpAxis", 1) cmds.setAttr ("L_DownTwist_IK.dTwistControlEnable", 1) cmds.setAttr ("L_DownTwist_IK.dWorldUpType", 4) cmds.setAttr ("L_DownTwist_IK.dForwardAxis", 0) cmds.setAttr ("L_DownTwist_IK.dWorldUpAxis", 1) cmds.setAttr ("R_DownTwist_IK.dTwistControlEnable", 1) cmds.setAttr ("R_DownTwist_IK.dWorldUpType", 4) cmds.setAttr ("R_DownTwist_IK.dForwardAxis", 0) cmds.setAttr ("R_DownTwist_IK.dWorldUpAxis", 1) cmds.connectAttr ("L_NoRot.xformMatrix", "L_UpTwist_IK.dWorldUpMatrix", f=True) cmds.connectAttr ("L_TwistElbow_JJ.xformMatrix", "L_UpTwist_IK.dWorldUpMatrixEnd", f=True ) cmds.connectAttr ("R_NoRot.xformMatrix", "R_UpTwist_IK.dWorldUpMatrix", f=True) cmds.connectAttr ("R_TwistElbow_JJ.xformMatrix", "R_UpTwist_IK.dWorldUpMatrixEnd", f=True ) cmds.connectAttr ("L_TwistElbow_JJ.xformMatrix", "L_DownTwist_IK.dWorldUpMatrix", f=True) cmds.connectAttr ("L_TwistWrist_JJ.xformMatrix", "L_DownTwist_IK.dWorldUpMatrixEnd", f=True ) cmds.connectAttr ("R_TwistElbow_JJ.xformMatrix", "R_DownTwist_IK.dWorldUpMatrix", f=True) cmds.connectAttr ("R_TwistWrist_JJ.xformMatrix", "R_DownTwist_IK.dWorldUpMatrixEnd", f=True ) cmds.setAttr ('L_UpArmTwist.inheritsTransform', 0) cmds.setAttr ('L_DownArmTwist.inheritsTransform', 0) cmds.setAttr ('R_UpArmTwist.inheritsTransform', 0) cmds.setAttr ('R_DownArmTwist.inheritsTransform', 0) cmds.select (clear = True) # Grouping and Organizing cmds.group ("L_armIK_GRP", "L_PV0_GRP", n="L_IKArm_GRP") cmds.group ("R_armIK_GRP", "R_PV_GRP", n="R_IKArm_GRP") cmds.group ("L_UpArmTwist", "L_DownArmTwist" , "L_UpTwist_IK", "L_DownTwist_IK","L_TwistShoulder_JJ","L_TwistElbow_JJ","L_TwistWrist_JJ","L_UpArmTwist01","L_DownArmTwist01", n = "L_TwistArm") cmds.group ("R_UpArmTwist", "R_DownArmTwist" , "R_UpTwist_IK", "R_DownTwist_IK","R_TwistShoulder_JJ","R_TwistElbow_JJ","R_TwistWrist_JJ","R_UpArmTwist01","R_DownArmTwist01", n = "R_TwistArm") cmds.group ("L_IKArm_GRP", "R_IKArm_GRP","L_clavicule_01_GRP","R_clavicule_01_GRP","L_arm_1","R_arm_1",n= "Connect this to the rest of the rig ARMS") cmds.group ("L_TwistArm", "R_TwistArm", "ExtrasAutoArms","Connect_this_to_the_rest_of_the_rig_ARMS", n="RdM_AutoARMS" ) #Lock and hide #FK cmds.select ('L_armFK_03_CC','L_armFK_02_CC','L_armFK_01_CC','R_armFK_03_CC','R_armFK_02_CC','R_armFK_01_CC') FK = cmds.ls(sl=True) for T in FK: cmds.setAttr(str(T)+'.translateX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.translateY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.translateZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.visibility',lock = True, keyable = False, channelBox = False) #IK, Clavicule cmds.select ('L_armIK_CC', 'R_armIK_CC','R_clavicule_01_CC ','L_clavicule_01_CC') IK = cmds.ls(sl=True) for T in IK: cmds.setAttr(str(T)+'.scaleX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.visibility',lock = True, keyable = False, channelBox = False) #Pole Vector cmds.select ('L_PV01', 'R_PV01') PV = cmds.ls(sl=True) for T in PV: cmds.setAttr(str(T)+'.rotateX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.rotateY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.rotateZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.visibility',lock = True, keyable = False, channelBox = False) # Borrar lo malo cmds.delete('L_UpArmTwist', 'L_DownArmTwist', 'L_UpTwist_IK', 'L_DownTwist_IK', 'R_UpArmTwist', 'R_DownArmTwist', 'R_UpTwist_IK', 'R_DownTwist_IK') cmds.delete('R_TwistShoulder_JJ_parentConstraint1', 'R_TwistElbow_JJ_parentConstraint1', 'R_TwistWrist_JJ_parentConstraint1', 'L_TwistWrist_JJ_parentConstraint1', 'L_TwistElbow_JJ_parentConstraint1', 'L_TwistShoulder_JJ_parentConstraint1') cmds.delete('L_TwistShoulder_JJ', 'R_TwistShoulder_JJ', 'L_UpArmTwist01', 'R_UpArmTwist01') # Acomodar todo del lado izquierdo cmds.parent('L_TwistWrist_JJ', 'L_TwistElbow_JJ') cmds.parent('L_TwistElbow_JJ', 'L_DownArmTwist02', 'L_arm_3') cmds.delete('L_DownArmTwist03', 'L_DownArmTwist01') cmds.makeIdentity('L_TwistElbow_JJ', apply=True, t=1, r=1) # IKSc cmds.select('L_TwistElbow_JJ', 'L_TwistWrist_JJ') cmds.ikHandle(sol='ikSCsolver', n='L_TwistIKSc') cmds.parent('L_TwistIKSc', 'L_arm_4') # Orient for Twist OrientTemp = cmds.orientConstraint('L_TwistElbow_JJ', 'L_arm_4', 'L_DownArmTwist02', mo=0) cmds.delete(OrientTemp) cmds.makeIdentity('L_DownArmTwist02', apply=True, t=1, r=1) # ConnectionEditor cmds.shadingNode('multiplyDivide', asUtility=1, n='L_TwistMult') cmds.connectAttr('L_TwistElbow_JJ.rotate.rotateX', 'L_TwistMult.input1.input1X') cmds.setAttr('L_TwistMult.input2X', 0.5) cmds.connectAttr('L_TwistMult.output.outputX', 'L_DownArmTwist02.rotate.rotateX') # Duplicar para R # Acomodar todo del lado izquierdo cmds.parent('R_TwistWrist_JJ', 'R_TwistElbow_JJ') cmds.parent('R_TwistElbow_JJ', 'R_DownArmTwist02', 'R_arm_3') cmds.delete('R_DownArmTwist03', 'R_DownArmTwist01') cmds.makeIdentity('R_TwistElbow_JJ', apply=True, t=1, r=1) # IKSc cmds.select('R_TwistElbow_JJ', 'R_TwistWrist_JJ') cmds.ikHandle(sol='ikSCsolver', n='R_TwistIKSc') cmds.parent('R_TwistIKSc', 'R_arm_4') # Orient for Twist OrientTemp = cmds.orientConstraint('R_TwistElbow_JJ', 'R_arm_4', 'R_DownArmTwist02', mo=0) cmds.delete(OrientTemp) cmds.makeIdentity('R_DownArmTwist02', apply=True, t=1, r=1) # ConnectionEditor cmds.shadingNode('multiplyDivide', asUtility=1, n='R_TwistMult') cmds.connectAttr('R_TwistElbow_JJ.rotate.rotateX', 'R_TwistMult.input1.input1X') cmds.setAttr('R_TwistMult.input2X', 0.5) cmds.connectAttr('R_TwistMult.output.outputX', 'R_DownArmTwist02.rotate.rotateX') cmds.select('L_DownArmTwist02', 'L_arm_1', 'R_DownArmTwist02', 'R_arm_1', 'R_arm_2', 'L_arm_2', 'L_arm_3', 'R_arm_3') cmds.sets(n='BindThisToArms') print 'DONE'
def IKFK(*args): for X in range(1, jointsNum + 1): cmds.setAttr("L_arm_" + str(X) + ".displayLocalAxis", 0) cmds.setAttr("R_arm_" + str(X) + ".displayLocalAxis", 0) cmds.duplicate("L_arm_2", rc=True) cmds.duplicate("L_arm_2", rc=True) cmds.rename("L_arm_5", "L_arm_01_IK") cmds.rename("L_arm_6", "L_arm_02_IK") cmds.rename("L_arm_7", "L_arm_03_IK") cmds.rename("L_arm_8", "L_arm_01_FK") cmds.rename("L_arm_9", "L_arm_02_FK") cmds.rename("L_arm_10", "L_arm_03_FK") if cmds.objExists('R_arm_1'): print 'Mirror already aplied' cmds.duplicate("R_arm_2", rc=True) cmds.duplicate("R_arm_2", rc=True) cmds.rename("R_arm_5", "R_arm_01_IK") cmds.rename("R_arm_6", "R_arm_02_IK") cmds.rename("R_arm_7", "R_arm_03_IK") cmds.rename("R_arm_8", "R_arm_01_FK") cmds.rename("R_arm_9", "R_arm_02_FK") cmds.rename("R_arm_10", "R_arm_03_FK") else: cmds.select("L_arm_1") cmds.mirrorJoint(mirrorYZ=True, mirrorBehavior=True, searchReplace=('L_', 'R_')) cmds.ikHandle(n="L_ArmIKrp", sj="L_arm_01_IK", ee="L_arm_03_IK") cmds.ikHandle(n="R_ArmIKrp", sj="R_arm_01_IK", ee="R_arm_03_IK") #Controladores ############################ GlobalMult = cmds.floatSliderGrp(RadioControlador, q=True, value=2) ############################ #Clavicule cmds.circle(r=3 * GlobalMult, nr=(1, 0, 0), n="L_clavicule_01_CC", ch=0) cmds.group("L_clavicule_01_CC", n="L_clavicule_01_GRP") cmds.parentConstraint("L_arm_1", "L_clavicule_01_GRP") cmds.delete("L_clavicule_01_GRP_parentConstraint1") cmds.makeIdentity("L_clavicule_01_CC", apply=True, t=True) cmds.setAttr("L_clavicule_01_CC" + "Shape.overrideEnabled", True) cmds.setAttr("L_clavicule_01_CC" + "Shape.overrideColor", 6) cmds.duplicate('L_clavicule_01_CC', n="R_clavicule_01_CC") cmds.group("R_clavicule_01_CC", n="R_clavicule_01_GRP") cmds.parentConstraint("R_arm_1", "R_clavicule_01_GRP") cmds.delete("R_clavicule_01_GRP_parentConstraint1") cmds.makeIdentity("R_clavicule_01_CC", apply=True, t=True) cmds.setAttr("R_clavicule_01_CC" + "Shape.overrideEnabled", True) cmds.setAttr("R_clavicule_01_CC" + "Shape.overrideColor", 13) #cmds.orientConstraint ('L_clavicule_01_CC','L_arm_1') #cmds.orientConstraint ('R_clavicule_01_CC','R_arm_1') #FK for P in range(1, jointsNum): cmds.circle(r=2 * GlobalMult, nr=(1, 0, 0), n="L_armFK_0" + str(P) + "_CC", ch=0) cmds.group("L_armFK_0" + str(P) + "_CC", n="L_armFK_0" + str(P) + "_GRP") cmds.parentConstraint("L_arm_0" + str(P) + "_FK", "L_armFK_0" + str(P) + "_GRP") cmds.delete("L_armFK_0" + str(P) + "_GRP_parentConstraint1") cmds.makeIdentity("L_armFK_0" + str(P) + "_CC", apply=True, t=True) cmds.setAttr("L_armFK_0" + str(P) + "_CCShape.overrideEnabled", True) cmds.setAttr("L_armFK_0" + str(P) + "_CCShape.overrideColor", 6) cmds.circle(r=2 * GlobalMult, nr=(1, 0, 0), n="R_armFK_0" + str(P) + "_CC", ch=0) cmds.group("R_armFK_0" + str(P) + "_CC", n="R_armFK_0" + str(P) + "_GRP") cmds.parentConstraint("R_arm_0" + str(P) + "_FK", "R_armFK_0" + str(P) + "_GRP") cmds.delete("R_armFK_0" + str(P) + "_GRP_parentConstraint1") cmds.makeIdentity("R_armFK_0" + str(P) + "_CC", apply=True, t=True) cmds.setAttr("R_armFK_0" + str(P) + "_CCShape.overrideEnabled", True) cmds.setAttr("R_armFK_0" + str(P) + "_CCShape.overrideColor", 13) cmds.parent("L_armFK_01_GRP", "L_clavicule_01_CC") cmds.parent("L_armFK_02_GRP", "L_armFK_01_CC") cmds.parent("L_armFK_03_GRP", "L_armFK_02_CC") cmds.parent("R_armFK_01_GRP", "R_clavicule_01_CC") cmds.parent("R_armFK_02_GRP", "R_armFK_01_CC") cmds.parent("R_armFK_03_GRP", "R_armFK_02_CC") cmds.parentConstraint("L_clavicule_01_CC", "L_arm_1") cmds.parentConstraint("L_armFK_01_CC", "L_arm_01_FK") cmds.parentConstraint("L_armFK_02_CC", "L_arm_02_FK") cmds.parentConstraint("L_armFK_03_CC", "L_arm_03_FK") cmds.parentConstraint("R_clavicule_01_CC", "R_arm_1") cmds.parentConstraint("R_armFK_01_CC", "R_arm_01_FK") cmds.parentConstraint("R_armFK_02_CC", "R_arm_02_FK") cmds.parentConstraint("R_armFK_03_CC", "R_arm_03_FK") #IK cmds.curve(n="L_armIK_CC", d=1, p=[(1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (-1, -1, 1), (-1, 1, 1), (1, 1, 1), (1, -1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (1, 1, -1), (1, -1, -1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1)], k=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) cmds.group("L_armIK_CC", n="L_armIK_GRP") cmds.pointConstraint("L_arm_03_IK", "L_armIK_GRP") cmds.delete("L_armIK_GRP_pointConstraint1") cmds.orientConstraint("L_arm_02_IK", "L_armIK_GRP") cmds.delete("L_armIK_GRP_orientConstraint1") cmds.curve(n="R_armIK_CC", d=1, p=[(1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (-1, -1, 1), (-1, 1, 1), (1, 1, 1), (1, -1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (1, 1, -1), (1, -1, -1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1)], k=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) cmds.group("R_armIK_CC", n="R_armIK_GRP") cmds.pointConstraint("R_arm_03_IK", "R_armIK_GRP") cmds.delete("R_armIK_GRP_pointConstraint1") cmds.orientConstraint("R_arm_02_IK", "R_armIK_GRP") cmds.delete("R_armIK_GRP_orientConstraint1") cmds.parent("L_ArmIKrp", "L_armIK_CC") cmds.parent("R_ArmIKrp", "R_armIK_CC") cmds.orientConstraint("L_armIK_CC", "L_arm_03_IK", mo=True) cmds.orientConstraint("R_armIK_CC", "R_arm_03_IK", mo=True) cmds.scale(GlobalMult, GlobalMult, GlobalMult, 'L_armIK_GRP', r=True) cmds.scale(GlobalMult, GlobalMult, GlobalMult, 'R_armIK_GRP', r=True) cmds.setAttr("L_armIK_CC.overrideEnabled", 1) cmds.setAttr("R_armIK_CC.overrideEnabled", 1) cmds.setAttr("L_armIK_CC.overrideColor", 6) cmds.setAttr("R_armIK_CC.overrideColor", 13) #Pole Vector cmds.polyPlane(n="L_PV_Plane", sh=1, sw=1) cmds.delete("L_PV_Plane.vtx[3]") cmds.cluster("L_PV_Plane.vtx[0]", n="ShoulderCluster") cmds.cluster("L_PV_Plane.vtx[1]", n="ElbowCluster") cmds.cluster("L_PV_Plane.vtx[2]", n="WristCluster") cmds.pointConstraint("L_arm_2", "ShoulderClusterHandle") cmds.pointConstraint("L_arm_3", "ElbowClusterHandle") cmds.pointConstraint("L_arm_4", "WristClusterHandle") P01X = cmds.getAttr("L_arm_1.translateX") P01Y = cmds.getAttr("L_arm_1.translateY") P01Z = cmds.getAttr("L_arm_1.translateZ") P02X = cmds.getAttr("L_arm_2.translateX") + P01X P02Y = cmds.getAttr("L_arm_2.translateY") + P01Y P02Z = cmds.getAttr("L_arm_2.translateZ") + P01Z P03X = cmds.getAttr("L_arm_3.translateX") + P02X P03Y = cmds.getAttr("L_arm_3.translateY") + P02Y P03Z = cmds.getAttr("L_arm_3.translateZ") + P02Z P04X = cmds.getAttr("L_arm_4.translateX") + P03X P04Y = cmds.getAttr("L_arm_4.translateY") + P03Y P04Z = cmds.getAttr("L_arm_4.translateZ") + P03Z cmds.moveVertexAlongDirection("L_PV_Plane.vtx[1]", u=P02X + (P02X / 2)) PVposition = cmds.pointPosition("L_PV_Plane.vtx[1]") cmds.circle(n="L_PV01", nr=(0, 0, 1), r=GlobalMult) cmds.circle(n="L_PV02", nr=(0, 1, 0), r=GlobalMult) cmds.circle(n="L_PV03", nr=(1, 0, 0), r=GlobalMult) cmds.parent("L_PV02Shape", "L_PV01", r=True, s=True) cmds.parent("L_PV03Shape", "L_PV01", r=True, s=True) cmds.delete("L_PV02", "L_PV03") cmds.select("L_PV01") cmds.group(n="L_PV01_GRP", r=True) cmds.xform(t=PVposition) cmds.duplicate("L_PV01_GRP", n="R_PV_GRP") cmds.rename("R_PV_GRP|L_PV01", "R_PV01") cmds.rename("L_PV01_GRP", "L_PV0_GRP") cmds.move(0, 0, 0, ".scalePivot", ".rotatePivot", absolute=True) cmds.setAttr("R_PV_GRP.scaleX", -1) cmds.xform('R_PV_GRP', cp=True) cmds.select("L_PV01", "L_ArmIKrp") cmds.PoleVectorConstraint() cmds.select("R_PV01", "R_ArmIKrp") cmds.PoleVectorConstraint() cmds.setAttr("R_PV01Shape.overrideEnabled", True) cmds.setAttr("R_PV01Shape.overrideColor", 13) cmds.setAttr("R_PV02Shape1.overrideEnabled", True) cmds.setAttr("R_PV02Shape1.overrideColor", 13) cmds.setAttr("R_PV03Shape1.overrideEnabled", True) cmds.setAttr("R_PV03Shape1.overrideColor", 13) cmds.setAttr("L_PV01Shape.overrideEnabled", True) cmds.setAttr("L_PV01Shape.overrideColor", 6) cmds.setAttr("L_PV02Shape.overrideEnabled", True) cmds.setAttr("L_PV02Shape.overrideColor", 6) cmds.setAttr("L_PV03Shape.overrideEnabled", True) cmds.setAttr("L_PV03Shape.overrideColor", 6) #SwitchIKFK if cmds.objExists("IK_FK_CC"): print "CurveControl IKFK Exists" else: if cmds.objExists('makeTextCurves1'): cmds.rename('makeTextCurves1', 'makeTextCurves1LOL') Texto = 'IK-FK' Color = 16 Text = cmds.textCurves(n=Texto, t=Texto, o=True) Lista = cmds.listRelatives(Text, ad=True) Shape = Lista[1] cmds.delete('makeTextCurves1') for Curva in Lista: if cmds.objectType(str(Curva), isType='nurbsCurve'): curvaPapa = cmds.listRelatives(Curva, p=True) curvaAbuelo = cmds.listRelatives(curvaPapa, p=True) DobleCurva = cmds.listRelatives(curvaAbuelo) if len(DobleCurva) == 2: LetrasDobles.append(Curva) else: if not Shape == curvaPapa[0]: cmds.makeIdentity(curvaAbuelo, a=True, t=True, r=True) cmds.parent(Curva, Shape, r=True, s=True) #Colores cmds.setAttr(Curva + '.overrideEnabled', 1) cmds.setAttr(Curva + '.overrideColor', Color) cmds.parent(Shape, w=True) cmds.rename(Shape, 'IK_FK_CC') cmds.setAttr("IK_FK_CC.overrideEnabled", 1) cmds.setAttr("IK_FK_CC.overrideColor", 16) cmds.setAttr('IK_FK_CC.rotateX', -90) cmds.xform(cp=True) cmds.setAttr('IK_FK_CC.scaleX', GlobalMult) cmds.setAttr('IK_FK_CC.scaleY', GlobalMult) cmds.setAttr('IK_FK_CC.scaleZ', GlobalMult) cmds.makeIdentity(a=True, t=True, r=True, s=True) if cmds.objExists("IK_FK_CC.LeftArmIKFK"): print 'existe Attr' else: cmds.select("IK_FK_CC") cmds.addAttr(ln="LeftArmIKFK", min=0, max=1) cmds.setAttr("IK_FK_CC.LeftArmIKFK", keyable=True) if cmds.objExists("IK_FK_CC.RightArmIKFK"): print 'existe Attr' else: cmds.select("IK_FK_CC") cmds.addAttr(ln="RightArmIKFK", min=0, max=1) cmds.setAttr("IK_FK_CC.RightArmIKFK", keyable=True) cmds.expression( n="L_Arms_Switch", s="L_arm_2.rotateX = (L_arm_01_FK.rotateX*IK_FK_CC.LeftArmIKFK)+(L_arm_01_IK.rotateX*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_2.rotateY = (L_arm_01_FK.rotateY*IK_FK_CC.LeftArmIKFK)+(L_arm_01_IK.rotateY*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_2.rotateZ = (L_arm_01_FK.rotateZ*IK_FK_CC.LeftArmIKFK)+(L_arm_01_IK.rotateZ*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_3.rotateX = (L_arm_02_FK.rotateX*IK_FK_CC.LeftArmIKFK)+(L_arm_02_IK.rotateX*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_3.rotateY = (L_arm_02_FK.rotateY*IK_FK_CC.LeftArmIKFK)+(L_arm_02_IK.rotateY*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_3.rotateZ = (L_arm_02_FK.rotateZ*IK_FK_CC.LeftArmIKFK)+(L_arm_02_IK.rotateZ*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_4.rotateX = (L_arm_03_FK.rotateX*IK_FK_CC.LeftArmIKFK)+(L_arm_03_IK.rotateX*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_4.rotateY = (L_arm_03_FK.rotateY*IK_FK_CC.LeftArmIKFK)+(L_arm_03_IK.rotateY*(1-IK_FK_CC.LeftArmIKFK));\nL_arm_4.rotateZ = (L_arm_03_FK.rotateZ*IK_FK_CC.LeftArmIKFK)+(L_arm_03_IK.rotateZ*(1-IK_FK_CC.LeftArmIKFK));\nL_armFK_03_CC.visibility = IK_FK_CC.LeftArmIKFK;\nL_armFK_02_CC.visibility = IK_FK_CC.LeftArmIKFK;\nL_armFK_01_CC.visibility = IK_FK_CC.LeftArmIKFK;\nL_armIK_CC.visibility = (1-IK_FK_CC.LeftArmIKFK);" ) cmds.expression( n="R_Arms_Switch", s="R_arm_2.rotateX = (R_arm_01_FK.rotateX*IK_FK_CC.RightArmIKFK)+(R_arm_01_IK.rotateX*(1-IK_FK_CC.RightArmIKFK));\nR_arm_2.rotateY = (R_arm_01_FK.rotateY*IK_FK_CC.RightArmIKFK)+(R_arm_01_IK.rotateY*(1-IK_FK_CC.RightArmIKFK));\nR_arm_2.rotateZ = (R_arm_01_FK.rotateZ*IK_FK_CC.RightArmIKFK)+(R_arm_01_IK.rotateZ*(1-IK_FK_CC.RightArmIKFK));\nR_arm_3.rotateX = (R_arm_02_FK.rotateX*IK_FK_CC.RightArmIKFK)+(R_arm_02_IK.rotateX*(1-IK_FK_CC.RightArmIKFK));\nR_arm_3.rotateY = (R_arm_02_FK.rotateY*IK_FK_CC.RightArmIKFK)+(R_arm_02_IK.rotateY*(1-IK_FK_CC.RightArmIKFK));\nR_arm_3.rotateZ = (R_arm_02_FK.rotateZ*IK_FK_CC.RightArmIKFK)+(R_arm_02_IK.rotateZ*(1-IK_FK_CC.RightArmIKFK));\nR_arm_4.rotateX = (R_arm_03_FK.rotateX*IK_FK_CC.RightArmIKFK)+(R_arm_03_IK.rotateX*(1-IK_FK_CC.RightArmIKFK));\nR_arm_4.rotateY = (R_arm_03_FK.rotateY*IK_FK_CC.RightArmIKFK)+(R_arm_03_IK.rotateY*(1-IK_FK_CC.RightArmIKFK));\nR_arm_4.rotateZ = (R_arm_03_FK.rotateZ*IK_FK_CC.RightArmIKFK)+(R_arm_03_IK.rotateZ*(1-IK_FK_CC.RightArmIKFK));\nR_armFK_03_CC.visibility = IK_FK_CC.RightArmIKFK;\nR_armFK_02_CC.visibility = IK_FK_CC.RightArmIKFK;\nR_armFK_01_CC.visibility = IK_FK_CC.RightArmIKFK;\nR_armIK_CC.visibility = (1-IK_FK_CC.RightArmIKFK);" ) cmds.setAttr("IK_FK_CC.overrideEnabled", 1) cmds.setAttr("IK_FK_CC.overrideColor", 18) #Organize the mess # Grouping and Organizing cmds.group("L_armIK_GRP", "L_PV0_GRP", n="L_IKArm_GRP") cmds.group("R_armIK_GRP", "R_PV_GRP", n="R_IKArm_GRP") cmds.group("L_IKArm_GRP", "R_IKArm_GRP", "L_clavicule_01_GRP", "R_clavicule_01_GRP", "L_arm_1", "R_arm_1", n="Connect this to the rest of the rig ARMS") cmds.group("Connect_this_to_the_rest_of_the_rig_ARMS", n="RdM_AutoARMS") cmds.delete('IK_FKShape', 'L_PV_Plane', 'ShoulderClusterHandle', 'ElbowClusterHandle', 'WristClusterHandle') cmds.select('IK_FK_CC') cmds.move(-1.195, 0, 10) #Lock and hide #FK cmds.select('L_armFK_03_CC', 'L_armFK_02_CC', 'L_armFK_01_CC', 'R_armFK_03_CC', 'R_armFK_02_CC', 'R_armFK_01_CC') FK = cmds.ls(sl=True) for T in FK: cmds.setAttr(str(T) + '.translateX', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.translateY', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.translateZ', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.scaleX', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.scaleY', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.scaleZ', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.visibility', lock=True, keyable=False, channelBox=False) #IK, Clavicule cmds.select('L_armIK_CC', 'R_armIK_CC', 'R_clavicule_01_CC ', 'L_clavicule_01_CC') IK = cmds.ls(sl=True) for T in IK: cmds.setAttr(str(T) + '.scaleX', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.scaleY', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.scaleZ', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.visibility', lock=True, keyable=False, channelBox=False) #Pole Vector cmds.select('L_PV01', 'R_PV01') PV = cmds.ls(sl=True) for T in PV: cmds.setAttr(str(T) + '.rotateX', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.rotateY', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.rotateZ', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.scaleX', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.scaleY', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.scaleZ', lock=True, keyable=False, channelBox=False) cmds.setAttr(str(T) + '.visibility', lock=True, keyable=False, channelBox=False) print 'DONE' Plane = cmds.nurbsPlane(ax=(0, 1, 0), w=2, lr=0.5, d=3, u=16, v=1, n='L_UpperPlane') cmds.move(-1, 0, 0, Plane[0] + ".scalePivot", Plane[0] + ".rotatePivot", absolute=True) Parent = cmds.pointConstraint('L_arm_2', Plane, mo=0) cmds.delete(Parent) cmds.setAttr("L_UpperPlane.rotateX", 90)