def cvBaseGuide(ctrlName, r=1): """Create a control to be used as a Base Guide control. Returns the main control (circle) and the radius control in a list. """ # get radius by checking linear unit r = dpCheckLinearUnit(r) # create a simple circle curve: circle = cmds.circle(n=ctrlName, ch=True, o=True, nr=(0, 0, 1), d=3, s=8, radius=r)[0] radiusCtrl = cmds.circle(n=ctrlName+"_RadiusCtrl", ch=True, o=True, nr=(0, 1, 0), d=3, s=8, radius=(r/4.0))[0] # rename curveShape: renameShape([circle, radiusCtrl]) # configure system of limits and radius: cmds.setAttr(radiusCtrl+".translateX", r) cmds.parent(radiusCtrl, circle, relative=True) cmds.transformLimits(radiusCtrl, tx=(0.01, 1), etx=(True, False)) setLockHide([radiusCtrl], ['ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) # find makeNurbCircle history of the circles: historyList = findHistory([circle, radiusCtrl], 'makeNurbCircle') circleHistory = historyList[0] radiusCtrlHistory = historyList[1] # rename and make a connection for circle: circleHistory = cmds.rename(circleHistory, circle+"_makeNurbCircle") cmds.connectAttr(radiusCtrl+".tx", circleHistory+".radius", force=True) radiusCtrlHistory = cmds.rename(radiusCtrlHistory, radiusCtrl+"_makeNurbCircle") # create a mutiplyDivide in order to automatisation the radius of the radiusCtrl: radiusCtrlMD = cmds.createNode('multiplyDivide', name=radiusCtrl+'_MD') cmds.connectAttr(radiusCtrl+'.translateX', radiusCtrlMD+'.input1X', force=True) cmds.setAttr(radiusCtrlMD+'.input2X', 0.15) cmds.connectAttr(radiusCtrlMD+".outputX", radiusCtrlHistory+".radius", force=True) # colorize curveShapes: colorShape([circle, radiusCtrl], 'yellow') cmds.select(clear=True) return [circle, radiusCtrl]
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool') cmds.setAttr(self.moduleGrp+".flip", 0) cmds.addAttr(self.moduleGrp, longName="indirectSkin", attributeType='bool') cmds.setAttr(self.moduleGrp+".indirectSkin", 0) cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3) self.connectShapeSize(shapeSizeCH) self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001) cmds.setAttr(self.jGuide1+".template", 1) cmds.parent(self.jGuide1, self.moduleGrp, relative=True) self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint+".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd+".template", 1) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) cmds.parent(self.jGuideEnd, self.jGuide1) cmds.parentConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ParentConstraint") cmds.parentConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ParentConstraint") cmds.scaleConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ScaleConstraint") cmds.scaleConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ScaleConstraint")
def sliderA(prefix): cmds.undoInfo(openChunk=True) #create nodes grp=cmds.group(empty=True,n=(prefix+'_grp')) cnt=cmds.circle(r=0.1,ch=False,n=(prefix+'_cnt')) shp=cmds.circle(o=True,r=1,ch=False,d=1,s=4,n=(prefix+'_shp')) #setup shp cmds.move(-1,0,0,'%s.cv[0]' % shp[0],r=True,os=True) cmds.move(-1,0,0,'%s.cv[4]' % shp[0],r=True,os=True) cmds.move(0,-1,0,'%s.cv[1]' % shp[0],r=True,os=True) cmds.move(1,0,0,'%s.cv[2]' % shp[0],r=True,os=True) cmds.move(0,1,0,'%s.cv[3]' % shp[0],r=True,os=True) cmds.parent(shp,grp) cmds.setAttr('%s.overrideEnabled' % shp[0],1) cmds.setAttr('%s.overrideDisplayType' % shp[0],2) #setup cnt cmds.parent(cnt,shp) cmds.setAttr('%s.overrideEnabled' % cnt[0],1) cmds.transformLimits(cnt,tx=(-1,1),etx=(1,1)) cmds.transformLimits(cnt,ty=(-1,1),ety=(1,1)) setupAttrs(prefix,cnt[0]) return grp cmds.undoInfo(closeChunk=True)
def createBrowCtl(self, jntNum, orderJnts): """ create extra controllor for the panel """ ctlP = "browDetailCtrl0" kids = cmds.listRelatives (ctlP, ad=True, type ='transform') if kids: cmds.delete (kids) attTemp = ['scaleX','scaleY','scaleZ', 'rotateX','rotateY', 'tz', 'visibility' ] index = 0 for jnt in orderJnts: detailCtl = cmds.circle ( n = 'browDetail' + str(index+1).zfill(2), ch=False, o =True, nr = ( 0, 0, 1), r = 0.2 ) detailPlane = cmds.nurbsPlane ( ax = ( 0, 0, 1 ), w = 0.1, lengthRatio = 10, degree = 3, ch=False, n = 'browDetail'+ str(index+1).zfill(2) + 'P' ) increment = 2.0/(jntNum-1) cmds.parent (detailCtl[0], detailPlane[0], relative=True ) cmds.parent (detailPlane[0], ctlP, relative=True ) cmds.setAttr (detailPlane[0] + '.tx', -2 + increment*index*2 ) cmds.xform ( detailCtl[0], r =True, s = (0.2, 0.2, 0.2)) cmds.setAttr (detailCtl[0] +".overrideEnabled", 1) cmds.setAttr (detailCtl[0] +"Shape.overrideEnabled", 1) cmds.setAttr( detailCtl[0]+"Shape.overrideColor", 20) cmds.transformLimits ( detailCtl[0] , tx = ( -.4, .4), etx=( True, True) ) cmds.transformLimits ( detailCtl[0], ty = ( -.8, .8), ety=( True, True) ) for att in attTemp: cmds.setAttr (detailCtl[0] +"."+ att, lock = True, keyable = False, channelBox =False) index = index + 1
def setLimitsOnAttrs(limitsTbl, objs): for eachObj in objs: for attr, limits in limitsTbl.items(): kw={} kw['e%s'%attr] = (1, 1) kw[attr] = limits mc.transformLimits(eachObj, **kw)
def rigSide(self, side ): inverseAim = False inverseUp = False globalMult = 1 if side.find( 'R' ) != -1: inverseAim = True inverseUp = True globalMult = -1 shoulder, elbow, wrist, poleV = self.armInitCtlData.getSortList( side ) upperArm, lowerArm = self.armInitCtlAdd.getSortList( side ) aimObjectOptions = { 'axis':0, 'upAxis':2, 'inverseAim':inverseAim, 'inverseUp':inverseUp, 'upType':'object', 'upObject':poleV, 'replaceTarget':'InitCTL', 'replace':'InitCtl' } aimObject, wristPoseMltDcmp = rigbase.makeAimObject( wrist, shoulder, **aimObjectOptions ) aimObject = cmds.rename( aimObject, aimObject.replace( 'AimObj', 'AimGrp' ) ) rigbase.betweenRigInAimObject( elbow, aimObject, dcmp = wristPoseMltDcmp, replaceTarget='InitCTL', replace='InitCtl', globalMult = globalMult ) rigbase.AttrEdit( elbow ).lockAttrs( 'ty' ) aimObjectElbow = rigbase.makeAimObject( wrist, elbow, **aimObjectOptions )[0] aimObjectShoulder = rigbase.makeAimObject( elbow, shoulder, **aimObjectOptions )[0] cmds.parent( upperArm, aimObjectShoulder ) cmds.parent( lowerArm, aimObjectElbow ) upperArmGrp = rigbase.addParent( upperArm ) lowerArmGrp = rigbase.addParent( lowerArm ) upperMtxDcmp = rigbase.getChildMtxDcmp( elbow, aimObjectShoulder ) lowerMtxDcmp = rigbase.getChildMtxDcmp( wrist, aimObjectElbow ) upperMultMiddle = cmds.createNode( 'multiplyDivide', n=upperArm.replace( 'InitCTL', 'InitCtlMiddleMult' ) ) lowerMultMiddle = cmds.createNode( 'multiplyDivide', n=lowerArm.replace( 'InitCTL', 'InitCtlMiddleMult' ) ) cmds.connectAttr( upperMtxDcmp+'.ot', upperMultMiddle+'.input1' ) cmds.connectAttr( lowerMtxDcmp+'.ot', lowerMultMiddle+'.input1' ) cmds.setAttr( upperMultMiddle+'.input2', .5,.5,.5 ) cmds.setAttr( lowerMultMiddle+'.input2', .5,.5,.5 ) cmds.connectAttr( upperMultMiddle+'.output', upperArmGrp+'.t' ) cmds.connectAttr( lowerMultMiddle+'.output', lowerArmGrp+'.t' ) cmds.setAttr( upperArmGrp+'.r', 0,0,0 ) cmds.setAttr( lowerArmGrp+'.r', 0,0,0 ) if side.find( 'L' ) != -1: self.outputTransformL = [ aimObjectShoulder, aimObjectElbow, wrist, poleV ] self.outputAddTrL = [ upperArm, lowerArm ] cmds.transformLimits( elbow, tz= [-1,0.01], etz=[False, True] ) else: self.outputTransformR = [ aimObjectShoulder, aimObjectElbow, wrist, poleV ] self.outputAddTrR = [ upperArm, lowerArm ] cmds.transformLimits( elbow, tz= [0.01,1], etz=[True, False] )
def rigLegPart(self, side ): inverseAim = False inverseUp = True globalMult = 1 if side.find( 'R' ) != -1: inverseAim= True inverseUp = False globalMult = -1 hip, knee, ankle, poleV = self.legInitCtlData.getSortList( side )[:4] upperLeg, lowerLeg = self.legInitCtlAdd.getSortList( side ) aimObjectOptions = { 'axis':0, 'upAxis':2, 'inverseAim':inverseAim, 'inverseUp':inverseUp, 'upType':'object', 'upObject':poleV, 'replaceTarget':'InitCTL', 'replace':'InitCtl' } aimObject, anklePoseMltDcmp = rigbase.makeAimObject( ankle, hip, **aimObjectOptions ) aimObject = cmds.rename( aimObject, aimObject.replace( 'AimObj', 'AimGrp' ) ) rigbase.betweenRigInAimObject( knee, aimObject, dcmp = anklePoseMltDcmp, replaceTarget='InitCTL', replace='InitCtl', globalMult = globalMult ) rigbase.AttrEdit( knee ).lockAttrs( 'ty' ) aimObjectKnee = rigbase.makeAimObject( ankle, knee, **aimObjectOptions )[0] aimObjectHip = rigbase.makeAimObject( knee, hip, **aimObjectOptions )[0] cmds.parent( upperLeg, aimObjectHip ) cmds.parent( lowerLeg, aimObjectKnee ) upperLegGrp = rigbase.addParent( upperLeg ) lowerLegGrp = rigbase.addParent( lowerLeg ) upperMtxDcmp = rigbase.getChildMtxDcmp( knee, aimObjectHip ) lowerMtxDcmp = rigbase.getChildMtxDcmp( ankle, aimObjectKnee ) upperMultMiddle = cmds.createNode( 'multiplyDivide', n=upperLeg.replace( 'InitCTL', 'InitCtlMiddleMult' ) ) lowerMultMiddle = cmds.createNode( 'multiplyDivide', n=lowerLeg.replace( 'InitCTL', 'InitCtlMiddleMult' ) ) cmds.connectAttr( upperMtxDcmp+'.ot', upperMultMiddle+'.input1' ) cmds.connectAttr( lowerMtxDcmp+'.ot', lowerMultMiddle+'.input1' ) cmds.setAttr( upperMultMiddle+'.input2', .5,.5,.5 ) cmds.setAttr( lowerMultMiddle+'.input2', .5,.5,.5 ) cmds.connectAttr( upperMultMiddle+'.output', upperLegGrp+'.t' ) cmds.connectAttr( lowerMultMiddle+'.output', lowerLegGrp+'.t' ) cmds.setAttr( upperLegGrp+'.r', 0,0,0 ) cmds.setAttr( lowerLegGrp+'.r', 0,0,0 ) if side.find( 'L' ) != -1: self.outputTransformL = [ aimObjectHip, aimObjectKnee, ankle, poleV ] self.outputAddTrL = [ upperLeg, lowerLeg ] cmds.transformLimits( knee, tz= [0.01,1], etz=[True, False] ) else: self.outputTransformR = [ aimObjectHip, aimObjectKnee, ankle, poleV ] self.outputAddTrR = [ upperLeg, lowerLeg ] cmds.transformLimits( knee, tz= [-1,0.01], etz=[False, True] )
def createDetailCtl(self, updn, i): """ draw detail control """ detailCtlP = cmds.group(em =True, n = updn + 'LipDetailP'+ str(i)) detailCtl = cmds.circle(n = updn + 'LipDetail' + str(i), ch=False, o =True, nr =(0, 0, 1), r = 0.05 ) cmds.parent(detailCtl[0], detailCtlP) cmds.setAttr(detailCtl[0]+"Shape.overrideEnabled", 1) cmds.setAttr(detailCtl[0]+"Shape.overrideColor", 20) cmds.setAttr(detailCtl[0]+'.translate', 0,0,0) cmds.transformLimits(detailCtl[0], tx =(-.5, .5), etx=(True, True)) cmds.transformLimits(detailCtl[0], ty =(-.5, .5), ety=(True, True)) attTemp = ['scaleX','scaleY','scaleZ', 'rotateX','rotateY','rotateZ', 'tz', 'visibility' ] for y in attTemp: cmds.setAttr(detailCtl[0] +"."+ y, lock = True, keyable = False, channelBox =False)
def createNodeUntwist(node, twistNodeName, boneAxis=1): ''' createNodeUnTwist('joint1', 'joint1_untwist') ''' # Set Bone Vector boneVec = [0,0,0] boneVec[boneAxis] = 1; # Create untwist joint if not MC.objExists(twistNodeName): unTwistJnt = MC.duplicate(node)[0] unTwistJnt = MC.rename(unTwistJnt, twistNodeName) if MC.attributeQuery('radius', node=twistNodeName, exists=True): MC.setAttr('%s.radius' % twistNodeName, 2) MC.delete(MC.listRelatives(unTwistJnt, f=True, children=True)) else: raise Exception,'%s node exists, please specify a unique untwist node name' % twistNodeName # Remove any transform limits on the twist joint MC.transformLimits(twistNodeName, remove=True) # Set joint's rotateOrder to xyz because the angleBetween node only outputs in xyz order MC.setAttr('%s.rotateOrder' % twistNodeName, 0) # joint orient is included in matrix, so we need another xform to break it out rotMat = MC.createNode('transform', name='%s_xf' % twistNodeName, parent=twistNodeName) for attr in ['rotateX','rotateY','rotateZ', 'rotateOrder']: MC.connectAttr('%s.%s' % (node, attr), '%s.%s' % (rotMat, attr)) rotPt = MC.createNode('pointMatrixMult', name='%s_pmm' % twistNodeName) MC.connectAttr('%s.matrix' % rotMat, '%s.inMatrix' % rotPt) MC.setAttr('%s.inPoint' % rotPt, boneVec[0], boneVec[1], boneVec[2]) MC.setAttr('%s.vectorMultiply' % rotPt, True) calcRot = MC.createNode('angleBetween', name='%s_angbt' % rotPt) MC.setAttr('%s.vector1' % calcRot, boneVec[0], boneVec[1], boneVec[2]) MC.connectAttr('%s.output' % rotPt, '%s.vector2' % calcRot) # Get euler rotations and plug back into our untwist node for attr in ['X','Y','Z']: MC.connectAttr('%s.euler%s' % (calcRot, attr), '%s.rotate%s' % (twistNodeName, attr) ) MC.connectAttr('%s.scale%s' % (node, attr), '%s.scale%s' % (twistNodeName, attr) ) return twistNodeName
def ConnectControlToBlendshape(controller, blendAttr, clampValue, multiplyer): cmds.transformLimits(controller.split(".")[0], tx=(-1,1), etx=(True,True)) clampNode = cmds.createNode("clamp", n=blendAttr.replace(".","_")+"_clm") if (clampValue>0): cmds.setAttr( clampNode+".maxR", clampValue ); else: cmds.setAttr( clampNode+".minR", clampValue ); multNode = cmds.createNode("multiplyDivide", n=blendAttr.replace(".","_")+"_mdn") cmds.setAttr( multNode+".input2X", multiplyer ); cmds.connectAttr(controller, clampNode+".inputR" ) cmds.connectAttr(clampNode+".outputR", multNode+".input1X" ) cmds.connectAttr(multNode+".outputX", blendAttr )
def connectIrisPupil(): #连接 Iris Pupil连个属性并删除形状节点 使用方法选择两个眼睛控制器 然后执行命令 sls = mc.ls(sl=True) size = len(sls) if size==0: print "No ctrl selected!" return for idx,tCtl in enumerate(sls): lr = "L" if re.search("L$",tCtl)!=None else "R" sCtl = lr+"_eyeBall_ctrl" sAtrs = ["iris","pupil"] tAtrs = ["IrisControl","PupilControl"] for n,atr in enumerate(sAtrs): sAtr = sCtl+"."+atr tAtr = tCtl+"."+tAtrs[n] sValue = mc.getAttr( sAtr ) tValue = mc.getAttr( tAtr ) pmaNode = mc.createNode("plusMinusAverage",name=tCtl+atr+"_pma") mc.connectAttr(sAtr,pmaNode+".input1D[0]") mc.setAttr(".input1D[1]",tValue-sValue) mc.connectAttr(".output1D",tAtr) sAtrs = ["sx","sy"] tAtrs = ["iris_scalX","iris_scalY"] for n,atr in enumerate(sAtrs): sAtr = sCtl+"."+atr tAtr = tCtl+"."+tAtrs[n] if mc.objExists(tAtr): attributesCls.setDrivenKey(tAtr,dv=[1,0],v=[0,-10],cd=sAtr,itt="linear",ott="linear",ift=["constant","constant"]) mc.transformLimits(sCtl,sx=[-1,1],esx=[0,1]) mc.transformLimits(sCtl,sy=[-1,1],esy=[0,1]) #Delete shapes sps = mc.listRelatives(tCtl,s=True) if sps!=None and sps!=[]: for shp in sps: mc.setAttr("%s.intermediateObject"%shp,1) #mc.delete( sps ) eyeballJnt = lr+"_eyeBall_jnt" mc.delete( mc.pointConstraint(eyeballJnt,tCtl) ) #mc.parent(tCtl,eyeballJnt) #import rig_ch.facialSystem.replaceEyeball as rpe #reload(rpe) #rpe.eyebalRder("Anim") #rpe.eyebalRder("Render") #rpe.connectIrisPupil()
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.setAttr(self.moduleGrp + ".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') cmds.addAttr(self.moduleGrp, longName="nJoints", attributeType='long') cmds.setAttr(self.moduleGrp + ".nJoints", 1) self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName + "_JointLoc1", r=0.5) self.connectShapeSize(shapeSizeCH) self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint + ".tz", 1.3) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) # Edit GUIDE: cmds.setAttr(self.moduleGrp + ".rx", -90) cmds.setAttr(self.moduleGrp + ".ry", -90) cmds.setAttr(self.moduleGrp + "_RadiusCtrl.tx", 4)
def rigEachPart( self, index, side ): outputTransform = [] inverseAim = False globalMult = 1 if side.find( 'R' ) != -1: inverseAim = True globalMult = -1 aimObjectOptions = { 'axis':0, 'inverseAim':inverseAim, 'replaceTarget':'InitCTL', 'replace':'InitCtl' } fingerInitCtlNameList = self.fingerInitCtlData.getEachFingerList( index, side ) firstFingerInitCtl = fingerInitCtlNameList[0] secondFingerInitCtl = fingerInitCtlNameList[1] betweenFingerInitCtls = fingerInitCtlNameList[2:-1] endFingerInitCtl = fingerInitCtlNameList[-1] aimObject0= rigbase.makeAimObject( secondFingerInitCtl, firstFingerInitCtl, **aimObjectOptions )[0] outputTransform.append( aimObject0 ) aimObject1 = rigbase.makeAimObject( endFingerInitCtl, secondFingerInitCtl, **aimObjectOptions )[0] aimObject1 = cmds.rename( aimObject1, aimObject1.replace( 'AimObj', 'AimGrp' ) ) rigbase.betweenRigInAimObject( betweenFingerInitCtls, aimObject1, replaceTarget='InitCTL', replace='InitCtl', globalMult = globalMult ) for fingerInitCtl in betweenFingerInitCtls: rigbase.AttrEdit( fingerInitCtl ).lockAttrs( 'tz' ) if side.find( 'L' ) != -1: cmds.transformLimits( fingerInitCtl, ty= [0.01,1], ety=[True, False] ) else: cmds.transformLimits( fingerInitCtl, ty= [-1,0.01], ety=[False, True] ) betweenFingerInitCtls.append( endFingerInitCtl ) aimObjectParent = secondFingerInitCtl for fingerInitCtl in betweenFingerInitCtls: aimObject = rigbase.makeAimObject( fingerInitCtl, aimObjectParent, **aimObjectOptions )[0] aimObjectParent = fingerInitCtl outputTransform.append( aimObject ) outputTransform.append( endFingerInitCtl ) return outputTransform
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.addAttr(self.moduleGrp, longName="nJoints", attributeType='long') cmds.setAttr(self.moduleGrp+".nJoints", 1) cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3) self.connectShapeSize(shapeSizeCH) self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001) cmds.setAttr(self.jGuide1+".template", 1) cmds.parent(self.jGuide1, self.moduleGrp, relative=True) self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.2) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint+".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd+".template", 1) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) cmds.parent(self.jGuideEnd, self.jGuide1) ctrls.directConnect(self.cvJointLoc, self.jGuide1, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) ctrls.directConnect(self.cvEndJoint, self.jGuideEnd, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) # change the number of falanges to 3: self.changeJointNumber(3) # create a base cvLoc to start the finger joints: self.cvBaseJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName+"_JointLoc0", r=0.2) self.connectShapeSize(shapeSizeCH) cmds.setAttr(self.cvBaseJoint+".translateZ", -1) cmds.parent(self.cvBaseJoint, self.moduleGrp) # transform cvLocs in order to put as a good finger guide: cmds.setAttr(self.moduleGrp+".rotateX", 90) cmds.setAttr(self.moduleGrp+".rotateZ", 90)
def __setup_main_control(self): #--- this method setups the main control if not cmds.objExists(self.main_ctl + '.globalScale'): attr = attribute.Attribute() attr.addAttr(node= self.main_ctl, attrName = 'globalScale', attrType = 'double', min = 0, default = 1) #--- connect the scale attributes of the main control with the gs for axis in 'xyz': attr.connectAttr(node = [self.main_ctl, self.main_ctl], attribute = ['globalScale', 's' + axis]) #--- limit the scale minimum to 0.01 cmds.transformLimits(self.main_ctl, scaleX = (0.01,1), scaleY = (0.01,1), scaleZ = (0.01,1), enableScaleX = (1,0), enableScaleY = (1,0), enableScaleZ = (1,0)) #--- lock the scale attributes of the main control attr.lockAttr(node = self.main_ctl, attribute = ['s']) if not cmds.objExists(self.main_ctl + '.displayType'): attr = attribute.Attribute() attr.addAttr(node= self.main_ctl, attrName = 'displayType', attrType = 'enum', enum = ['normal', 'template', 'reference']) #--- connect the meshes for i in cmds.ls(type='mesh'): if cmds.objExists(i): attr.setAttr(node=i, attribute=['overrideEnabled'], value=1, lock=True) attr.connectAttr(node=[self.main_ctl, i], attribute=['displayType', 'drawOverride.overrideDisplayType']) attr.setAttr(node=self.main_ctl, attribute=['displayType'], value=2)
def setTranslateLimits(ctrl, tx=True, ty=True, tz=True): """ """ if tx: mc.transformLimits(ctrl, tx=(-1.0, 1.0), etx=(1, 1)) if ty: mc.transformLimits(ctrl, ty=(-1.0, 1.0), ety=(1, 1)) if tz: mc.transformLimits(ctrl, tz=(-1.0, 1.0), etz=(1, 1))
def locadCtl(self, *args): """ """ ctls = cmds.ls(sl=True, fl =1, type = 'transform') tx = cmds.transformLimits(ctls[-1], tx = True, q = True) ty = cmds.transformLimits(ctls[-1], ty = True, q = True) tz = cmds.transformLimits(ctls[-1], tz = True, q = True) rx = cmds.transformLimits(ctls[-1], rx = True, q = True) ry = cmds.transformLimits(ctls[-1], ry = True, q = True) rz = cmds.transformLimits(ctls[-1], rz = True, q = True) cmds.floatField(self.txMinFloatField, e = True, v = tx[0]) cmds.floatField(self.txMaxFloatField, e = True, v = tx[1]) cmds.floatField(self.tyMinFloatField, e = True, v = ty[0]) cmds.floatField(self.tyMaxFloatField, e = True, v = ty[1]) cmds.floatField(self.tzMinFloatField, e = True, v = tz[0]) cmds.floatField(self.tzMaxFloatField, e = True, v = tz[1]) cmds.floatField(self.rxMinFloatField, e = True, v = rx[0]) cmds.floatField(self.rxMaxFloatField, e = True, v = rx[1]) cmds.floatField(self.ryMinFloatField, e = True, v = ry[0]) cmds.floatField(self.ryMaxFloatField, e = True, v = ry[1]) cmds.floatField(self.rzMinFloatField, e = True, v = rz[0]) cmds.floatField(self.rzMaxFloatField, e = True, v = rz[1])
def mirrorControlShape(typ, source, targent, flipAxis): if len(typ) == 0:return if source not in 'LR':return if source == targent:return #- get source side controls all_controls = ' '.join(mc.listRelatives(mc.ls(type='nurbsCurve'), p=True, path=True)) matched_controls = re.findall('\S*%s_\w+_%s_\d+'%(source, typ), all_controls) for ctl in matched_controls: #- get targent control targentControl = re.sub('%s_'%source, '%s_'%targent, ctl) if not mc.objExists(targentControl):continue #- duplicate shape tempx = mc.duplicate(ctl, po=True) mc.parent(mc.listRelatives(ctl, s=True, path=True), tempx, s=True, add=True) #- make Temp Temp = pymel.core.PyNode(mc.duplicate(tempx, rc=True)[0]) for a in 'trs': for b in 'xyz': attr = a + b mc.setAttr('%s.%s'%(Temp, attr), l=False, k=True, cb=False) #- close max min value controler mc.transformLimits(Temp.name(), etx=(0, 0),ety=(0, 0),etz=(0, 0),erx=(0, 0),ery=(0, 0),erz=(0, 0)) mc.parent(Temp.name(), w=True) #- filp grp = mc.createNode('transform') sourcePosi = mc.xform(ctl, q=True, ws=True, rp=True) targenPosi = mc.xform(targentControl, q=True, ws=True, rp=True) midPoint = [(sourcePosi[0] + targenPosi[0]) / 2, (sourcePosi[0] + targenPosi[0]) / 2, (sourcePosi[0] + targenPosi[0]) / 2] mc.move(midPoint[0], midPoint[1], midPoint[2], grp, a=True) mc.parent(Temp.name(), grp) mc.setAttr('%s.s%s'%(grp, flipAxis.lower()), -1) #- freeze transformations mc.parent(Temp.name(), targentControl) mc.makeIdentity(Temp.name(), apply=True, t=True, r=True, s=True) #- get original shapes originalShapes = mc.listRelatives(targentControl, s=True, path=True, type='nurbsCurve') #- parent new shapes shapes = mc.listRelatives(Temp.name(), s=True, path=True, type='nurbsCurve') for shp in shapes: mc.setAttr('%s.ovc'%shp, mc.getAttr('%s.ovc'%originalShapes[0])) mc.delete(originalShapes) mc.parent(shapes, targentControl, s=True, r=True) for shp in shapes: mc.rename(shp, '%sShape'%targentControl) #- delete temp mc.delete(tempx, Temp.name(), grp)
def build(self): FKIKCtl = '%s_legFrontFkIk_ctl_%s' % (self.locus,self.count) IKCtl = '%s_legFrontIk_ctl_%s' % (self.locus,self.count) footBallPivot = '%s_footPivotBallLegFrontIk_org_%s' % (self.locus,self.count) footRoll = '%s_footRollLegFrontIk_org_%s' % (self.locus,self.count) ballIkCtl = '%s_legFrontBallIk_ctl_%s' % (self.locus,self.count) # add attrs cmds.addAttr(FKIKCtl,ln='feetControls',at='double',min=0,max=1,dv=1) cmds.setAttr('%s.feetControls' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='swivel',at='double',dv=0) cmds.setAttr('%s.swivel' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='toeRoll',at='double',dv=0) cmds.setAttr('%s.toeRoll' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='toeSwivel',at='double',dv=0) cmds.setAttr('%s.toeSwivel' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='toeTwist',at='double',dv=0) cmds.setAttr('%s.toeTwist' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='heelBank',at='double',dv=0) cmds.setAttr('%s.heelBank' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='heelSwivel',at='double',dv=0) cmds.setAttr('%s.heelSwivel' % FKIKCtl,e=True,k=True) negate = 1 if self.locus == 'L': negate = -1 elif self.locus == 'C': # fix the outer and inner foot bind joints if the foot is centered cmds.rename('L_%sInnerfoot_bnd_%s' % (self.namespace,self.count),'C_%sInnerfoot_bnd_%s' % (self.namespace,self.count)) cmds.rename('R_%sOuterfoot_bnd_%s' % (self.namespace,self.count),'C_%sOuterfoot_bnd_%s' % (self.namespace,self.count)) # constrain to the rig cmds.connectAttr('C_main_loc_0Shape.worldPosition','%s_%s_mod_%s.translate' % (self.locus,self.namespace,self.count)) cmds.orientConstraint('C_main_loc_0','%s_%s_mod_%s' % (self.locus,self.namespace,self.count),mo=True) cmds.parentConstraint('%s_%sFoot_bnd_%s' % (self.locus,self.namespace,self.count),'%s_%sFKIK_org_%s' % (self.locus,self.namespace,self.count),mo=True) cmds.parentConstraint('C_chest_bnd_0','%s_%sCtl_org_%s' % (self.locus,self.namespace,self.count),mo=True) # connect fkikctl attrs to ik foot ctl attrs cmds.connectAttr('%s.swivel' % FKIKCtl,'%s.swivel' % IKCtl) cmds.setAttr('%s.swivel' % IKCtl,l=True,k=False) cmds.setAttr('%s.toe' % IKCtl,l=True,k=False) cmds.setAttr('%s.rollAngle' % IKCtl,l=True,k=False) # add control to IK feet controls to hide other controls cmds.connectAttr('%s.feetControls' % FKIKCtl,'%s_legFrontToeIk_ctl_%sShape.v' % (self.locus,self.count)) cmds.connectAttr('%s.feetControls' % FKIKCtl,'%s_legFrontHeelIk_ctl_%sShape.v' % (self.locus,self.count)) # add follow to ik feet controls cmds.addAttr(IKCtl,ln='follow',at='double',min=0,max=1,dv=0) cmds.setAttr('%s.follow' % IKCtl,e=True,k=True) pConst = cmds.parentConstraint('%s_%sIK_org_%s' % (self.locus,self.namespace,self.count),'C_root_bnd_0','%s_legFrontIk_org_%s' % (self.locus,self.count),mo=True)[0] rev = cmds.createNode('reverse') cmds.connectAttr('%s.follow' % IKCtl,'%s.C_root_bnd_0W1' % pConst) cmds.connectAttr('%s.follow' % IKCtl,'%s.inputX' % rev) cmds.connectAttr('%s.outputX' % rev,'%s.%s_%sIK_org_%sW0' % (pConst,self.locus,self.namespace,self.count)) cmds.setAttr('%s.interpType' % pConst, 2) # reconnect foot roll cmds.parent(footBallPivot, '%s_legFrontBallIk_cth_%s' % (self.locus,self.count)) cmds.setAttr('%s.roll' % IKCtl,l=True,cb=False,k=False) cmds.connectAttr('%s.swivel' % IKCtl,'%s_legFrontToeIk_cth_%s.ry' % (self.locus,self.count)) # add foot bank off = cmds.group(em=True,n='%s_%sFootBankInIk_off_%s' % (self.locus,self.namespace,self.count)) inn = cmds.group(em=True,n='%s_%sFootBankInIk_org_%s' % (self.locus,self.namespace,self.count)) cmds.delete(cmds.parentConstraint('%s_%sInnerfoot_bnd_%s' % (self.locus,self.namespace,self.count),inn,mo=False)) cmds.delete(cmds.parentConstraint('%s_%sInnerfoot_bnd_%s' % (self.locus,self.namespace,self.count),off,mo=False)) out = cmds.group(em=True,n='%s_%sFootBankOutIk_org_%s' % (self.locus,self.namespace,self.count)) cmds.delete(cmds.parentConstraint('%s_%sOuterfoot_bnd_%s' % (self.locus,self.namespace,self.count),out,mo=False)) cmds.parent(off,IKCtl) cmds.parent(inn,off) cmds.parent(out,inn) cmds.parent(footRoll,out) cmds.setAttr('%s.rz' % ballIkCtl,l=False,k=True) cmds.transformLimits(ballIkCtl,erz=[0,0]) cond = cmds.createNode('condition') mult = cmds.createNode('multiplyDivide') cmds.connectAttr('%s.rz' % ballIkCtl,'%s.firstTerm' % cond) cmds.connectAttr('%s.rz' % ballIkCtl,'%s.colorIfTrueR' % cond) if self.locus == 'R': cmds.setAttr('%s.operation' % cond,2) else: cmds.setAttr('%s.operation' % cond,4) cmds.setAttr('%s.colorIfFalseR' % cond,0) cmds.setAttr('%s.input2X' % mult,negate) cmds.connectAttr('%s.outColorR' % cond,'%s.input1X' % mult) cmds.connectAttr('%s.outputX' % mult,'%s.rx' % out) cond = cmds.createNode('condition') mult = cmds.createNode('multiplyDivide') cmds.connectAttr('%s.rz' % ballIkCtl,'%s.firstTerm' % cond) cmds.connectAttr('%s.rz' % ballIkCtl,'%s.colorIfTrueR' % cond) if self.locus == 'R': cmds.setAttr('%s.operation' % cond,4) else: cmds.setAttr('%s.operation' % cond,2) cmds.setAttr('%s.colorIfFalseR' % cond,0) cmds.setAttr('%s.input2X' % mult,negate) cmds.connectAttr('%s.outColorR' % cond,'%s.input1X' % mult) cmds.connectAttr('%s.outputX' % mult,'%s.rx' % inn) # dup = cmds.duplicate(ballIkCtl,po=True,n='%s_legBallIk_dmy_%s' % (self.locus,self.count))[0] # cmds.parent(footBallPivot,dup) # cmds.connectAttr('%s.rx' % ballIkCtl,'%s.rx' % dup) # reorient the toes and midfoot controls # toe = cmds.circle(ch=False)[0] # midfoot = cmds.circle(ch=False)[0] # new = [toe,midfoot] # old = ['%s_%sToesFk_ctl_%s' % (self.locus,self.namespace,self.count),'%s_%sMidfootFk_ctl_%s' % (self.locus,self.namespace,self.count)] # # i = 0 # while True: # if i == len(new): break # # a = new[i] # b = old[i] # p = cmds.listRelatives(b,p=True)[0] # gp = cmds.listRelatives(p,p=True)[0] # pos = cmds.xform(b,q=True,ws=True,t=True) # cmds.move(pos[0],pos[1],pos[2],a,ws=True) # cmds.parent(b,a) # cmds.parent(p,w=True) # cmds.setAttr('%s.rotate' % p,0,0,0) # cmds.parent(p,gp) # cmds.parent(a,p) # shpA = cmds.listRelatives(a,s=True)[0] # cmds.setAttr('%s.overrideEnabled' % shpA,1) # shpB = cmds.listRelatives(b,s=True)[0] # plg = cmds.listConnections('%s.v' % shpB,s=True,d=False,p=True) # if plg: # cmds.disconnectAttr(plg[0],'%s.v' % shpB) # cmds.connectAttr(plg[0],'%s.v' % shpA) # cmds.setAttr('%s.v' % shpB,0) # cmds.setAttr('%s.v' % a,l=True,k=False) # cmds.connectAttr('%s.sx' % a, '%s.sz' % b) # cmds.connectAttr('%s.sy' % a, '%s.sy' % b) # cmds.connectAttr('%s.sz' % a, '%s.sx' % b) # cmds.rename(b,string.replace(b,'_ctl_','_dmy_')) # cmds.rename(shpA,'%sShape' % b) # cmds.rename(a,b) # i = i + 1 # rerig foot roll to incorporate the toe joint cmds.delete('%s_%sToesEnd_bnd_%s' % (self.locus,self.namespace,self.count)) cmds.parent('%s_%sToe_bnd_%s' % (self.locus,self.namespace,self.count),'%s_%sToes_bnd_%s' % (self.locus,self.namespace,self.count)) # create toes IK joint toesIKJoint = cmds.joint(n='%s_%sToesIk_jnt_%s' % (self.locus,self.namespace,self.count)) pos = cmds.xform('%s_%sToes_bnd_%s' % (self.locus,self.namespace,self.count),q=True,ws=True,t=True) cmds.move(pos[0],pos[1],pos[2],toesIKJoint,ws=True) cmds.parent(toesIKJoint,'%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count)) cmds.makeIdentity(toesIKJoint,a=True,r=True,jo=True) cmds.parent('%s_%sToeIk_jnt_%s' % (self.locus,self.namespace,self.count),toesIKJoint) # new rotational groups org = cmds.group(em=True,n='%s_%sToesPivotBallLegIK_org_%s' % (self.locus,self.namespace,self.count)) cmds.parent(org,'%s_legFrontBallIk_cth_%s' % (self.locus,self.count),r=True) cmds.move(pos[0],pos[1],pos[2],org,ws=True) cmds.parent(footBallPivot,org) # toe ik handles cmds.delete('%s_liftToeLegFrontToeIk_org_%s' % (self.locus,self.count)) midfootIK = cmds.ikHandle(n='%s_legFrontMidfootIk_hdl_%s' % (self.locus,self.count),sj='%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),ee=toesIKJoint)[0] toeIK = cmds.ikHandle(n='%s_legFrontToeIk_hdl_%s' % (self.locus,self.count),sj=toesIKJoint,ee='%s_%sToeIk_jnt_%s' % (self.locus,self.namespace,self.count))[0] cmds.setAttr('%s.v' % midfootIK,0) cmds.setAttr('%s.v' % toeIK,0) # connect roll clamp = cmds.createNode('clamp') mult = cmds.createNode('multiplyDivide') cmds.setAttr('%s.maxR' % clamp,99999) cmds.setAttr('%s.input2X' % mult,0.25) #cmds.connectAttr('%s.rx' % ballIkCtl,'%s.input1X' % mult) #cmds.connectAttr('%s.outputX' % mult,'%s.inputR' % clamp) #cmds.connectAttr('%s.outputR' % clamp,'%s.rx' % footBallPivot) cmds.connectAttr('%s.rx' % ballIkCtl,'%s.inputR' % clamp) cmds.connectAttr('%s.outputR' % clamp,'%s.input1X' % mult) cmds.connectAttr('%s.outputX' % mult,'%s.rx' % footBallPivot) cmds.connectAttr('%s.outputR' % clamp,'%s.rx' % org) clamp = cmds.createNode('clamp') #avg = cmds.createNode('plusMinusAverage') plug = cmds.listConnections('%s_rollLegFrontHeelIk_org_%s.rx' % (self.locus,self.count),s=True,d=False,p=True)[0] cmds.setAttr('%s.minR' % clamp,-99999) cmds.connectAttr('%s.rx' % ballIkCtl,'%s.inputR' % clamp) cmds.disconnectAttr(plug,'%s_rollLegFrontHeelIk_org_%s.rx' % (self.locus,self.count)) cmds.connectAttr('%s.outputR' % clamp,'%s_rollLegFrontHeelIk_org_%s.rx' % (self.locus,self.count)) cmds.connectAttr('%s.heelBank' % FKIKCtl,'%s.rz' % footBallPivot) cmds.connectAttr('%s.heelBank' % FKIKCtl,'%s.rz' % org) #cmds.setAttr('%s.input1D[0]' % avg,cmds.getAttr('%s.ry' % footBallPivot)) #cmds.connectAttr('%s.heelSwivel' % FKIKCtl,'%s.input1D[1]' % avg) #cmds.connectAttr('%s.output1D' % avg, '%s.ry' % footBallPivot) children = cmds.listRelatives(footBallPivot,c=True) cmds.parent(children,w=True) cmds.connectAttr('%s.heelSwivel' % FKIKCtl,'%s.ry' % footBallPivot) cmds.parent(children,footBallPivot) cmds.connectAttr('%s.heelSwivel' % FKIKCtl,'%s.ry' % org) # create 'fk' controls toesctl = cmds.circle(ch=False,n='%s_%sToesIk_ctl_%s' % (self.locus,self.namespace,self.count))[0] toescth = cmds.group(n='%s_%sToesIk_cth_%s' % (self.locus,self.namespace,self.count)) toesctg = cmds.group(n='%s_%sToesIk_ctg_%s' % (self.locus,self.namespace,self.count)) toesdummyoff = cmds.group(n='%s_%sToesIkDummy_off_%s' % (self.locus,self.namespace,self.count),em=True) toesdummyorg = cmds.group(n='%s_%sToesIkDummy_org_%s' % (self.locus,self.namespace,self.count)) #cmds.move(pos[0],pos[1],pos[2],toesctg,ws=True) #cmds.move(pos[0],pos[1],pos[2],toesdummyorg,ws=True) cmds.delete(cmds.parentConstraint('%s_%sToesIk_jnt_%s' % (self.locus,self.namespace,self.count),toesctg,mo=False)) cmds.delete(cmds.parentConstraint('%s_%sToesIk_jnt_%s' % (self.locus,self.namespace,self.count),toesdummyorg,mo=False)) pos = cmds.xform('%s_%sMidfoot_bnd_%s' % (self.locus,self.namespace,self.count),q=True,ws=True,t=True) footctl = cmds.circle(ch=False,n='%s_%sMidfootIk_ctl_%s' % (self.locus,self.namespace,self.count))[0] footcth = cmds.group(n='%s_%sMidfootIk_cth_%s' % (self.locus,self.namespace,self.count)) footctg = cmds.group(n='%s_%sMidfootIk_ctg_%s' % (self.locus,self.namespace,self.count)) footdummyoff = cmds.group(n='%s_%sMidfootIkDummy_off_%s' % (self.locus,self.namespace,self.count),em=True) footdummyorg = cmds.group(n='%s_%sMidfootIkDummy_org_%s' % (self.locus,self.namespace,self.count)) footdummymain = cmds.group(n='%s_%sFootIkDummy_org_%s' % (self.locus,self.namespace,self.count)) #cmds.move(pos[0],pos[1],pos[2],footctg,ws=True) #cmds.move(pos[0],pos[1],pos[2],footdummyorg,ws=True) cmds.delete(cmds.parentConstraint('%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),footctg,mo=False)) #cmds.delete(cmds.parentConstraint('%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),footdummyorg,mo=False)) cmds.delete(cmds.parentConstraint('%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),footdummymain,mo=False)) cmds.setAttr('%s.tx' % toesctl,l=True,k=False) cmds.setAttr('%s.ty' % toesctl,l=True,k=False) cmds.setAttr('%s.tz' % toesctl,l=True,k=False) cmds.setAttr('%s.sx' % toesctl,l=True,k=False) cmds.setAttr('%s.sy' % toesctl,l=True,k=False) cmds.setAttr('%s.sz' % toesctl,l=True,k=False) cmds.setAttr('%s.v' % toesctl,l=True,k=False) cmds.setAttr('%s.tx' % footctl,l=True,k=False) cmds.setAttr('%s.ty' % footctl,l=True,k=False) cmds.setAttr('%s.tz' % footctl,l=True,k=False) cmds.setAttr('%s.sx' % footctl,l=True,k=False) cmds.setAttr('%s.sy' % footctl,l=True,k=False) cmds.setAttr('%s.sz' % footctl,l=True,k=False) cmds.setAttr('%s.v' % footctl,l=True,k=False) cmds.parent(toesctg,footctl) cmds.parent(toesdummyorg,footdummyoff) #cmds.parent(footdummyorg,footdummymain) cmds.parent(footctg,'%s_legFrontToeIk_ctl_%s' % (self.locus,self.count)) cmds.parent(footdummymain,'%s_legFrontToeIk_ctl_%s' % (self.locus,self.count)) cmds.parent(toeIK,toesdummyoff) cmds.parent(midfootIK,footdummyoff) ##################################### ##################################### ##################################### ##################################### cmds.connectAttr('%s.rotate' % toesctl,'%s.rotate' % toesdummyoff) cmds.connectAttr('%s.rotate' % footctl,'%s.rotate' % footdummyoff) #cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % toescth) #cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % footcth) #cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % toesdummyorg) #cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % footdummyorg) cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rz' % toescth) cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rz' % footcth) cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rz' % toesdummyorg) cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rz' % footdummyorg) cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % toescth) cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % footcth) cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % toesdummyorg) cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % footdummyorg) #cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % toescth) #cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % footcth) #cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % toesdummyorg) #cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % footdummyorg) cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rx' % toescth) cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rx' % footcth) cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rx' % toesdummyorg) cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rx' % footdummyorg) cmds.parentConstraint('%s_%sFootIk_jnt_%s' % (self.locus,self.namespace,self.count),footctg,mo=True) cmds.parentConstraint('%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),toesctg,mo=True) # connect shape visibility shp = cmds.listRelatives(toesctl,s=True)[0] cmds.connectAttr('%s.feetControls' % FKIKCtl,'%s.v' % shp) shp = cmds.listRelatives(footctl,s=True)[0] cmds.connectAttr('%s.feetControls' % FKIKCtl,'%s.v' % shp) # move original fk controls cmds.parent('%s_%sMidfootFk_ctj_%s' % (self.locus,self.namespace,self.count),'%s_%sFootFk_jnt_%s' % (self.locus,self.namespace,self.count)) cmds.parent('%s_%sToesFk_ctj_%s' % (self.locus,self.namespace,self.count),'%s_%sMidfootFk_jnt_%s' % (self.locus,self.namespace,self.count)) cmds.delete('%s_to%sMidfootFk_jth_%s' % (self.locus,self.namespace,self.count),'%s_to%sFootFk_jth_%s' % (self.locus,self.namespace,self.count)) # constrain bind joints for constraint in cmds.listConnections('%s_%sMidfoot_bnd_%s' % (self.locus,self.namespace,self.count),s=True,d=False): if cmds.objectType(constraint,isAType='constraint'): cmds.delete(constraint) break pConst = cmds.parentConstraint('%s_%sMidfootFk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sMidfoot_bnd_%s' % (self.locus,self.namespace,self.count))[0] rev = cmds.createNode('reverse') cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.inputX' % rev) cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%s_%sMidfootIk_jnt_%sW1' % (pConst,self.locus,self.namespace,self.count)) cmds.connectAttr('%s.outputX' % rev,'%s.%s_%sMidfootFk_jnt_%sW0' % (pConst,self.locus,self.namespace,self.count)) for constraint in cmds.listConnections('%s_%sToes_bnd_%s' % (self.locus,self.namespace,self.count),s=True,d=False): if cmds.objectType(constraint,isAType='constraint'): cmds.delete(constraint) break pConst = cmds.parentConstraint('%s_%sToesFk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sToesIk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sToes_bnd_%s' % (self.locus,self.namespace,self.count))[0] cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%s_%sToesIk_jnt_%sW1' % (pConst,self.locus,self.namespace,self.count)) cmds.connectAttr('%s.outputX' % rev,'%s.%s_%sToesFk_jnt_%sW0' % (pConst,self.locus,self.namespace,self.count)) ### ^ ### ^ ### ^ ### # replace the ik control with split translational/rotational controls # cmds.delete('%s_%sFootIk_orc_%s' % (self.locus,self.namespace,self.count)) # ctg = cmds.duplicate('%s_%sFootFk_cth_%s' % (self.locus,self.namespace,self.count),n='%s_%sFootIk_ctg_%s' % (self.locus,self.namespace,self.count),po=True)[0] # cth = cmds.duplicate('%s_%sFootFk_cth_%s' % (self.locus,self.namespace,self.count),n='%s_%sFootIk_cth_%s' % (self.locus,self.namespace,self.count),po=True)[0] # ctl = cmds.duplicate('%s_%sFootFk_ctl_%s' % (self.locus,self.namespace,self.count),n='%s_%sFootIk_ctl_%s' % (self.locus,self.namespace,self.count))[0] # cmds.delete(cmds.listRelatives(ctl,type='joint',f=True)) # cmds.parent(ctl,cth) # cmds.parent(cth,ctg) # cmds.parent(ctg,IKCtl) # cmds.makeIdentity(ctg,a=True,r=True) # cmds.parent('%s_%sFootBankInIk_org_%s' % (self.locus,self.namespace,self.count),ctl) # create dummy ik leg to constrain the foot rotation controls # shoulder = cmds.duplicate('%s_%sShoulderIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_%sShoulderIk_dmy_%s' % (self.locus,self.namespace,self.count),po=True)[0] # elbow = cmds.duplicate('%s_%sElbowIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_%sElbowIk_dmy_%s' % (self.locus,self.namespace,self.count),po=True)[0] # foot = cmds.duplicate('%s_%sFootIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_%sFootIk_dmy_%s' % (self.locus,self.namespace,self.count),po=True)[0] # cmds.parent(foot,elbow) # cmds.parent(elbow,shoulder) # handle = cmds.ikHandle(sj=shoulder,ee=foot,sol='ikRPsolver')[0] # cmds.parent(handle,IKCtl) # cmds.setAttr('%s.v' % handle,0) # cmds.poleVectorConstraint('%s_poleLegFront_ctl_%s' % (self.locus,self.count),handle) # setup the global orientation blending of the ik foot rotational control # pConst = cmds.parentConstraint(foot,IKCtl,ctg,st=['x','y','z'],mo=True)[0] # rev = cmds.createNode('reverse') # cmds.connectAttr('%s.Global' % ctl,'%s.%sW1' % (pConst,IKCtl)) # cmds.connectAttr('%s.Global' % ctl,'%s.inputX' % rev) # cmds.connectAttr('%s.outputX' % rev,'%s.%sW0' % (pConst,foot)) # cmds.setAttr('%s.interpType' % pConst,2) # cmds.setAttr('%s.Global' % ctl,1) # lower the foot roll controls to the ground plane cmds.setAttr('%s_rollLegFrontBallIk_org_%s.tx' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegFrontBallIk_org_%s.ty' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegFrontBallIk_org_%s.tz' % (self.locus,self.count),l=False,k=True) cmds.parent('%s_rollLegFrontBallIk_org_%s' % (self.locus,self.count),w=True) cmds.parent('%s_%sMidfootIk_ctg_%s' % (self.locus,self.namespace,self.count),w=True) cmds.parent('%s_%sFootIkDummy_org_%s' % (self.locus,self.namespace,self.count),w=True) #cmds.parent('%s_liftToeLegFrontToeIk_org_%s' % (self.locus,self.count),w=True) cmds.setAttr('%s_rollLegFrontHeelIk_org_%s.tx' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegFrontHeelIk_org_%s.ty' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegFrontHeelIk_org_%s.tz' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegFrontToeIk_org_%s.tx' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegFrontToeIk_org_%s.ty' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegFrontToeIk_org_%s.tz' % (self.locus,self.count),l=False,k=True) cmds.parent(toeIK,w=True) cmds.move(0,0,0,'%s_rollLegFrontHeelIk_org_%s' % (self.locus,self.count),ws=True,x=False,y=True,z=False) cmds.move(0,0,0,'%s_rollLegFrontToeIk_org_%s' % (self.locus,self.count),ws=True,x=False,y=True,z=False) cmds.parent('%s_rollLegFrontBallIk_org_%s' % (self.locus,self.count),'%s_legFrontToeIk_ctl_%s' % (self.locus,self.count)) cmds.parent('%s_%sMidfootIk_ctg_%s' % (self.locus,self.namespace,self.count),'%s_legFrontToeIk_ctl_%s' % (self.locus,self.count)) cmds.parent('%s_%sFootIkDummy_org_%s' % (self.locus,self.namespace,self.count),'%s_legFrontToeIk_ctl_%s' % (self.locus,self.count)) cmds.parent(toeIK,toesdummyoff) #cmds.parent('%s_liftToeLegFrontToeIk_org_%s' % (self.locus,self.count),'%s_legFrontToeIk_ctl_%s' % (self.locus,self.count)) # lock attributes for attr in ['sx','sy','sz']: cmds.setAttr('%s_%sShoulderFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) cmds.setAttr('%s_%sElbowFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) cmds.setAttr('%s_%sFootFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) #cmds.setAttr('%s_%sFootIk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) cmds.setAttr('%s_%sMidfootFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) cmds.setAttr('%s_%sToesFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) # reconstrain pole vector cmds.delete('%s_legFrontFkIk_prc_%s' % (self.locus,self.count)) cmds.delete('%s_poleLegFront_prc_%s' % (self.locus,self.count)) pConst = cmds.parentConstraint(IKCtl,'%s_poleLegFrontStatic_tgt_%s' % (self.locus,self.count),'%s_poleLegFront_org_%s' % (self.locus,self.count),mo=True)[0] rev = cmds.createNode('reverse') cmds.connectAttr('%s_poleLegFront_ctl_%s.follow' % (self.locus,self.count),'%s.%sW0' % (pConst,IKCtl)) cmds.connectAttr('%s_poleLegFront_ctl_%s.follow' % (self.locus,self.count),'%s.inputX' % rev) cmds.connectAttr('%s.outputX' % rev,'%s.%s_poleLegFrontStatic_tgt_%sW1' % (pConst,self.locus,self.count)) cmds.setAttr('%s.interpType' % pConst,2) # add extra wrist IK control ctl = cmds.circle(ch=False,n='%s_%sWristIk_ctl_%s' % (self.locus,self.namespace,self.count))[0] cth = cmds.group(n='%s_%sWristIk_cth_%s' % (self.locus,self.namespace,self.count)) ctg = cmds.group(n='%s_%sWristIk_ctg_%s' % (self.locus,self.namespace,self.count)) cmds.parent(ctg,footBallPivot,r=True) cmds.parent('%s_legFrontIk_hdl_%s' % (self.locus,self.count),ctl) cmds.setAttr('%s.tx' % ctl,l=True,k=False) cmds.setAttr('%s.ty' % ctl,l=True,k=False) cmds.setAttr('%s.tz' % ctl,l=True,k=False) cmds.setAttr('%s.sx' % ctl,l=True,k=False) cmds.setAttr('%s.sy' % ctl,l=True,k=False) cmds.setAttr('%s.sz' % ctl,l=True,k=False) cmds.setAttr('%s.v' % ctl,l=True,k=False) cmds.setAttr('%s.legAim' % IKCtl,0)
def setTranslateLimits(ctrl,tx=[],ty=[],tz=[]): ''' ''' if(tx): mc.transformLimits(ctrl,tx=(tx[0],tx[1]),etx=(1,1)) if(ty): mc.transformLimits(ctrl,ty=(ty[0],ty[1]),ety=(1,1)) if(tz): mc.transformLimits(ctrl,tz=(tz[0],tz[1]),etz=(1,1))
def ctlSetLimits(self, *args): """ """ ctls = cmds.ls(sl=1, fl =1, type = 'transform') posTx = cmds.floatField(self.txMaxFloatField, q = True, v = True) negTx = cmds.floatField(self.txMinFloatField, q = True, v = True) posTy = cmds.floatField(self.tyMaxFloatField, q = True, v = True) negTy = cmds.floatField(self.tyMinFloatField, q = True, v = True) posTz = cmds.floatField(self.tzMaxFloatField, q = True, v = True) negTz = cmds.floatField(self.tzMinFloatField, q = True, v = True) posRx = cmds.floatField(self.rxMaxFloatField, q = True, v = True) negRx = cmds.floatField(self.rxMinFloatField, q = True, v = True) posRy = cmds.floatField(self.ryMaxFloatField, q = True, v = True) negRy = cmds.floatField(self.ryMinFloatField, q = True, v = True) posRz = cmds.floatField(self.rzMaxFloatField, q = True, v = True) negRz = cmds.floatField(self.rzMinFloatField, q = True, v = True) for c in ctls: #set translate limits if cmds.getAttr(c +'.translateX', lock =1) == False: cmds.transformLimits(c, translationX = (negTx, posTx), etx = (1,1)) if cmds.getAttr(c +'.translateY', lock =1) == False: cmds.transformLimits(c, translationY = (negTy, posTy), ety =(1,1)) if cmds.getAttr(c +'.translateZ', lock =1) == False: cmds.transformLimits(c, translationZ = (negTz, posTz), etz =(1,1)) #set rotate limits if cmds.getAttr(c +'.rotateX', lock =1) == False: cmds.transformLimits(c, rotationX = (negRx, posRx), erx =(1,1)) if cmds.getAttr(c +'.rotateX', lock =1) == False: cmds.transformLimits(c, rotationY = (negRy, posRy), ery =(1,1)) if cmds.getAttr(c +'.rotateX', lock =1) == False: cmds.transformLimits(c, rotationZ = (negRz, posRz), erz =(1,1))
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.setAttr(self.moduleGrp + ".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') # create cvJointLoc and cvLocators: self.cvFootLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName + "_foot", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFALoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfA", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFBLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfB", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFCLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfC", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFDLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfD", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvRFELoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_RfE", r=0.3) self.connectShapeSize(shapeSizeCH) # create jointGuides: self.jGuideFoot = cmds.joint(name=self.guideName + "_JGuideFoot", radius=0.001) self.jGuideRFE = cmds.joint(name=self.guideName + "_JGuideRfE", radius=0.001) cmds.select(clear=True) self.jGuideRFA = cmds.joint(name=self.guideName + "_JGuideRfA", radius=0.001) self.jGuideRFD = cmds.joint(name=self.guideName + "_JGuideRfD", radius=0.001) self.jGuideRFB = cmds.joint(name=self.guideName + "_JGuideRfB", radius=0.001) self.jGuideRFC = cmds.joint(name=self.guideName + "_JGuideRfC", radius=0.001) self.jGuideRFAC = cmds.joint(name=self.guideName + "_JGuideRfAC", radius=0.001) # set jointGuides as templates: cmds.setAttr(self.jGuideFoot + ".template", 1) cmds.setAttr(self.jGuideRFA + ".template", 1) cmds.setAttr(self.jGuideRFB + ".template", 1) cmds.setAttr(self.jGuideRFC + ".template", 1) cmds.setAttr(self.jGuideRFD + ".template", 1) cmds.setAttr(self.jGuideRFE + ".template", 1) cmds.parent(self.jGuideFoot, self.jGuideRFA, self.moduleGrp, relative=True) # create cvEnd: self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvRFELoc) cmds.setAttr(self.cvEndJoint + ".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName + "_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd + ".template", 1) cmds.parent(self.jGuideEnd, self.jGuideRFE) # make parents between cvLocs: cmds.parent(self.cvFootLoc, self.cvRFALoc, self.cvRFBLoc, self.cvRFCLoc, self.cvRFDLoc, self.moduleGrp) cmds.parent(self.cvRFELoc, self.cvFootLoc) # connect cvLocs in jointGuides: ctrls.directConnect(self.cvFootLoc, self.jGuideFoot, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) cmds.parentConstraint(self.cvRFALoc, self.jGuideRFA, maintainOffset=False, name=self.jGuideRFA + "_ParentConstraint") cmds.parentConstraint(self.cvRFBLoc, self.jGuideRFB, maintainOffset=False, name=self.jGuideRFB + "_ParentConstraint") cmds.parentConstraint(self.cvRFCLoc, self.jGuideRFC, maintainOffset=False, name=self.jGuideRFC + "_ParentConstraint") cmds.parentConstraint(self.cvRFDLoc, self.jGuideRFD, maintainOffset=False, name=self.jGuideRFD + "_ParentConstraint") cmds.parentConstraint(self.cvRFELoc, self.jGuideRFE, maintainOffset=False, name=self.jGuideRFE + "_ParentConstraint") cmds.parentConstraint(self.cvRFALoc, self.jGuideRFAC, maintainOffset=False, name=self.jGuideRFAC + "_ParentConstraint") ctrls.directConnect(self.cvEndJoint, self.jGuideEnd, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']) # limit, lock and hide cvEnd: cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) # transform cvLocs in order to put as a good foot guide: cmds.setAttr(self.cvFootLoc + ".translateZ", 2) cmds.setAttr(self.cvFootLoc + ".rotateY", -90) cmds.setAttr(self.cvRFELoc + ".translateX", -1) cmds.setAttr(self.cvRFELoc + ".translateZ", 2.5) cmds.setAttr(self.cvRFCLoc + ".translateX", 1) cmds.setAttr(self.cvRFALoc + ".translateX", -0.6) cmds.setAttr(self.cvRFALoc + ".translateY", -1) cmds.setAttr(self.cvRFBLoc + ".translateX", -0.6) cmds.setAttr(self.cvRFBLoc + ".translateY", 1) cmds.setAttr(self.cvRFDLoc + ".translateX", -3.5) cmds.setAttr(self.moduleGrp + ".rotateX", -90) cmds.setAttr(self.moduleGrp + ".rotateY", 90)
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.setAttr(self.moduleGrp + ".moduleNamespace", self.moduleGrp[: self.moduleGrp.rfind(":")], type="string") # create cvJointLoc and cvLocators: self.cvNeckLoc, shapeSizeCH = ctrls.cvJointLoc(ctrlName=self.guideName + "_neck", r=0.5) self.connectShapeSize(shapeSizeCH) self.cvHeadLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_head", r=0.4) self.connectShapeSize(shapeSizeCH) self.cvJawLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_jaw", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvChinLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_chin", r=0.3) self.connectShapeSize(shapeSizeCH) self.cvLLipLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_lLip", r=0.1) self.connectShapeSize(shapeSizeCH) self.cvRLipLoc, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_rLip", r=0.1) self.connectShapeSize(shapeSizeCH) # create jointGuides: self.jGuideNeck = cmds.joint(name=self.guideName + "_JGuideNeck", radius=0.001) self.jGuideHead = cmds.joint(name=self.guideName + "_JGuideHead", radius=0.001) self.jGuideJaw = cmds.joint(name=self.guideName + "_JGuideJaw", radius=0.001) self.jGuideChin = cmds.joint(name=self.guideName + "_JGuideChin", radius=0.001) # set jointGuides as templates: cmds.setAttr(self.jGuideNeck + ".template", 1) cmds.setAttr(self.jGuideHead + ".template", 1) cmds.setAttr(self.jGuideJaw + ".template", 1) cmds.setAttr(self.jGuideChin + ".template", 1) cmds.parent(self.jGuideNeck, self.moduleGrp, relative=True) # create cvEnd: self.cvEndJoint, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_JointEnd", r=0.1) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvChinLoc) cmds.setAttr(self.cvEndJoint + ".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName + "_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd + ".template", 1) cmds.parent(self.jGuideEnd, self.jGuideChin) # make parents between cvLocs: cmds.parent(self.cvNeckLoc, self.moduleGrp) cmds.parent(self.cvHeadLoc, self.cvNeckLoc) cmds.parent(self.cvJawLoc, self.cvHeadLoc) cmds.parent(self.cvChinLoc, self.cvJawLoc) cmds.parent(self.cvLLipLoc, self.cvJawLoc) cmds.parent(self.cvRLipLoc, self.cvJawLoc) # connect cvLocs in jointGuides: ctrls.directConnect(self.cvNeckLoc, self.jGuideNeck, ["tx", "ty", "tz", "rx", "ry", "rz"]) ctrls.directConnect(self.cvHeadLoc, self.jGuideHead, ["tx", "ty", "tz", "rx", "ry", "rz"]) ctrls.directConnect(self.cvJawLoc, self.jGuideJaw, ["tx", "ty", "tz", "rx", "ry", "rz"]) ctrls.directConnect(self.cvChinLoc, self.jGuideChin, ["tx", "ty", "tz", "rx", "ry", "rz"]) ctrls.directConnect(self.cvEndJoint, self.jGuideEnd, ["tx", "ty", "tz", "rx", "ry", "rz"]) # limit, lock and hide cvEnd: cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) ctrls.setLockHide([self.cvEndJoint], ["tx", "ty", "rx", "ry", "rz", "sx", "sy", "sz"]) # transform cvLocs in order to put as a good head guide: cmds.setAttr(self.cvNeckLoc + ".rotateY", -10) cmds.setAttr(self.cvHeadLoc + ".translateZ", 2) cmds.setAttr(self.cvHeadLoc + ".rotateY", 5) cmds.setAttr(self.cvJawLoc + ".translateX", -0.5) cmds.setAttr(self.cvJawLoc + ".translateZ", 1.25) cmds.setAttr(self.cvJawLoc + ".rotateY", -95) cmds.setAttr(self.cvChinLoc + ".translateZ", 0.25) cmds.setAttr(self.moduleGrp + ".rotateX", -90) cmds.setAttr(self.moduleGrp + ".rotateY", 90) # lip cvLocs: cmds.setAttr(self.cvLLipLoc + ".translateY", -0.5) cmds.setAttr(self.cvLLipLoc + ".translateZ", 1) self.lipMD = cmds.createNode("multiplyDivide", name=self.guideName + "_lip_MD") cmds.connectAttr(self.cvLLipLoc + ".translateX", self.lipMD + ".input1X", force=True) cmds.connectAttr(self.cvLLipLoc + ".translateY", self.lipMD + ".input1Y", force=True) cmds.connectAttr(self.cvLLipLoc + ".translateZ", self.lipMD + ".input1Z", force=True) cmds.connectAttr(self.lipMD + ".outputX", self.cvRLipLoc + ".translateX", force=True) cmds.connectAttr(self.lipMD + ".outputY", self.cvRLipLoc + ".translateY", force=True) cmds.connectAttr(self.lipMD + ".outputZ", self.cvRLipLoc + ".translateZ", force=True) cmds.setAttr(self.lipMD + ".input2Y", -1)
from sgMaya import sgCmds, sgModel import pymel.core from maya import cmds slider = sgCmds.makeController( sgModel.Controller.move2Points, 0.5 ) sliderBase = sgCmds.createSliderBase('x') slider.setParent( sliderBase ) cmds.transformLimits( slider.name(), tx=[0,1], etx=[1,0] ) cmds.transformLimits( slider.name(), ty=[0,1], ety=[1,0] ) keyAttrs = cmds.listAttr( slider.name(), k=1, sn=1 ) keyAttrs += cmds.listAttr( slider.name(), cb=1, sn=1 ) for keyAttr in keyAttrs: if keyAttr in ['tx','ty'] : continue cmds.setAttr( slider.attr( keyAttr ).name(), e=1, lock=1, k=0 ) cmds.setAttr( slider.attr( keyAttr ).name(), e=1, cb=0 ) sliderBaseParent = sgCmds.makeParent( sliderBase ) pymel.core.select( sliderBaseParent )
def makeRotateInfoForOneJoint(joint): #- create sets TempCircle = mc.circle(r=1, ch=False) TempLine = mc.curve(d=1, p=((-1, 1, 0), (-1, -1, 0), (1, -1, 0), (1, 1, 0), (-1, 1, 0))) BaseLoc = mc.spaceLocator(p=(0,0,0), name='%s_RIF_Baseloc'%joint.rsplit('_', 2)[0])[0] AimLoc = mc.spaceLocator(p=(0,0,0), name='%s_RIF_aimLoc'%joint.rsplit('_', 2)[0])[0] grp = mc.group(TempCircle, TempLine, BaseLoc, AimLoc, name='%s_RIF_G'%joint.rsplit('_', 2)[0]) #- set Temp Curve Template for temp in (TempCircle, TempLine): shape = mc.listRelatives(temp, s=True, path=True) mc.setAttr('%s.ove'%shape[0], 1) mc.setAttr('%s.ovdt'%shape[0], 1) #- lock attributes for attr in mc.listAttr(BaseLoc, k=True): if attr in ('translateX', 'translateY'): continue mc.setAttr('%s.%s'%(BaseLoc, attr), l=True, k=False) #- limit Translate mc.transformLimits(BaseLoc, tx=(-1, 1), ty=(-1, 1), etx=(True, True), ety=(True, True)) mc.pointConstraint(AimLoc, BaseLoc, skip='z') #- add Atributes for attr in ('x', 'y', 'ypxp', 'ypxn', 'ynxp', 'ynxn', 'up', 'down', 'left', 'right'): mc.addAttr(grp, sn=attr, k=True) #- comp connections #- 1 mc.connectAttr('%s.tx'%BaseLoc, '%s.x'%grp) mc.connectAttr('%s.ty'%BaseLoc, '%s.y'%grp) #- 2 Values = ('ypxp', 0.707,0.707), ('ypxn', -0.707,0.707), ('ynxp', 0.707,-0.707), ('ynxn', -0.707,-0.707) for Attr, x, y in Values: node = mc.createNode('multDoubleLinear') mc.setDrivenKeyframe('%s.i1'%node, cd='%s.tx'%BaseLoc, dv=0, v=0, itt='linear', ott='linear') mc.setDrivenKeyframe('%s.i1'%node, cd='%s.tx'%BaseLoc, dv=x, v=1, itt='linear', ott='linear') mc.setDrivenKeyframe('%s.i2'%node, cd='%s.ty'%BaseLoc, dv=0, v=0, itt='linear', ott='linear') mc.setDrivenKeyframe('%s.i2'%node, cd='%s.ty'%BaseLoc, dv=y, v=1, itt='linear', ott='linear') mc.connectAttr('%s.o'%node, '%s.%s'%(grp, Attr)) #- 3 # to line 71 #- match Position mc.delete(mc.parentConstraint(joint, grp)) JntChildren = mc.listRelatives(joint, c=True, path=True, type='joint') if not JntChildren:return mc.delete(mc.aimConstraint(JntChildren, grp, aim=(0,0,1), u=(0,1,0))) mc.delete(mc.pointConstraint(JntChildren, AimLoc)) mc.parentConstraint(joint, AimLoc, mo=True) #- match Scale startPosi = mc.xform(grp, q=True, ws=True, rp=True) endPosi = mc.xform(AimLoc , q=True, ws=True, rp=True) Dis = math.sqrt((startPosi[0] - endPosi[0]) ** 2 + (startPosi[1] - endPosi[1]) ** 2 + (startPosi[2] - endPosi[2]) ** 2) mc.setAttr(grp + '.sx', Dis) mc.setAttr(grp + '.sy', Dis) mc.setAttr(grp + '.sz', Dis) #- connect line 52 Expstrings = '\ $Ah = %s.ty;\n\ $Aw = %s.tx;\n\ $C = %s;\n\ %s.%s = clamp(0, 180, 90 - acos($Ah / $C) * 180 / 3.14159265359);\n\ %s.%s = clamp(-180, 0, 90 - acos($Ah / $C) * 180 / 3.14159265359);\n\ %s.%s = clamp(0, 180, 90 - acos($Aw / $C) * 180 / 3.14159265359);\n\ %s.%s = clamp(-180, 0, 90 - acos($Aw / $C) * 180 / 3.14159265359);\n\ '%(BaseLoc, BaseLoc, mc.getAttr('%s.tz'%AimLoc), grp, 'up', grp, 'down', grp, 'left', grp, 'right') mc.expression(s=Expstrings) #--------------------------------------------------------------------------------------- # connect attbutes to prefs_grp if not mc.objExists('prefs_grp'):return typ = joint.rsplit('_', 2)[0] mc.addAttr('prefs_grp', sn=typ, k=True) mc.setAttr('prefs_grp.' + typ, l=True) for Attr in mc.listAttr(grp, ud=True): mc.addAttr('prefs_grp', sn=typ + Attr, k=True) mc.connectAttr('%s.%s'%(grp, Attr), 'prefs_grp.%s%s'%(typ , Attr)) return grp, AimLoc
def limit(limitTransforms=[{'node': None, 'attr': None, 'min': None, 'max': None}]): """ @type limitTransforms: dictionary in a list @param limitTransforms: specify a dictionary in a list which includes the object name, one attribute, the min and the max keys storing the defined limitation values. (ie: [{'node': 'C_bla_CTL', 'attr': 'tx', 'min': -2, 'max': 2}]) """ assert limitTransforms, "limit: Please specify valid keys and values!" for d in limitTransforms: assert isinstance(limitTransforms, list), ("limit: Please specify a list!") node = None attr = None mini = None maxi = None for i in d.items(): if i[0] == 'node': node = i[1] elif i[0] == 'attr': attr = i[1] elif i[0] == 'min': mini = i[1] elif i[0] == 'max': maxi = i[1] else: raise Exception("limit: Please define 'node','attr'," "'min','max' as keys!") if not node[1]: if attr[1]: raise Exception("limit: Please specify a node!") else: if not attr[1]: raise Exception("limit: Please specify attribute!") if not isinstance(attr[1], str): raise Exception("limit: Please specify only one" " valid attribute per dictionary!") if node: #--- enable the transforms enableMin = False enableMax = False if mini is not None: enableMin = True if maxi is not None: enableMax = True #--- specify default limitation values if attr.startswith('t'): if mini is None: mini = -1 if maxi is None: maxi = 1 elif attr.startswith('r'): if mini is None: mini = -45 if maxi is None: maxi = 45 if attr.startswith('s'): if mini is None: mini = -1 if maxi is None: maxi = 1 #--- set translation if attr == 'tx': cmds.transformLimits(node, etx=(enableMin, enableMax), tx=(mini, maxi)) elif attr == 'ty': cmds.transformLimits(node, ety=(enableMin, enableMax), ty=(mini, maxi)) elif attr == 'tz': cmds.transformLimits(node, etz=(enableMin, enableMax), tz=(mini, maxi)) #--- set rotation if attr == 'rx': cmds.transformLimits(node, erx=(enableMin, enableMax), rx=(mini, maxi)) elif attr == 'ry': cmds.transformLimits(node, ery=(enableMin, enableMax), ry=(mini, maxi)) elif attr == 'rz': cmds.transformLimits(node, erz=(enableMin, enableMax), rz=(mini, maxi)) #--- set scale if attr == 'sx': cmds.transformLimits(node, esx=(enableMin, enableMax), sx=(mini, maxi)) elif attr == 'sy': cmds.transformLimits(node, esy=(enableMin, enableMax), sy=(mini, maxi)) elif attr == 'sz': cmds.transformLimits(node, esz=(enableMin, enableMax), sz=(mini, maxi))
def build(self): FKIKCtl = '%s_legFkIk_ctl_%s' % (self.locus,self.count) IKCtl = '%s_legIk_ctl_%s' % (self.locus,self.count) footBallPivot = '%s_footPivotBallLegBackIk_org_%s' % (self.locus,self.count) footRoll = '%s_footRollLegBackIk_org_%s' % (self.locus,self.count) ballIkCtl = '%s_legBallIk_ctl_%s' % (self.locus,self.count) legikhandle = '%s_legIk_hdl_%s' % (self.locus,self.count) cmds.rename('%s_footPivotBallLegIk_org_%s' % (self.locus,self.count),footBallPivot) cmds.rename('%s_footRollLegIk_org_%s' % (self.locus,self.count),footRoll) cmds.ikHandle(legikhandle,e=True,sol='ikSpringSolver') # add attrs cmds.addAttr(FKIKCtl,ln='feetControls',at='double',min=0,max=1,dv=1) cmds.setAttr('%s.feetControls' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='swivel',at='double',dv=0) cmds.setAttr('%s.swivel' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='toeRoll',at='double',dv=0) cmds.setAttr('%s.toeRoll' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='toeSwivel',at='double',dv=0) cmds.setAttr('%s.toeSwivel' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='toeTwist',at='double',dv=0) cmds.setAttr('%s.toeTwist' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='heelBank',at='double',dv=0) cmds.setAttr('%s.heelBank' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='heelSwivel',at='double',dv=0) cmds.setAttr('%s.heelSwivel' % FKIKCtl,e=True,k=True) cmds.addAttr(FKIKCtl,ln='kneeWeighting',at='double',min=0,max=1,dv=0.5) cmds.setAttr('%s.kneeWeighting' % FKIKCtl,e=True,k=True) negate = 1 if self.locus == 'L': negate = -1 elif self.locus == 'C': # fix the outer and inner foot bind joints if the foot is centered cmds.rename('L_%sInnerfoot_bnd_%s' % (self.namespace,self.count),'C_%sInnerfoot_bnd_%s' % (self.namespace,self.count)) cmds.rename('R_%sOuterfoot_bnd_%s' % (self.namespace,self.count),'C_%sOuterfoot_bnd_%s' % (self.namespace,self.count)) # constrain to the rig cmds.connectAttr('C_main_loc_0Shape.worldPosition','%s_%s_mod_%s.translate' % (self.locus,self.namespace,self.count)) cmds.orientConstraint('C_main_loc_0','%s_%s_mod_%s' % (self.locus,self.namespace,self.count),mo=True) cmds.parentConstraint('%s_%sAnkle_bnd_%s' % (self.locus,self.namespace,self.count),'%s_%sFKIK_org_%s' % (self.locus,self.namespace,self.count),mo=True) cmds.parentConstraint('C_root_bnd_0','%s_%sCtl_org_%s' % (self.locus,self.namespace,self.count),mo=True) hiprootloc = cmds.spaceLocator(n='%s_hipRootFollow_loc_%s' % (self.locus,self.count))[0] cmds.parent(hiprootloc,'%s_%sHip_bnd_%s' % (self.locus,self.namespace,self.count),r=True) cmds.parent(hiprootloc,'C_root_bnd_0') cmds.setAttr('%s.v' % hiprootloc,0) cmds.orientConstraint(hiprootloc,'%s_%sAim_org_%s' % (self.locus,self.namespace,self.count),mo=True) cmds.pointConstraint(hiprootloc,'%s_%sHipIk_jth_%s' % (self.locus,self.namespace,self.count),mo=True) cmds.setAttr('%s_%sHipIk_org_%s.inheritsTransform' % (self.locus,self.namespace,self.count),0) ankle = cmds.duplicate('%s_%sAnkleIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_%sAnkleIk_tmp_%s' % (self.locus,self.namespace,self.count),po=True)[0] cmds.parent(ankle,w=True) posA = cmds.xform('%s_%sKnee_bnd_%s' % (self.locus,self.namespace,self.count),q=True,ws=True,t=True) posB = cmds.xform('comp_%s%s:R_knee_ctl_0' % (self.namespace,self.count),q=True,ws=True,t=True) if round(posA[0]) != round(posB[0]*negate) or round(posA[1]) != round(posB[1]) or round(posA[2]) != round(posB[2]): # reposition the pole vector control - this messes up the joint orientations cmds.delete('%s_poleLeg_prc_%s' % (self.locus,self.count)) pos = cmds.xform('comp_%s%s:R_poleVector_loc_0' % (self.namespace,self.count),q=True,ws=True,t=True) cmds.move(pos[0]*negate,pos[1],pos[2],'%s_poleLegStatic_tgt_%s' % (self.locus,self.count),ws=True) cmds.move(pos[0]*negate,pos[1],pos[2],'%s_poleLeg_org_%s' % (self.locus,self.count),ws=True) pConst = cmds.parentConstraint(IKCtl,'%s_poleLegStatic_tgt_%s' % (self.locus,self.count),'%s_poleLeg_org_%s' % (self.locus,self.count),mo=True)[0] rev = cmds.createNode('reverse') cmds.connectAttr('%s_poleLeg_ctl_%s.follow' % (self.locus,self.count),'%s.%sW0' % (pConst,IKCtl)) cmds.connectAttr('%s_poleLeg_ctl_%s.follow' % (self.locus,self.count),'%s.inputX' % rev) cmds.connectAttr('%s.outputX' % rev,'%s.%s_poleLegStatic_tgt_%sW1' % (pConst,self.locus,self.count)) cmds.setAttr('%s.interpType' % pConst,2) # re create IK chain to set correct the messed up orientations cmds.select(cl=True) hock = cmds.joint(n='%s_%sHockIk_tmp_%s' % (self.locus,self.namespace,self.count)) knee = cmds.joint(n='%s_%sKneeIk_tmp_%s' % (self.locus,self.namespace,self.count)) cmds.parent(knee,'%s_%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count),r=True) cmds.setAttr('%s.rx' % knee,180) cmds.parent(knee,'%s_%sHipIk_jnt_%s' % (self.locus,self.namespace,self.count)) cmds.parent(hock,'%s_%sHockIk_jnt_%s' % (self.locus,self.namespace,self.count),r=True) cmds.setAttr('%s.rx' % hock,180) cmds.parent(hock,knee) cmds.parent(ankle,hock) plug = cmds.listConnections('%s_%sKneeIk_jnt_%s.tx' % (self.locus,self.namespace,self.count),s=True,d=False,p=True)[0] cmds.connectAttr(plug,'%s.tx' % knee) plug = cmds.listConnections('%s_%sHockIk_jnt_%s.tx' % (self.locus,self.namespace,self.count),s=True,d=False,p=True)[0] cmds.connectAttr(plug,'%s.tx' % hock) cmds.delete(legikhandle) cmds.parent('%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),w=True) cmds.parent('%s_fKAlignedLegIk_org_%s' % (self.locus,self.count),w=True) cmds.parent('%s_poleLeg_ann_%s' % (self.locus,self.count),w=True,r=True) cmds.delete('%s_%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count)) cmds.makeIdentity('%s_%sHipIk_jnt_%s' % (self.locus,self.namespace,self.count),a=True,r=True) cmds.joint('%s_%sHipIk_jnt_%s' % (self.locus,self.namespace,self.count),e=True,spa=True,ch=True) legikhandle = cmds.ikHandle(sj='%s_%sHipIk_jnt_%s' % (self.locus,self.namespace,self.count),ee=ankle,sol='ikSpringSolver')[0] cmds.poleVectorConstraint('%s_poleLeg_ctl_%s' % (self.locus,self.count),legikhandle) cmds.parent('%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),ankle) cmds.parent('%s_fKAlignedLegIk_org_%s' % (self.locus,self.count),ankle) cmds.parent(legikhandle,footBallPivot) handle = cmds.ikHandle(sj=ankle,ee='%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),sol='ikSCsolver')[0] cmds.parent(handle,footBallPivot) cmds.setAttr('%s.v' % handle,0) # rename tmp joints and reconstrain bind joints cmds.rename(knee,'%s_%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count)) cmds.rename(hock,'%s_%sHockIk_jnt_%s' % (self.locus,self.namespace,self.count)) cmds.rename(ankle,'%s_%sAnkleIk_jnt_%s' % (self.locus,self.namespace,self.count)) pConst = cmds.parentConstraint('%s_%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sKnee_bnd_%s' % (self.locus,self.namespace,self.count),mo=False)[0] cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%s_%sKneeIk_jnt_%sW1' % (pConst,self.locus,self.namespace,self.count)) pConst = cmds.parentConstraint('%s_%sHockIk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sHock_bnd_%s' % (self.locus,self.namespace,self.count),mo=False)[0] cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%s_%sHockIk_jnt_%sW1' % (pConst,self.locus,self.namespace,self.count)) pConst = cmds.parentConstraint('%s_%sAnkleIk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sAnkle_bnd_%s' % (self.locus,self.namespace,self.count),mo=False)[0] cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%s_%sAnkleIk_jnt_%sW1' % (pConst,self.locus,self.namespace,self.count)) # fix the fk chain orientations knee = '%s_%sKneeFk_ctj_%s' % (self.locus,self.namespace,self.count) hock = '%s_%sHockFk_ctj_%s' % (self.locus,self.namespace,self.count) ankle = '%s_%sAnkleFk_ctj_%s' % (self.locus,self.namespace,self.count) cmds.parent(knee,w=True) cmds.parent(hock,w=True) cmds.parent(ankle,w=True) cmds.delete(cmds.aimConstraint(hock,knee,wut='object',wuo='comp_%s%s:%s_poleVector_loc_0' % (self.namespace,self.count,self.locus),aim=[negate,0,0],u=[0,negate,0])) cmds.delete(cmds.aimConstraint(ankle,hock,wut='object',wuo='comp_%s%s:%s_poleVector_loc_0' % (self.namespace,self.count,self.locus),aim=[negate,0,0],u=[0,negate,0])) cmds.parent(ankle,'%s_%sHockFk_ctl_%s' % (self.locus,self.namespace,self.count)) cmds.parent(hock,'%s_%sKneeFk_ctl_%s' % (self.locus,self.namespace,self.count)) cmds.parent(knee,'%s_%sHipFk_jnt_%s' % (self.locus,self.namespace,self.count)) # connect fkikctl attrs to ik foot ctl attrs cmds.connectAttr('%s.swivel' % FKIKCtl,'%s.swivel' % IKCtl) cmds.setAttr('%s.swivel' % IKCtl,l=True,k=False) cmds.setAttr('%s.toe' % IKCtl,l=True,k=False) cmds.setAttr('%s.rollAngle' % IKCtl,l=True,k=False) # add control to IK feet controls to hide other controls cmds.connectAttr('%s.feetControls' % FKIKCtl,'%s_legToeIk_ctl_%sShape.v' % (self.locus,self.count)) cmds.connectAttr('%s.feetControls' % FKIKCtl,'%s_legHeelIk_ctl_%sShape.v' % (self.locus,self.count)) # add follow to ik feet controls cmds.addAttr(IKCtl,ln='follow',at='double',min=0,max=1,dv=0) cmds.setAttr('%s.follow' % IKCtl,e=True,k=True) pConst = cmds.parentConstraint('%s_%sIK_org_%s' % (self.locus,self.namespace,self.count),'C_root_bnd_0','%s_legIk_org_%s' % (self.locus,self.count),mo=True)[0] rev = cmds.createNode('reverse') cmds.connectAttr('%s.follow' % IKCtl,'%s.C_root_bnd_0W1' % pConst) cmds.connectAttr('%s.follow' % IKCtl,'%s.inputX' % rev) cmds.connectAttr('%s.outputX' % rev,'%s.%s_%sIK_org_%sW0' % (pConst,self.locus,self.namespace,self.count)) cmds.setAttr('%s.interpType' % pConst, 2) # reconnect foot roll # cmds.parent(footBallPivot, '%s_legBallIk_cth_%s' % (self.locus,self.count)) # cmds.setAttr('%s.roll' % IKCtl,l=True,cb=False,k=False) # cmds.connectAttr('%s.swivel' % IKCtl,'%s_legToeIk_cth_%s.ry' % (self.locus,self.count)) # cmds.disconnectAttr('%s.swivel' % IKCtl,'%s_poleAimLeg_amc_%s.offsetX' % (self.locus,self.count)) # add foot bank off = cmds.group(em=True,n='%s_%sFootBankInIk_off_%s' % (self.locus,self.namespace,self.count)) inn = cmds.group(em=True,n='%s_%sFootBankInIk_org_%s' % (self.locus,self.namespace,self.count)) cmds.delete(cmds.parentConstraint('%s_%sInnerfoot_bnd_%s' % (self.locus,self.namespace,self.count),inn,mo=False)) cmds.delete(cmds.parentConstraint('%s_%sInnerfoot_bnd_%s' % (self.locus,self.namespace,self.count),off,mo=False)) out = cmds.group(em=True,n='%s_%sFootBankOutIk_org_%s' % (self.locus,self.namespace,self.count)) cmds.delete(cmds.parentConstraint('%s_%sOuterfoot_bnd_%s' % (self.locus,self.namespace,self.count),out,mo=False)) cmds.parent(off,IKCtl) cmds.parent(inn,off) cmds.parent(out,inn) cmds.parent(footRoll,out) cmds.setAttr('%s.rz' % ballIkCtl,l=False,k=True) cmds.transformLimits(ballIkCtl,erz=[0,0]) cond = cmds.createNode('condition') mult = cmds.createNode('multiplyDivide') cmds.connectAttr('%s.rz' % ballIkCtl,'%s.firstTerm' % cond) cmds.connectAttr('%s.rz' % ballIkCtl,'%s.colorIfTrueR' % cond) if self.locus == 'R': cmds.setAttr('%s.operation' % cond,2) else: cmds.setAttr('%s.operation' % cond,4) cmds.setAttr('%s.colorIfFalseR' % cond,0) cmds.setAttr('%s.input2X' % mult,negate) cmds.connectAttr('%s.outColorR' % cond,'%s.input1X' % mult) cmds.connectAttr('%s.outputX' % mult,'%s.rx' % out) cond = cmds.createNode('condition') mult = cmds.createNode('multiplyDivide') cmds.connectAttr('%s.rz' % ballIkCtl,'%s.firstTerm' % cond) cmds.connectAttr('%s.rz' % ballIkCtl,'%s.colorIfTrueR' % cond) if self.locus == 'R': cmds.setAttr('%s.operation' % cond,4) else: cmds.setAttr('%s.operation' % cond,2) cmds.setAttr('%s.colorIfFalseR' % cond,0) cmds.setAttr('%s.input2X' % mult,negate) cmds.connectAttr('%s.outColorR' % cond,'%s.input1X' % mult) cmds.connectAttr('%s.outputX' % mult,'%s.rx' % inn) dup = cmds.duplicate(ballIkCtl,po=True,n='%s_legBallIk_dmy_%s' % (self.locus,self.count))[0] cmds.parent(footBallPivot,dup) cmds.connectAttr('%s.rx' % ballIkCtl,'%s.rx' % dup) # reorient the toes and midfoot controls # toe = cmds.circle(ch=False)[0] # midfoot = cmds.circle(ch=False)[0] # new = [toe,midfoot] # old = ['%s_%sToesFk_ctl_%s' % (self.locus,self.namespace,self.count),'%s_%sMidfootFk_ctl_%s' % (self.locus,self.namespace,self.count)] # # i = 0 # while True: # if i == len(new): break # # a = new[i] # b = old[i] # p = cmds.listRelatives(b,p=True)[0] # gp = cmds.listRelatives(p,p=True)[0] # pos = cmds.xform(b,q=True,ws=True,t=True) # cmds.move(pos[0],pos[1],pos[2],a,ws=True) # cmds.parent(b,a) # cmds.parent(p,w=True) # cmds.setAttr('%s.rotate' % p,0,0,0) # cmds.parent(p,gp) # cmds.parent(a,p) # shpA = cmds.listRelatives(a,s=True)[0] # cmds.setAttr('%s.overrideEnabled' % shpA,1) # shpB = cmds.listRelatives(b,s=True)[0] # plg = cmds.listConnections('%s.v' % shpB,s=True,d=False,p=True) # if plg: # cmds.disconnectAttr(plg[0],'%s.v' % shpB) # cmds.connectAttr(plg[0],'%s.v' % shpA) # cmds.setAttr('%s.v' % shpB,0) # cmds.setAttr('%s.v' % a,l=True,k=False) # cmds.connectAttr('%s.sx' % a, '%s.sz' % b) # cmds.connectAttr('%s.sy' % a, '%s.sy' % b) # cmds.connectAttr('%s.sz' % a, '%s.sx' % b) # cmds.rename(b,string.replace(b,'_ctl_','_dmy_')) # cmds.rename(shpA,'%sShape' % b) # cmds.rename(a,b) # i = i + 1 # rerig foot roll to incorporate the toe joint # cmds.delete('%s_%sToesEnd_bnd_%s' % (self.locus,self.namespace,self.count)) # cmds.parent('%s_legToe_bnd_%s' % (self.locus,self.count),'%s_%sToes_bnd_%s' % (self.locus,self.namespace,self.count)) # # create toes IK joint # toesIKJoint = cmds.joint(n='%s_%sToesIk_jnt_%s' % (self.locus,self.namespace,self.count)) # pos = cmds.xform('%s_%sToes_bnd_%s' % (self.locus,self.namespace,self.count),q=True,ws=True,t=True) # cmds.move(pos[0],pos[1],pos[2],toesIKJoint,ws=True) # cmds.parent(toesIKJoint,'%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count)) # cmds.makeIdentity(toesIKJoint,a=True,r=True,jo=True) # cmds.parent('%s_legToeIk_jnt_%s' % (self.locus,self.count),toesIKJoint) # # new rotational groups # org = cmds.group(em=True,n='%s_%sToesPivotBallLegIK_org_%s' % (self.locus,self.namespace,self.count)) # cmds.parent(org,'%s_legBallIk_cth_%s' % (self.locus,self.count),r=True) # cmds.move(pos[0],pos[1],pos[2],org,ws=True) # cmds.parent(footBallPivot,org) # # toe ik handles # #cmds.delete('%s_liftToeLegToeIk_org_%s' % (self.locus,self.count)) # toesIK = cmds.ikHandle(sj='%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),ee=toesIKJoint)[0] # toeIK = cmds.ikHandle(sj=toesIKJoint,ee='%s_legToeIk_jnt_%s' % (self.locus,self.count))[0] # cmds.setAttr('%s.v' % toesIK,0) # cmds.setAttr('%s.v' % toeIK,0) # connect roll # clamp = cmds.createNode('clamp') # mult = cmds.createNode('multiplyDivide') # cmds.setAttr('%s.maxR' % clamp,99999) # cmds.setAttr('%s.input2X' % mult,0.25) # cmds.connectAttr('%s.rx' % ballIkCtl,'%s.inputR' % clamp) # cmds.connectAttr('%s.outputR' % clamp,'%s.input1X' % mult) # cmds.connectAttr('%s.outputX' % mult,'%s_%sToesPivotBallLegIK_org_%s.rx' % (self.locus,self.namespace,self.count)) # cmds.connectAttr('%s.outputR' % clamp,'%s.rx' % footBallPivot) # clamp = cmds.createNode('clamp') # #avg = cmds.createNode('plusMinusAverage') # plug = cmds.listConnections('%s_rollLegHeelIk_org_%s.rx' % (self.locus,self.count),s=True,d=False,p=True)[0] # cmds.setAttr('%s.minR' % clamp,-99999) # cmds.connectAttr('%s.rx' % ballIkCtl,'%s.inputR' % clamp) # cmds.disconnectAttr(plug,'%s_rollLegHeelIk_org_%s.rx' % (self.locus,self.count)) # cmds.connectAttr('%s.outputR' % clamp,'%s_rollLegHeelIk_org_%s.rx' % (self.locus,self.count)) # cmds.connectAttr('%s.heelBank' % FKIKCtl,'%s.rz' % footBallPivot) # cmds.connectAttr('%s.heelBank' % FKIKCtl,'%s_%sToesPivotBallLegIK_org_%s.rz' % (self.locus,self.namespace,self.count)) # #cmds.setAttr('%s.input1D[0]' % avg,cmds.getAttr('%s.ry' % footBallPivot)) # #cmds.connectAttr('%s.heelSwivel' % FKIKCtl,'%s.input1D[1]' % avg) # #cmds.connectAttr('%s.output1D' % avg, '%s.ry' % footBallPivot) # children = cmds.listRelatives(footBallPivot,c=True) # cmds.parent(children,w=True) # cmds.connectAttr('%s.heelSwivel' % FKIKCtl,'%s.ry' % footBallPivot) # cmds.parent(children,footBallPivot) # cmds.connectAttr('%s.heelSwivel' % FKIKCtl,'%s_%sToesPivotBallLegIK_org_%s.ry' % (self.locus,self.namespace,self.count)) # # create 'fk' controls # toesctl = cmds.circle(ch=False,n='%s_%sToesIk_ctl_%s' % (self.locus,self.namespace,self.count))[0] # toescth = cmds.group(n='%s_%sToesIk_cth_%s' % (self.locus,self.namespace,self.count)) # toesctg = cmds.group(n='%s_%sToesIk_ctg_%s' % (self.locus,self.namespace,self.count)) # toesdummyoff = cmds.group(n='%s_%sToesIkDummy_off_%s' % (self.locus,self.namespace,self.count),em=True) # toesdummyorg = cmds.group(n='%s_%sToesIkDummy_org_%s' % (self.locus,self.namespace,self.count)) # #cmds.move(pos[0],pos[1],pos[2],toesctg,ws=True) # #cmds.move(pos[0],pos[1],pos[2],toesdummyorg,ws=True) # cmds.delete(cmds.parentConstraint('%s_%sToesIk_jnt_%s' % (self.locus,self.namespace,self.count),toesctg,mo=False)) # cmds.delete(cmds.parentConstraint('%s_%sToesIk_jnt_%s' % (self.locus,self.namespace,self.count),toesdummyorg,mo=False)) # # pos = cmds.xform('%s_%sMidfoot_bnd_%s' % (self.locus,self.namespace,self.count),q=True,ws=True,t=True) # footctl = cmds.circle(ch=False,n='%s_%sMidfootIk_ctl_%s' % (self.locus,self.namespace,self.count))[0] # footcth = cmds.group(n='%s_%sMidfootIk_cth_%s' % (self.locus,self.namespace,self.count)) # footctg = cmds.group(n='%s_%sMidfootIk_ctg_%s' % (self.locus,self.namespace,self.count)) # footdummyoff = cmds.group(n='%s_%sMidfootIkDummy_off_%s' % (self.locus,self.namespace,self.count),em=True) # footdummyorg = cmds.group(n='%s_%sMidfootIkDummy_org_%s' % (self.locus,self.namespace,self.count)) # footdummymain = cmds.group(n='%s_%sFootIkDummy_org_%s' % (self.locus,self.namespace,self.count)) # #cmds.move(pos[0],pos[1],pos[2],footctg,ws=True) # #cmds.move(pos[0],pos[1],pos[2],footdummyorg,ws=True) # cmds.delete(cmds.parentConstraint('%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),footctg,mo=False)) # cmds.delete(cmds.parentConstraint('%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),footdummymain,mo=False)) # # cmds.setAttr('%s.tx' % toesctl,l=True,k=False) # cmds.setAttr('%s.ty' % toesctl,l=True,k=False) # cmds.setAttr('%s.tz' % toesctl,l=True,k=False) # cmds.setAttr('%s.sx' % toesctl,l=True,k=False) # cmds.setAttr('%s.sy' % toesctl,l=True,k=False) # cmds.setAttr('%s.sz' % toesctl,l=True,k=False) # cmds.setAttr('%s.v' % toesctl,l=True,k=False) # cmds.setAttr('%s.tx' % footctl,l=True,k=False) # cmds.setAttr('%s.ty' % footctl,l=True,k=False) # cmds.setAttr('%s.tz' % footctl,l=True,k=False) # cmds.setAttr('%s.sx' % footctl,l=True,k=False) # cmds.setAttr('%s.sy' % footctl,l=True,k=False) # cmds.setAttr('%s.sz' % footctl,l=True,k=False) # cmds.setAttr('%s.v' % footctl,l=True,k=False) # # cmds.parent(toesctg,footctl) # cmds.parent(toesdummyorg,footdummyoff) # #cmds.parent(footdummyorg,footdummymain) # cmds.parent(footctg,'%s_legToeIk_ctl_%s' % (self.locus,self.count)) # cmds.parent(footdummymain,'%s_legToeIk_ctl_%s' % (self.locus,self.count)) # cmds.parent(toeIK,toesdummyoff) # cmds.parent(toesIK,footdummyoff) # # ##################################### # ##################################### # ##################################### # ##################################### # cmds.connectAttr('%s.rotate' % toesctl,'%s.rotate' % toesdummyoff) # cmds.connectAttr('%s.rotate' % footctl,'%s.rotate' % footdummyoff) # #cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % toescth) # #cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % footcth) # #cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % toesdummyorg) # #cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % footdummyorg) # cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rz' % toescth) # cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rz' % footcth) # cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rz' % toesdummyorg) # cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rz' % footdummyorg) # cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % toescth) # cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % footcth) # cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % toesdummyorg) # cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % footdummyorg) # #cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % toescth) # #cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % footcth) # #cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % toesdummyorg) # #cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % footdummyorg) # cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rx' % toescth) # cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rx' % footcth) # cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rx' % toesdummyorg) # cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rx' % footdummyorg) # # cmds.parent(toesctg,footctl) # # cmds.parent(toesdummyorg,footdummyoff) # # cmds.parent(footctg,'%s_legToeIk_ctl_%s' % (self.locus,self.count)) # # cmds.parent(footdummyorg,'%s_legToeIk_ctl_%s' % (self.locus,self.count)) # # cmds.parent(toeIK,toesdummyoff) # # cmds.parent(toesIK,footdummyoff) # # cmds.connectAttr('%s.rotate' % toesctl,'%s.rotate' % toesdummyoff) # # cmds.connectAttr('%s.rotate' % footctl,'%s.rotate' % footdummyoff) # # cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % toescth) # # cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % footcth) # # cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % toesdummyorg) # # cmds.connectAttr('%s.toeRoll' % FKIKCtl,'%s.rx' % footdummyorg) # # cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % toescth) # # cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % footcth) # # cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % toesdummyorg) # # cmds.connectAttr('%s.toeSwivel' % FKIKCtl,'%s.ry' % footdummyorg) # # cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % toescth) # # cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % footcth) # # cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % toesdummyorg) # # cmds.connectAttr('%s.toeTwist' % FKIKCtl,'%s.rz' % footdummyorg) # # cmds.parentConstraint('%s_%sAnkleIk_jnt_%s' % (self.locus,self.namespace,self.count),footctg,mo=True) # cmds.parentConstraint('%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),toesctg,mo=True) # # connect shape visibility # shp = cmds.listRelatives(toesctl,s=True)[0] # cmds.connectAttr('%s.feetControls' % FKIKCtl,'%s.v' % shp) # shp = cmds.listRelatives(footctl,s=True)[0] # cmds.connectAttr('%s.feetControls' % FKIKCtl,'%s.v' % shp) # # move original fk controls # cmds.parent('%s_%sMidfootFk_ctj_%s' % (self.locus,self.namespace,self.count),'%s_%sAnkleFk_jnt_%s' % (self.locus,self.namespace,self.count)) # cmds.parent('%s_%sToesFk_ctj_%s' % (self.locus,self.namespace,self.count),'%s_%sMidfootFk_jnt_%s' % (self.locus,self.namespace,self.count)) # cmds.delete('%s_to%sMidfootFk_jth_%s' % (self.locus,self.namespace,self.count),'%s_to%sAnkleFk_jth_%s' % (self.locus,self.namespace,self.count)) # # constrain bind joints # for constraint in cmds.listConnections('%s_%sMidfoot_bnd_%s' % (self.locus,self.namespace,self.count),s=True,d=False): # if cmds.objectType(constraint,isAType='constraint'): # cmds.delete(constraint) # break # pConst = cmds.parentConstraint('%s_%sMidfootFk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sMidfootIk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sMidfoot_bnd_%s' % (self.locus,self.namespace,self.count))[0] # rev = cmds.createNode('reverse') # cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.inputX' % rev) # cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%s_%sMidfootIk_jnt_%sW1' % (pConst,self.locus,self.namespace,self.count)) # cmds.connectAttr('%s.outputX' % rev,'%s.%s_%sMidfootFk_jnt_%sW0' % (pConst,self.locus,self.namespace,self.count)) # # for constraint in cmds.listConnections('%s_%sToes_bnd_%s' % (self.locus,self.namespace,self.count),s=True,d=False): # if cmds.objectType(constraint,isAType='constraint'): # cmds.delete(constraint) # break # pConst = cmds.parentConstraint('%s_%sToesFk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sToesIk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sToes_bnd_%s' % (self.locus,self.namespace,self.count))[0] # cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%s_%sToesIk_jnt_%sW1' % (pConst,self.locus,self.namespace,self.count)) # cmds.connectAttr('%s.outputX' % rev,'%s.%s_%sToesFk_jnt_%sW0' % (pConst,self.locus,self.namespace,self.count)) # replace the ik control with split translational/rotational controls # ctg = cmds.duplicate('%s_%sAnkleFk_cth_%s' % (self.locus,self.namespace,self.count),n='%s_%sAnkleIk_ctg_%s' % (self.locus,self.namespace,self.count),po=True)[0] # cth = cmds.duplicate('%s_%sAnkleFk_cth_%s' % (self.locus,self.namespace,self.count),n='%s_%sAnkleIk_cth_%s' % (self.locus,self.namespace,self.count),po=True)[0] # ctl = cmds.duplicate('%s_%sAnkleFk_ctl_%s' % (self.locus,self.namespace,self.count),n='%s_%sAnkleIk_ctl_%s' % (self.locus,self.namespace,self.count))[0] # cmds.delete(cmds.listRelatives(ctl,type='joint',f=True)) # cmds.parent(ctl,cth) # cmds.parent(cth,ctg) # cmds.parent(ctg,IKCtl) # cmds.makeIdentity(ctg,a=True,r=True) # cmds.parent('%s_%sFootBankInIk_org_%s' % (self.locus,self.namespace,self.count),ctl) # create dummy ik leg to constrain the ankle rotation controls # hip = cmds.duplicate('%s_%sHipIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_%sHipIk_dmy_%s' % (self.locus,self.namespace,self.count),po=True)[0] # knee = cmds.duplicate('%s_%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_%sKneeIk_dmy_%s' % (self.locus,self.namespace,self.count),po=True)[0] # hock = cmds.duplicate('%s_%sHockIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_%sHockIk_dmy_%s' % (self.locus,self.namespace,self.count),po=True)[0] # ankle = cmds.duplicate('%s_%sAnkleIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_%sAnkleIk_dmy_%s' % (self.locus,self.namespace,self.count),po=True)[0] # cmds.parent(ankle,hock) # cmds.parent(hock,knee) # cmds.parent(knee,hip) # dummyikhandle = cmds.ikHandle(sj=hip,ee=ankle,sol='ikSpringSolver')[0] # cmds.parent(dummyikhandle,IKCtl) # cmds.poleVectorConstraint('%s_poleLeg_ctl_%s' % (self.locus,self.count),dummyikhandle) # setup the global orientation blending of the ik ankle rotational control # pConst = cmds.parentConstraint(ankle,IKCtl,ctg,st=['x','y','z'],mo=True)[0] # rev = cmds.createNode('reverse') # cmds.connectAttr('%s.Global' % ctl,'%s.%sW1' % (pConst,IKCtl)) # cmds.connectAttr('%s.Global' % ctl,'%s.inputX' % rev) # cmds.connectAttr('%s.outputX' % rev,'%s.%sW0' % (pConst,ankle)) # cmds.setAttr('%s.interpType' % pConst,2) # cmds.setAttr('%s.Global' % ctl,1) # lower the foot roll controls to the ground plane cmds.setAttr('%s_rollLegBallIk_org_%s.tx' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegBallIk_org_%s.ty' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegBallIk_org_%s.tz' % (self.locus,self.count),l=False,k=True) cmds.parent('%s_rollLegBallIk_org_%s' % (self.locus,self.count),w=True) #cmds.parent('%s_%sMidfootIk_ctg_%s' % (self.locus,self.namespace,self.count),w=True) #cmds.parent('%s_%sFootIkDummy_org_%s' % (self.locus,self.namespace,self.count),w=True) cmds.setAttr('%s_rollLegHeelIk_org_%s.tx' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegHeelIk_org_%s.ty' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegHeelIk_org_%s.tz' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegToeIk_org_%s.tx' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegToeIk_org_%s.ty' % (self.locus,self.count),l=False,k=True) cmds.setAttr('%s_rollLegToeIk_org_%s.tz' % (self.locus,self.count),l=False,k=True) cmds.parent('%s_legToeIk_hdl_%s' % (self.locus,self.count),w=True) cmds.move(0,0,0,'%s_rollLegHeelIk_org_%s' % (self.locus,self.count),ws=True,x=False,y=True,z=False) cmds.move(0,0,0,'%s_rollLegToeIk_org_%s' % (self.locus,self.count),ws=True,x=False,y=True,z=False) cmds.parent('%s_rollLegBallIk_org_%s' % (self.locus,self.count),'%s_legToeIk_ctl_%s' % (self.locus,self.count)) cmds.parent('%s_legToeIk_hdl_%s' % (self.locus,self.count),'%s_liftToeLegToeIk_org_%s' % (self.locus,self.count)) #cmds.parent('%s_%sMidfootIk_ctg_%s' % (self.locus,self.namespace,self.count),'%s_legToeIk_ctl_%s' % (self.locus,self.count)) #cmds.parent('%s_%sFootIkDummy_org_%s' % (self.locus,self.namespace,self.count),'%s_legToeIk_ctl_%s' % (self.locus,self.count)) # fix the IK partial stretching if not cmds.listConnections('%s_%sAnkleIk_jnt_%s.tx' % (self.locus,self.namespace,self.count),s=True,d=False): mult = cmds.createNode('multiplyDivide') x = cmds.getAttr('%s_%sAnkleIk_jnt_%s.tx' % (self.locus,self.namespace,self.count)) cmds.setAttr('%s.input1X' % mult,x) cmds.connectAttr('%s_messureDivLegIk_mdn_%s.outputX' % (self.locus,self.count),'%s.input2X' % mult) cmds.connectAttr('%s.outputX' % mult,'%s_%sAnkleIk_jnt_%s.tx' % (self.locus,self.namespace,self.count)) # create the secondary IK structure ctl = cmds.circle(n='%s_%sHipIk_ctl_%s' % (self.locus,self.namespace,self.count),d=3,s=8,ch=False,nr=[1,0,0])[0] cth = cmds.group(n='%s_%sHipIk_cth_%s' % (self.locus,self.namespace,self.count)) ctg = cmds.group(n='%s_%sHipIk_ctg_%s' % (self.locus,self.namespace,self.count)) org = cmds.group(n='%s_secondaryIk_org_%s' % (self.locus,self.count)) loc = cmds.spaceLocator(n='%s_%sKneeIk_loc_%s' % (self.locus,self.namespace,self.count))[0] cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.v' % org) cmds.setAttr('%s.tx' % ctl,l=True,k=False) cmds.setAttr('%s.ty' % ctl,l=True,k=False) cmds.setAttr('%s.tz' % ctl,l=True,k=False) cmds.setAttr('%s.rx' % ctl,l=True,k=False) cmds.setAttr('%s.sx' % ctl,l=True,k=False) cmds.setAttr('%s.sy' % ctl,l=True,k=False) cmds.setAttr('%s.sz' % ctl,l=True,k=False) cmds.setAttr('%s.v' % ctl,l=True,k=False) # position hip control cmds.parent(org,'%s_%sIK_org_%s' % (self.locus,self.namespace,self.count)) cmds.parentConstraint('%s_%sHipIk_jnt_%s' % (self.locus,self.namespace,self.count),ctg,mo=False) # position knee locator cmds.parent(loc,ctl,r=True) cmds.connectAttr('%s_%sKneeIk_jnt_%s.tx' % (self.locus,self.namespace,self.count),'%s.tx' % loc) cmds.setAttr('%s.v' % loc,0) # duplicate knee knee = cmds.duplicate('%s_%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_secondary%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count),po=True)[0] hock = cmds.duplicate('%s_%sHockIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_secondary%sHockIk_jnt_%s' % (self.locus,self.namespace,self.count),po=True)[0] ankle = cmds.duplicate('%s_%sAnkleIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_secondary%sAnkleIk_jnt_%s' % (self.locus,self.namespace,self.count),po=True)[0] if not cmds.listConnections('%s.drawOverride' % knee,s=True,d=False): cmds.connectAttr('controlJointLayer.drawInfo','%s.drawOverride' % knee) cmds.connectAttr('controlJointLayer.drawInfo','%s.drawOverride' % hock) cmds.connectAttr('%s_%sHockIk_jnt_%s.tx' % (self.locus,self.namespace,self.count),'%s.tx' % hock) cmds.parent(ankle,hock) cmds.parent(hock,knee) cmds.parent('%s_poleLeg_ann_%s' % (self.locus,self.count),knee,r=True) cmds.parent(knee,org) # create IK handle = cmds.ikHandle(sj=knee,ee=ankle,sol='ikRPsolver')[0] cmds.parent(handle,footBallPivot) cmds.poleVectorConstraint('%s_poleLeg_ctl_%s' % (self.locus,self.count),handle)[0] cmds.pointConstraint(loc,knee) cmds.setAttr('%s.v' % handle,0) posA = cmds.xform('%s_%sHockIk_jnt_%s' % (self.locus,self.namespace,self.count),q=True,ws=True,t=True) posB = cmds.xform(hock,q=True,ws=True,t=True) if round(posA[0]) != round(posB[0]) or round(posA[1]) != round(posB[1]) or round(posA[2]) != round(posB[2]): cmds.setAttr('%s.twist' % handle,180) # setup the IK hip twist hipTwistIK = cmds.duplicate('%s_%sHipIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_twist%sHipIk_jnt_%s' % (self.locus,self.namespace,self.count),po=True)[0] kneeTwistIK = cmds.duplicate('%s_%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_twist%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count),po=True)[0] cmds.parent(kneeTwistIK,hipTwistIK) cmds.parent(hipTwistIK,'%s_%sAim_org_%s' % (self.locus,self.namespace,self.count)) handle = cmds.ikHandle(sj=hipTwistIK,ee=kneeTwistIK,sol='ikRPsolver')[0] cmds.parent(handle,ctl) cmds.poleVectorConstraint(hiprootloc,handle)[0] cmds.pointConstraint(hiprootloc,hipTwistIK) cmds.setAttr('%s.v' % handle,0) # mult = cmds.createNode('multiplyDivide') # cmds.connectAttr('C_root_bnd_0.rx','%s.input1X' % mult) # cmds.connectAttr('%s.outputX' % mult,'%s.twist' % handle) # cmds.setAttr('%s.input2X' % mult,-1) twistLocAIK = cmds.spaceLocator(n='%s_%sHipIkTwistA_loc_%s' % (self.locus,self.namespace,self.count))[0] twistLocBIK = cmds.spaceLocator(n='%s_%sHipIkTwistB_loc_%s' % (self.locus,self.namespace,self.count))[0] cmds.parent(twistLocAIK,twistLocBIK,hipTwistIK,r=True) pConst = cmds.pointConstraint(hipTwistIK,kneeTwistIK,twistLocAIK,mo=False)[0] oConst = cmds.orientConstraint(ctl,hipTwistIK,twistLocAIK,mo=False)[0] cmds.setAttr('%s.interpType' % oConst,2) cmds.setAttr('%s.%sW0' % (pConst,hipTwistIK),0.65) cmds.setAttr('%s.%sW1' % (pConst,kneeTwistIK),0.35) cmds.setAttr('%s.%sW0' % (oConst,ctl),0.35) cmds.setAttr('%s.%sW1' % (oConst,hipTwistIK),0.65) pConst = cmds.pointConstraint(hipTwistIK,kneeTwistIK,twistLocBIK,mo=False)[0] oConst = cmds.orientConstraint(ctl,hipTwistIK,twistLocBIK,mo=False)[0] cmds.setAttr('%s.interpType' % oConst,2) cmds.setAttr('%s.%sW0' % (pConst,hipTwistIK),0.35) cmds.setAttr('%s.%sW1' % (pConst,kneeTwistIK),0.65) cmds.setAttr('%s.%sW0' % (oConst,ctl),0.65) cmds.setAttr('%s.%sW1' % (oConst,hipTwistIK),0.35) # setup the FK hip twist hipTwistFK = cmds.duplicate('%s_%sHipIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_twist%sHipFk_jnt_%s' % (self.locus,self.namespace,self.count),po=True)[0] kneeTwistFK = cmds.duplicate('%s_%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count),n='%s_twist%sKneeFk_jnt_%s' % (self.locus,self.namespace,self.count),po=True)[0] cmds.parent(kneeTwistFK,hipTwistFK) cmds.parent(hipTwistFK,'%s_%sAim_org_%s' % (self.locus,self.namespace,self.count)) handle = cmds.ikHandle(sj=hipTwistFK,ee=kneeTwistFK,sol='ikRPsolver')[0] cmds.parent(handle,'%s_%sHipFk_ctl_%s' % (self.locus,self.namespace,self.count)) cmds.poleVectorConstraint('%s_%sHipFk_ctl_%s' % (self.locus,self.namespace,self.count),handle)[0] cmds.pointConstraint('%s_%sHipFk_ctl_%s' % (self.locus,self.namespace,self.count),hipTwistFK) cmds.setAttr('%s.v' % handle,0) mult = cmds.createNode('multiplyDivide') cmds.connectAttr('C_root_bnd_0.rx','%s.input1X' % mult) cmds.connectAttr('%s.outputX' % mult,'%s.twist' % handle) cmds.setAttr('%s.input2X' % mult,-1) twistLocAFK = cmds.spaceLocator(n='%s_%sHipFkTwistA_loc_%s' % (self.locus,self.namespace,self.count))[0] twistLocBFK = cmds.spaceLocator(n='%s_%sHipFkTwistB_loc_%s' % (self.locus,self.namespace,self.count))[0] cmds.parent(twistLocAFK,twistLocBFK,hipTwistFK,r=True) pConst = cmds.pointConstraint(hipTwistFK,kneeTwistFK,twistLocAFK,mo=False)[0] oConst = cmds.orientConstraint('%s_%sHipFk_ctl_%s' % (self.locus,self.namespace,self.count),hipTwistFK,twistLocAFK,mo=False)[0] cmds.setAttr('%s.interpType' % oConst,2) cmds.setAttr('%s.%sW0' % (pConst,hipTwistFK),0.65) cmds.setAttr('%s.%sW1' % (pConst,kneeTwistFK),0.35) cmds.setAttr('%s.%s_%sHipFk_ctl_%sW0' % (oConst,self.locus,self.namespace,self.count),0.35) cmds.setAttr('%s.%sW1' % (oConst,hipTwistFK),0.65) pConst = cmds.pointConstraint(hipTwistFK,kneeTwistFK,twistLocBFK,mo=False)[0] oConst = cmds.orientConstraint('%s_%sHipFk_ctl_%s' % (self.locus,self.namespace,self.count),hipTwistFK,twistLocBFK,mo=False)[0] cmds.setAttr('%s.interpType' % oConst,2) cmds.setAttr('%s.%sW0' % (pConst,hipTwistFK),0.35) cmds.setAttr('%s.%sW1' % (pConst,kneeTwistFK),0.65) cmds.setAttr('%s.%s_%sHipFk_ctl_%sW0' % (oConst,self.locus,self.namespace,self.count),0.65) cmds.setAttr('%s.%sW1' % (oConst,hipTwistFK),0.35) # re-constrain the bind joints cmds.delete('%s_%sHip_prc_%s' % (self.locus,self.namespace,self.count)) pConst = cmds.parentConstraint(hipTwistFK,hipTwistIK,'%s_%sHip_bnd_%s' % (self.locus,self.namespace,self.count),mo=True)[0] cmds.setAttr('%s.interpType' % pConst,2) cmds.connectAttr('%s_blendLegFkIk_rev_%s.outputX' % (self.locus,self.count),'%s.%sW0' % (pConst,hipTwistFK)) cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%sW1' % (pConst,hipTwistIK)) cmds.delete('%s_%sKnee_prc_%s' % (self.locus,self.namespace,self.count)) pConst = cmds.parentConstraint('%s_%sKneeFk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_secondary%sKneeIk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sKnee_bnd_%s' % (self.locus,self.namespace,self.count))[0] cmds.setAttr('%s.interpType' % pConst,2) cmds.connectAttr('%s_blendLegFkIk_rev_%s.outputX' % (self.locus,self.count),'%s.%s_%sKneeFk_jnt_%sW0' % (pConst,self.locus,self.namespace,self.count)) cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%s_secondary%sKneeIk_jnt_%sW1' % (pConst,self.locus,self.namespace,self.count)) cmds.delete('%s_%sHock_prc_%s' % (self.locus,self.namespace,self.count)) pConst = cmds.parentConstraint('%s_%sHockFk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_secondary%sHockIk_jnt_%s' % (self.locus,self.namespace,self.count),'%s_%sHock_bnd_%s' % (self.locus,self.namespace,self.count))[0] cmds.setAttr('%s.interpType' % pConst,2) cmds.connectAttr('%s_blendLegFkIk_rev_%s.outputX' % (self.locus,self.count),'%s.%s_%sHockFk_jnt_%sW0' % (pConst,self.locus,self.namespace,self.count)) cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%s_secondary%sHockIk_jnt_%sW1' % (pConst,self.locus,self.namespace,self.count)) # create the hip twist bind joints cmds.select(cl=True) jnt = cmds.joint(n='%s_%sHipA_bnd_%s' % (self.locus,self.namespace,self.count)) cmds.parent(jnt,'%s_%sHip_bnd_%s' % (self.locus,self.namespace,self.count)) pConst = cmds.parentConstraint(twistLocAFK,twistLocAIK,jnt,mo=False)[0] cmds.setAttr('%s.interpType' % pConst,2) cmds.connectAttr('%s_blendLegFkIk_rev_%s.outputX' % (self.locus,self.count),'%s.%sW0' % (pConst,twistLocAFK)) cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%sW1' % (pConst,twistLocAIK)) cmds.select(cl=True) jnt = cmds.joint(n='%s_%sHipB_bnd_%s' % (self.locus,self.namespace,self.count)) cmds.parent(jnt,'%s_%sHipA_bnd_%s' % (self.locus,self.namespace,self.count)) pConst = cmds.parentConstraint(twistLocBFK,twistLocBIK,jnt,mo=False)[0] cmds.setAttr('%s.interpType' % pConst,2) cmds.connectAttr('%s_blendLegFkIk_rev_%s.outputX' % (self.locus,self.count),'%s.%sW0' % (pConst,twistLocBFK)) cmds.connectAttr('%s.FKIKBlend' % FKIKCtl,'%s.%sW1' % (pConst,twistLocBIK)) cmds.parent('%s_%sKnee_bnd_%s' % (self.locus,self.namespace,self.count),jnt) # lock attributes for attr in ['sx','sy','sz']: cmds.setAttr('%s_%sHipFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) cmds.setAttr('%s_%sKneeFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) cmds.setAttr('%s_%sHockFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) cmds.setAttr('%s_%sAnkleFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) #cmds.setAttr('%s_%sAnkleIk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) cmds.setAttr('%s_%sMidfootFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) #cmds.setAttr('%s_%sToesFk_ctl_%s.%s' % (self.locus,self.namespace,self.count,attr),l=True,k=False) # create toe locator loc = cmds.spaceLocator(n='%s_toe_loc_%s' % (self.locus,self.count))[0] cmds.parent(loc,'%s_legToe_bnd_%s' % (self.locus,self.count),r=True) cmds.setAttr('%s.v' % loc,0) avg = cmds.createNode('plusMinusAverage') cmds.connectAttr('%s.kneeWeighting' % FKIKCtl,'%s.springAngleBias[0].springAngleBias_FloatValue' % legikhandle) cmds.connectAttr('%s.kneeWeighting' % FKIKCtl,'%s.input1D[1]' % avg) cmds.setAttr('%s.input1D[0]' % avg,1) cmds.setAttr('%s.operation' % avg,2) cmds.connectAttr('%s.output1D' % avg,'%s.springAngleBias[1].springAngleBias_FloatValue' % legikhandle) if cmds.getAttr('%s.v' % legikhandle): cmds.setAttr('%s.v' % legikhandle,0) # cmds.connectAttr('%s.kneeWeighting' % FKIKCtl,'%s.springAngleBias[0].springAngleBias_FloatValue' % dummyikhandle) # cmds.setAttr('%s.input1D[0]' % avg,1) # cmds.setAttr('%s.operation' % avg,2) # cmds.connectAttr('%s.output1D' % avg,'%s.springAngleBias[1].springAngleBias_FloatValue' % dummyikhandle) # cmds.setAttr('%s.v' % dummyikhandle,0)
def setTranslateLimits(ctrl, tx=True, ty=True, tz=True): """ """ if (tx): cmds.transformLimits(ctrl, tx=(-1.0, 1.0), etx=(1, 1)) if (ty): cmds.transformLimits(ctrl, ty=(-1.0, 1.0), ety=(1, 1)) if (tz): cmds.transformLimits(ctrl, tz=(-1.0, 1.0), etz=(1, 1))
def sqCreateStickyLipsCtrlAttr(self, *args): if not cmds.objExists(self.optionCtrl): cmds.circle(name=self.optionCtrl, constructionHistory=False) cmds.addAttr(self.optionCtrl, longName='stickyLips', attributeType='bool') cmds.setAttr(self.optionCtrl+'.stickyLips', edit=True, keyable=True) for i in range(0, self.maxIter): cmds.addAttr(self.optionCtrl, longName="stickyLipsWireLocator"+str(i), attributeType='float', keyable=False) for i in range(0, self.maxIter): for wireNode in self.wireNodeList: cmds.connectAttr(self.optionCtrl+".stickyLipsWireLocator"+str(i), wireNode+".wireLocatorEnvelope["+str(i)+"]") slTextCurve = cmds.textCurves(ch=False, font="Arial|w400|h-08", text="StickyLips", name="StickyLips_Label_Txt")[0] if "Shape" in slTextCurve: slTextCurve = cmds.rename(slTextCurve, slTextCurve[:slTextCurve.find("Shape")]) t = 0 slCharTransformList = cmds.listRelatives(slTextCurve, children=True, type="transform") for charTransform in slCharTransformList: txValue = cmds.getAttr(charTransform+".tx") sLTextShapeList = cmds.listRelatives(charTransform, allDescendents=True, type="nurbsCurve") for i, textShape in enumerate(sLTextShapeList): textShape = cmds.rename(textShape, "StickyLips_Txt_"+str(t)+"Shape") cmds.parent(textShape, slTextCurve, shape=True, relative=True) cmds.move(txValue, 0, 0, textShape+".cv[:]", relative=True) t = t+1 cmds.delete(charTransform) cmds.setAttr(slTextCurve+".translateX", -0.1) cmds.setAttr(slTextCurve+".translateY", 0.25) cmds.setAttr(slTextCurve+".scaleX", 0.1) cmds.setAttr(slTextCurve+".scaleY", 0.1) cmds.setAttr(slTextCurve+".scaleZ", 0.1) cmds.setAttr(slTextCurve+".template", 1) cmds.makeIdentity(slTextCurve, apply=True) sideNameList = ["L", "R"] for side in sideNameList: bg = cmds.circle(name=side+"_StickyLips_Bg", normal=(0,0,1), radius=1, degree=1, sections=4, constructionHistory=False)[0] cmds.setAttr(bg+".rotateZ", 45) cmds.setAttr(bg+".translateX", 0.5) cmds.makeIdentity(bg, apply=True) cmds.setAttr(bg+".scaleX", 0.85) cmds.setAttr(bg+".scaleY", 0.15) cmds.makeIdentity(bg, apply=True) cmds.setAttr(bg+".template", 1) self.sliderCtrl = cmds.circle(name=side+"_StickyLips_Ctrl", normal=(0,0,1), radius=0.1, degree=3, constructionHistory=False)[0] attrToHideList = ['ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'] for attr in attrToHideList: cmds.setAttr(self.sliderCtrl+"."+attr, edit=True, lock=True, keyable=False) cmds.transformLimits(self.sliderCtrl, translationX=(0,1), enableTranslationX=(1,1)) distPos = 1.0 / self.maxIter for i in range(0, self.maxIter): lPosA = (i * distPos) lPosB = (lPosA + distPos) rPosB = 1 - (i * distPos) rPosA = (rPosB - distPos) if i > 0: lPosA = lPosA - (distPos*0.33) rPosA = rPosA - (distPos*0.33) cmds.setDrivenKeyframe(self.optionCtrl, attribute="stickyLipsWireLocator"+str(i), currentDriver=sideNameList[0]+"_StickyLips_Ctrl.translateX", driverValue=lPosA, value=0, inTangentType="linear", outTangentType="linear") cmds.setDrivenKeyframe(self.optionCtrl, attribute="stickyLipsWireLocator"+str(i), currentDriver=sideNameList[0]+"_StickyLips_Ctrl.translateX", driverValue=lPosB, value=1, inTangentType="linear", outTangentType="linear") cmds.setDrivenKeyframe(self.optionCtrl, attribute="stickyLipsWireLocator"+str(i), currentDriver=sideNameList[1]+"_StickyLips_Ctrl.translateX", driverValue=rPosA, value=0, inTangentType="linear", outTangentType="linear") cmds.setDrivenKeyframe(self.optionCtrl, attribute="stickyLipsWireLocator"+str(i), currentDriver=sideNameList[1]+"_StickyLips_Ctrl.translateX", driverValue=rPosB, value=1, inTangentType="linear", outTangentType="linear") lSliderGrp = cmds.group(sideNameList[0]+"_StickyLips_Ctrl", sideNameList[0]+"_StickyLips_Bg", name=sideNameList[0]+"_StickyLips_Ctrl_Grp") rSliderGrp = cmds.group(sideNameList[1]+"_StickyLips_Ctrl", sideNameList[1]+"_StickyLips_Bg", name=sideNameList[1]+"_StickyLips_Ctrl_Grp") cmds.setAttr(rSliderGrp+".rotateZ", 180) cmds.setAttr(rSliderGrp+".translateY", -0.25) sliderGrp = cmds.group(lSliderGrp, rSliderGrp, slTextCurve, name="StickyLips_Ctrl_Grp")
def createLidCtl(self, miNum): """ create sub controller for the control panel """ for updn in self.lrUplow: ctlP = updn + "Ctrl0" kids = cmds.listRelatives(ctlP, ad=True, type ='transform') if kids: cmds.delete(kids) cntCtlP = cmds.duplicate(ctlP, po =True, n = updn + 'CntCtlP') cmds.parent(cntCtlP[0],ctlP) cntCtl = cmds.circle(n = updn + "Center", ch=False, o =True, nr =(0, 0, 1), r = 0.1) cntCtl[0] cmds.parent(cntCtl[0], cntCtlP[0]) cmds.setAttr(cntCtl[0] + ".overrideEnabled", 1) cmds.setAttr(cntCtl[0] + "Shape.overrideEnabled", 1) cmds.setAttr(cntCtl[0] + "Shape.overrideColor", 9) cmds.setAttr(cntCtl[0] + '.translate', 0,0,0) cmds.transformLimits(cntCtl, tx =(-1, 1), etx=(True, True)) cmds.transformLimits(cntCtl, ty =(-1, 1), ety=(True, True)) inCornerP = cmds.duplicate(cntCtlP , n = updn + 'InCornerP', rc =True) cmds.setAttr(inCornerP[0] +'.tx', -1) inTemp = cmds.listRelatives(inCornerP[0], c=True, type ='transform') inCorner = cmds.rename(inTemp[0], updn + 'InCorner') cmds.setAttr(inCorner +'.scale', .8, .8, .8) cmds.transformLimits(inCorner, tx =(-.25, .25), etx=(True, True)) cmds.transformLimits(inCorner, ty =(-1, 1), ety=(True, True)) outCornerP = cmds.duplicate(cntCtlP , n = updn + 'OutCornerP', rc=True) cmds.setAttr(outCornerP[0] +'.tx', 1) outTemp = cmds.listRelatives(outCornerP[0], c=True, type ='transform') outCorner = cmds.rename(outTemp[0], updn + 'OutCorner') cmds.setAttr(outCorner +'.scale', .8, .8, .8) cmds.transformLimits(outCorner, tx =(-.25, .25), etx=(True, True)) cmds.transformLimits(outCorner, ty =(-1, 1), ety=(True, True)) attTemp = ['scaleX','scaleY','scaleZ', 'rotateX','rotateY','rotateZ', 'tz', 'visibility' ] for x in attTemp: cmds.setAttr(cntCtl[0] +"."+ x, lock = True, keyable = False, channelBox =False) cmds.setAttr(inCorner +"."+ x, lock = True, keyable = False, channelBox =False) cmds.setAttr(outCorner+"."+ x, lock = True, keyable = False, channelBox =False) for i in range(0, miNum): detailCtl = cmds.spaceLocator(n = updn + 'Detail' + str(i+1).zfill(2)) detailCtlP = cmds.group(em =True, n = updn + 'Detail'+ str(i+1).zfill(2) + 'P') cmds.parent(detailCtl[0], detailCtlP) cmds.parent(detailCtlP, ctlP) cmds.setAttr(detailCtl[0] +".overrideEnabled", 1) cmds.setAttr(detailCtl[0] +"Shape.overrideEnabled", 1) cmds.setAttr(detailCtl[0]+"Shape.overrideColor", 20) increment = 2.0 /(miNum-1) cmds.setAttr(detailCtlP + ".tx", increment*i - 1.0) cmds.setAttr(detailCtlP + ".ty", 0) cmds.setAttr(detailCtlP + ".tz", 0) cmds.xform(detailCtl, r =True, s =(0.1, 0.1, 0.1)) cmds.transformLimits(detailCtl , tx =(-.25, .25), etx=(True, True)) cmds.transformLimits(detailCtl , ty =(-.5, .5), ety=(True, True)) for y in attTemp: cmds.setAttr(detailCtl[0] +"."+ y, lock = True, keyable = False, channelBox =False)