def postSetupRig(self): ''' clean up section for the setup rig ''' if common.isValid('%s.displayAxis' % self.masterGuide) or common.isValid(self.masterGuide) != True: return True #create attributes and lock/hide attrs on top nodes as well as masterGuide control displayAttr = attribute.addAttr(self.masterGuide, 'displayAxis', attrType = 'enum', defValue = 'off:on') attribute.lockAndHide(['r','t','s','v'], [self.setupRigGrp, self.skeletonGrp,self.guidesGrp, common.getParent(self.masterGuide)]) attribute.lockAndHide('v', self.masterGuide) #resize guide controls for guide in self.getGuides(): cmds.setAttr('%s.radius' % common.getShapes(guide, 0), self.controlScale * .5) #resize masterGuide control control.scaleShape(self.masterGuide, scale = [self.controlScale * 2, self.controlScale * 2, self.controlScale * 2]) #declaring skeleton joints skeletonJnts = self.getSkeletonJnts() #connect joints to the attributes on the masterGuide control for jnt in skeletonJnts: if cmds.objExists(jnt): attribute.connect(displayAttr , '%s.displayLocalAxis' % jnt) common.setDisplayType(jnt, 'reference') #parent all constraints to guides group if self.setupConstraints: cmds.parent(self.setupConstraints, self.guidesGrp) #Put the build attributes onto setup rigs ''' cmds.addAttr(self.setupRigGrp, ln = 'kwargs', dt = "string") cmds.setAttr('%s.kwargs' % self.setupRigGrp, str(self._buildAttrs), type = "string") ''' attribute.copy('displayAxis', self.masterGuide, self.name(), reverseConnect = True) #parent setup under puppet node self._puppetNode.addChild(self.setupRigGrp) if self.parentHook: if cmds.objExists(self.parentHook): displayLine = control.displayLine(self.masterGuide, self.parentHook, name = self.masterGuide.replace('_%s' % common.GUIDES, '_%s' % common.CURVE)) cmds.parent(displayLine, self.guidesGrp) #set build args on puppet node attrs = dict() for attr in self.attributes(): attrs[attr.name()] = attr.value() self.puppetNode.storeArgs(**attrs)
def rig(self): ''' this is the build section for the rig. ''' if common.isValid(self.controlsGrp): return True if not self._puppetNode: self.runSetupRig() #resolve build arguments if not self.puppetNode == self.name(): self.puppetNode = puppet.Puppet(self.name()) self.puppetNode.restoreArgs(self) cmds.createNode('transform', n = self.rigGrp) cmds.createNode('transform', n = self.jointsGrp) cmds.createNode('transform', n = self.controlsGrp) cmds.parent([self.jointsGrp, self.controlsGrp], self.rigGrp) if not self.skinClusterJnts: self.skinClusterJnts.extend(self.getSkeletonJnts()) for jnt in self.skinClusterJnts: if cmds.objExists(jnt): common.setDisplayType(jnt, 'normal') #get parent jnt parent = cmds.listRelatives(jnt, p = True) if parent: if parent[0] == self.skeletonGrp: cmds.parent(jnt, self.jointsGrp) #delete the setup rig group cmds.delete(self.setupRigGrp) for jnt in self.skinClusterJnts: if cmds.objExists(jnt): #turn display axis off cmds.setAttr('%s.displayLocalAxis' % jnt, 0) #take the rotations of the joint and make the orientation joint.rotateToOrient(jnt)