Example #1
0
 def changeJointNumber(self, enteredNJoints, *args):
     """ Edit the number of joints in the guide.
     """
     utils.useDefaultRenderLayer()
     # get the number of joints entered by user:
     if enteredNJoints == 0:
         try:
             self.enteredNJoints = cmds.intField(self.nJointsIF, query=True, value=True)
         except:
             return
     else:
         self.enteredNJoints = enteredNJoints
     # get the number of joints existing:
     self.currentNJoints = cmds.getAttr(self.moduleGrp+".nJoints")
     # start analisys the difference between values:
     if self.enteredNJoints != self.currentNJoints:
         # unparent temporarely the Ends:
         self.cvEndJoint = self.guideName+"_JointEnd"
         cmds.parent(self.cvEndJoint, world=True)
         self.jGuideEnd = (self.guideName+"_JGuideEnd")
         cmds.parent(self.jGuideEnd, world=True)
         # verify if the nJoints is greather or less than the current
         if self.enteredNJoints > self.currentNJoints:
             for n in range(self.currentNJoints+1, self.enteredNJoints+1):
                 # create another N cvJointLoc:
                 self.cvJointLoc = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc"+str(n), r=0.2, d=1, guide=True)
                 # set its nJoint value as n:
                 cmds.setAttr(self.cvJointLoc+".nJoint", n)
                 # parent it to the lastGuide:
                 cmds.parent(self.cvJointLoc, self.guideName+"_JointLoc"+str(n-1), relative=True)
                 cmds.setAttr(self.cvJointLoc+".translateZ", 1)
                 cmds.setAttr(self.cvJointLoc+".rotateY", -1)
                 # create a joint to use like an arrowLine:
                 self.jGuide = cmds.joint(name=self.guideName+"_JGuide"+str(n), radius=0.001)
                 cmds.setAttr(self.jGuide+".template", 1)
                 cmds.parent(self.jGuide, self.guideName+"_JGuide"+str(n-1))
                 self.ctrls.directConnect(self.cvJointLoc, self.jGuide, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz'])
         elif self.enteredNJoints < self.currentNJoints:
             # re-define cvEndJoint:
             self.cvJointLoc = self.guideName+"_JointLoc"+str(self.enteredNJoints)
             self.cvEndJoint = self.guideName+"_JointEnd"
             self.jGuide = self.guideName+"_JGuide"+str(self.enteredNJoints)
             # re-parent the children guides:
             childrenGuideBellowList = utils.getGuideChildrenList(self.cvJointLoc)
             if childrenGuideBellowList:
                 for childGuide in childrenGuideBellowList:
                     cmds.parent(childGuide, self.cvJointLoc)
             # delete difference of nJoints:
             cmds.delete(self.guideName+"_JointLoc"+str(self.enteredNJoints+1))
             cmds.delete(self.guideName+"_JGuide"+str(self.enteredNJoints+1))
         # re-parent cvEndJoint:
         cmds.parent(self.cvEndJoint, self.cvJointLoc)
         cmds.setAttr(self.cvEndJoint+".tz", 1.3)
         cmds.parent(self.jGuideEnd, self.jGuide)
         # actualise the nJoints in the moduleGrp:
         cmds.setAttr(self.moduleGrp+".nJoints", self.enteredNJoints)
         self.currentNJoints = self.enteredNJoints
         # re-build the preview mirror:
         Layout.LayoutClass.createPreviewMirror(self)
     cmds.select(self.moduleGrp)
Example #2
0
 def rigModule(self, *args):
     """ The fun part of the module, just read the values from editModuleLayout and create the rig for this guide.
         Delete the moduleLayout, guide and namespaces for this module.
     """
     # verify integrity of the guideModule:
     if self.verifyGuideModuleIntegrity():
         try:
             # clear selected module layout:
             self.clearSelectedModuleLayout()
         except:
             pass
         
         # unPinGuides before Rig them:
         self.ctrls.unPinGuide(self.moduleGrp)
         
         # RIG:
         utils.useDefaultRenderLayer()
         
         # get the radius value to controls:
         if cmds.objExists(self.radiusCtrl):
             self.ctrlRadius = utils.getCtrlRadius(self.radiusCtrl)
         else:
             self.ctrlRadius = 1
             
         # get curve degree:
         self.curveDegree = cmds.getAttr(self.moduleGrp+".degree")
         
         # unparent all guide modules child:
         childrenList = cmds.listRelatives(self.moduleGrp, allDescendents=True, type='transform')
         if childrenList:
             for child in childrenList:
                 if cmds.objExists(child+".guideBase") and cmds.getAttr(child+".guideBase") == 1:
                     cmds.parent(child, world=True)
         
         # just edit customName and prefix:
         self.customName = cmds.getAttr(self.moduleGrp+".customName")
         if self.customName != "" and self.customName != " " and self.customName != "_" and self.customName != None:
             allTransformList = cmds.ls(selection=False, type="transform")
             if allTransformList:
                 for transform in allTransformList:
                     if cmds.objExists(transform+".dpAR_name"):
                         currentName = cmds.getAttr(transform+".dpAR_name")
                         if currentName == self.customName:
                             self.customName = self.customName + "1"
             self.userGuideName = self.customName
         prefix = cmds.textField("prefixTextField", query=True, text=True)
         if prefix != "" and prefix != " " and prefix != "_" and prefix != None:
             if prefix[len(prefix)-1] != "_":
                 prefix = prefix + "_"
             self.userGuideName = prefix + self.userGuideName
         cmds.select(clear=True)
Example #3
0
 def createGuide(self, *args):
     """ Create the elements to Guide module in the scene, like controls, etc...
     """
     # GUIDE:
     utils.useDefaultRenderLayer()
     # create guide base (moduleGrp):
     guideBaseList = self.ctrls.cvBaseGuide(self.moduleGrp, r=2)
     self.moduleGrp = guideBaseList[0]
     self.radiusCtrl = guideBaseList[1]
     # add attributes to be read when rigging module:
     baseBooleanAttrList = ['guideBase', 'mirrorEnable', 'displayAnnotation']
     for baseBooleanAttr in baseBooleanAttrList:
         cmds.addAttr(self.moduleGrp, longName=baseBooleanAttr, attributeType='bool')
         cmds.setAttr(self.moduleGrp+"."+baseBooleanAttr, 1)
     
     baseIntegerAttrList = ['guideColor']
     for baseIntegerAttr in baseIntegerAttrList:
         cmds.addAttr(self.moduleGrp, longName=baseIntegerAttr, attributeType='long')
     
     baseStringAttrList  = ['moduleNamespace', 'customName', 'mirrorAxis', 'mirrorName', 'mirrorNameList', 'hookNode', 'moduleInstanceInfo', 'guideObjectInfo', 'rigType', 'dpARVersion']
     for baseStringAttr in baseStringAttrList:
         cmds.addAttr(self.moduleGrp, longName=baseStringAttr, dataType='string')
     cmds.setAttr(self.moduleGrp+".mirrorAxis", "off", type='string')
     cmds.setAttr(self.moduleGrp+".mirrorName", self.langDic[self.langName]['p002_left']+' --> '+self.langDic[self.langName]['p003_right'], type='string')
     cmds.setAttr(self.moduleGrp+".hookNode", "_Grp", type='string')
     cmds.setAttr(self.moduleGrp+".moduleInstanceInfo", self, type='string')
     cmds.setAttr(self.moduleGrp+".guideObjectInfo", self.dpUIinst.guide, type='string')
     cmds.setAttr(self.moduleGrp+".rigType", self.rigType, type='string')
     cmds.setAttr(self.moduleGrp+".dpARVersion", self.dpUIinst.dpARVersion, type='string')
     
     baseFloatAttrList = ['shapeSize']
     for baseFloatAttr in baseFloatAttrList:
         cmds.addAttr(self.moduleGrp, longName=baseFloatAttr, attributeType='float')
     cmds.setAttr(self.moduleGrp+".shapeSize", 1)
     
     baseIntegerAttrList = ['degree']
     for baseIntAttr in baseIntegerAttrList:
         cmds.addAttr(self.moduleGrp, longName=baseIntAttr, attributeType='short')
     cmds.setAttr(self.moduleGrp+".degree", self.dpUIinst.degreeOption)
     
     # create annotation to this module:
     self.annotation = cmds.annotate( self.moduleGrp, tx=self.moduleGrp, point=(0,2,0) )
     self.annotation = cmds.listRelatives(self.annotation, parent=True)[0]
     self.annotation = cmds.rename(self.annotation, self.moduleGrp+"_Ant")
     cmds.parent(self.annotation, self.moduleGrp)
     cmds.setAttr(self.annotation+'.text', self.moduleGrp[self.moduleGrp.find("__")+2:self.moduleGrp.rfind(":")], type='string')
     cmds.setAttr(self.annotation+'.template', 1)
Example #4
0
 def rigModule(self, *args):
     """ The fun part of the module, just read the values from editModuleLayout and create the rig for this guide.
         Delete the moduleLayout, guide and namespaces for this module.
     """
     # verify integrity of the guideModule:
     if self.verifyGuideModuleIntegrity():
         try:
             # clear selected module layout:
             self.clearSelectedModuleLayout()
         except:
             pass
         
         # RIG:
         utils.useDefaultRenderLayer()
         
         # get the radius value to controls:
         if cmds.objExists(self.radiusCtrl):
             self.ctrlRadius = utils.getCtrlRadius(self.radiusCtrl)
         else:
             self.ctrlRadius = 1
         
         # unparent all guide modules child:
         childrenList = cmds.listRelatives(self.moduleGrp, allDescendents=True, type='transform')
         if childrenList:
             for child in childrenList:
                 if cmds.objExists(child+".guideBase") and cmds.getAttr(child+".guideBase") == 1:
                     cmds.parent(child, world=True)
         
         # just edit customName and prefix:
         self.customName = cmds.getAttr(self.moduleGrp+".customName")
         if self.customName != "" and self.customName != " " and self.customName != "_" and self.customName != None:
             allTransformList = cmds.ls(selection=False, type="transform")
             if allTransformList:
                 for transform in allTransformList:
                     if cmds.objExists(transform+".dpAR_name"):
                         currentName = cmds.getAttr(transform+".dpAR_name")
                         if currentName == self.customName:
                             self.customName = self.customName + "1"
             self.userGuideName = self.customName
         prefix = cmds.textField("prefixTextField", query=True, text=True)
         if prefix != "" and prefix != " " and prefix != "_" and prefix != None:
             if prefix[len(prefix)-1] != "_":
                 prefix = prefix + "_"
             self.userGuideName = prefix + self.userGuideName
         cmds.select(clear=True)
Example #5
0
    def createGuide(self, *args):
        """ Create the elements to Guide module in the scene, like controls, etc...
        """
        # GUIDE:
        utils.useDefaultRenderLayer()
        # create guide base (moduleGrp):
        guideBaseList = ctrls.cvBaseGuide(self.moduleGrp, r=2)
        self.moduleGrp = guideBaseList[0]
        self.radiusCtrl = guideBaseList[1]
        # add attributes to be read when rigging module:
        baseBooleanAttrList = ['guideBase', 'mirrorEnable', 'displayAnnotation']
        for baseBooleanAttr in baseBooleanAttrList:
            cmds.addAttr(self.moduleGrp, longName=baseBooleanAttr, attributeType='bool')
            cmds.setAttr(self.moduleGrp+"."+baseBooleanAttr, 1)
        
        baseIntegerAttrList = ['guideColor']
        for baseIntegerAttr in baseIntegerAttrList:
            cmds.addAttr(self.moduleGrp, longName=baseIntegerAttr, attributeType='long')
        
        baseStringAttrList  = ['moduleNamespace', 'customName', 'mirrorAxis', 'mirrorName', 'mirrorNameList', 'hookNode', 'moduleInstanceInfo', 'guideObjectInfo', 'rigType']
        for baseStringAttr in baseStringAttrList:
            cmds.addAttr(self.moduleGrp, longName=baseStringAttr, dataType='string')
        cmds.setAttr(self.moduleGrp+".mirrorAxis", "off", type='string')
        cmds.setAttr(self.moduleGrp+".mirrorName", self.langDic[self.langName]['p002_left']+' --> '+self.langDic[self.langName]['p003_right'], type='string')
        cmds.setAttr(self.moduleGrp+".hookNode", "_Grp", type='string')
        cmds.setAttr(self.moduleGrp+".moduleInstanceInfo", self, type='string')
        cmds.setAttr(self.moduleGrp+".guideObjectInfo", self.dpUIinst.guide, type='string')
        cmds.setAttr(self.moduleGrp+".rigType", self.rigType, type='string')
        
        baseFloatAttrList = ['shapeSize']
        for baseFloatAttr in baseFloatAttrList:
            cmds.addAttr(self.moduleGrp, longName=baseFloatAttr, attributeType='float')
        cmds.setAttr(self.moduleGrp+".shapeSize", 1)

        # create annotation to this module:
        self.annotation = cmds.annotate( self.moduleGrp, tx=self.moduleGrp, point=(0,2,0) )
        self.annotation = cmds.listRelatives(self.annotation, parent=True)[0]
        self.annotation = cmds.rename(self.annotation, self.moduleGrp+"_Ant")
        cmds.parent(self.annotation, self.moduleGrp)
        cmds.setAttr(self.annotation+'.text', self.moduleGrp[self.moduleGrp.find("__")+2:self.moduleGrp.rfind(":")], type='string')
        cmds.setAttr(self.annotation+'.template', 1)
 def changeJointNumber(self, enteredNJoints, *args):
     """ Edit the number of joints in the guide.
     """
     utils.useDefaultRenderLayer()
     # get the number of joints entered by user:
     if enteredNJoints == 0:
         try:
             self.enteredNJoints = cmds.intField(self.nJointsIF, query=True, value=True)
         except:
             return
     else:
         self.enteredNJoints = enteredNJoints
     # get the number of joints existing:
     self.currentNJoints = cmds.getAttr(self.moduleGrp + ".nJoints")
     # start analisys the difference between values:
     if self.enteredNJoints != self.currentNJoints:
         self.cvEndJoint = self.guideName + "_JointEnd"
         if self.currentNJoints > 1:
             # delete current point constraints:
             for n in range(2, self.currentNJoints):
                 cmds.delete(self.guideName + "_ParentConstraint" + str(n))
         # verify if the nJoints is greather or less than the current
         if self.enteredNJoints > self.currentNJoints:
             # add the new cvLocators:
             for n in range(self.currentNJoints + 1, self.enteredNJoints + 1):
                 # create another N cvLocator:
                 self.cvLocator, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_JointLoc" + str(n), r=0.3)
                 self.connectShapeSize(shapeSizeCH)
                 # set its nJoint value as n:
                 cmds.setAttr(self.cvLocator + ".nJoint", n)
                 # parent its group to the first cvJointLocator:
                 self.cvLocGrp = cmds.group(self.cvLocator, name=self.cvLocator + "_Grp")
                 cmds.parent(self.cvLocGrp, self.guideName + "_JointLoc" + str(n - 1), relative=True)
                 cmds.setAttr(self.cvLocGrp + ".translateZ", 2)
                 if n > 2:
                     cmds.parent(self.cvLocGrp, self.guideName + "_JointLoc1", absolute=True)
         elif self.enteredNJoints < self.currentNJoints:
             # re-parent cvEndJoint:
             self.cvLocator = self.guideName + "_JointLoc" + str(self.enteredNJoints)
             cmds.parent(self.cvEndJoint, world=True)
             # delete difference of nJoints:
             for n in range(self.enteredNJoints, self.currentNJoints):
                 # re-parent the children guides:
                 childrenGuideBellowList = utils.getGuideChildrenList(
                     self.guideName + "_JointLoc" + str(n + 1) + "_Grp")
                 if childrenGuideBellowList:
                     for childGuide in childrenGuideBellowList:
                         cmds.parent(childGuide, self.cvLocator)
                 cmds.delete(self.guideName + "_JointLoc" + str(n + 1) + "_Grp")
         # re-parent cvEndJoint:
         cmds.parent(self.cvEndJoint, self.cvLocator)
         cmds.setAttr(self.cvEndJoint + ".tz", 1.3)
         cmds.setAttr(self.cvEndJoint + ".visibility", 0)
         # re-create parentConstraints:
         if self.enteredNJoints > 1:
             for n in range(2, self.enteredNJoints):
                 self.parentConst = cmds.parentConstraint(self.guideName + "_JointLoc1",
                                                          self.cvEndJoint,
                                                          self.guideName + "_JointLoc" + str(n) + "_Grp",
                                                          name=self.guideName + "_ParentConstraint" + str(n),
                                                          maintainOffset=True)[0]
                 nParentValue = (n - 1) / float(self.enteredNJoints - 1)
                 cmds.setAttr(self.parentConst + ".Guide_JointLoc1W0", 1 - nParentValue)
                 cmds.setAttr(self.parentConst + ".Guide_JointEndW1", nParentValue)
                 ctrls.setLockHide([self.guideName + "_JointLoc" + str(n)], ['rx', 'ry', 'rz', 'sx', 'sy', 'sz'])
         # actualise the nJoints in the moduleGrp:
         cmds.setAttr(self.moduleGrp + ".nJoints", self.enteredNJoints)
         self.currentNJoints = self.enteredNJoints
         # re-build the preview mirror:
         Layout.LayoutClass.createPreviewMirror(self)
     cmds.select(self.moduleGrp)
Example #7
0
    def changeJointNumber(self, enteredNJoints, *args):
        """ Edit the number of joints in the guide.
        """
        utils.useDefaultRenderLayer()
        # get the number of joints entered by user:
        if enteredNJoints == 0:
            try:
                self.enteredNJoints = cmds.intField(self.nJointsIF,
                                                    query=True,
                                                    value=True)
            except:
                return
        else:
            self.enteredNJoints = enteredNJoints
        # get the number of joints existing:
        self.currentNJoints = cmds.getAttr(self.moduleGrp + ".nJoints")
        # start analisys the difference between values:
        if self.enteredNJoints != self.currentNJoints:
            # unparent temporarely the Ends:
            self.cvEndJoint = self.guideName + "_JointEnd"
            cmds.parent(self.cvEndJoint, world=True)
            self.jGuideEnd = (self.guideName + "_JGuideEnd")
            cmds.parent(self.jGuideEnd, world=True)
            # verify if the nJoints is greather or less than the current
            if self.enteredNJoints > self.currentNJoints:
                for n in range(self.currentNJoints + 1,
                               self.enteredNJoints + 1):
                    # create another N cvJointLoc:
                    self.cvJointLoc, shapeSizeCH = self.ctrls.cvJointLoc(
                        ctrlName=self.guideName + "_JointLoc" + str(n),
                        r=0.3,
                        d=1,
                        guide=True)
                    self.connectShapeSize(shapeSizeCH)
                    # set its nJoint value as n:
                    cmds.setAttr(self.cvJointLoc + ".nJoint", n)
                    # parent it to the lastGuide:
                    cmds.parent(self.cvJointLoc,
                                self.guideName + "_JointLoc" + str(n - 1),
                                relative=True)
                    cmds.setAttr(self.cvJointLoc + ".translateZ", 2)
                    # create a joint to use like an arrowLine:
                    self.jGuide = cmds.joint(name=self.guideName + "_JGuide" +
                                             str(n),
                                             radius=0.001)
                    cmds.setAttr(self.jGuide + ".template", 1)
                    #Prevent a intermidiate node to be added
                    cmds.parent(self.jGuide,
                                self.guideName + "_JGuide" + str(n - 1),
                                relative=True)
                    #Do not maintain offset and ensure cv will be at the same place than the joint
                    cmds.parentConstraint(self.cvJointLoc,
                                          self.jGuide,
                                          maintainOffset=False,
                                          name=self.jGuide +
                                          "_ParentConstraint")
                    cmds.scaleConstraint(self.cvJointLoc,
                                         self.jGuide,
                                         maintainOffset=False,
                                         name=self.jGuide + "_ScaleConstraint")
            elif self.enteredNJoints < self.currentNJoints:
                # re-define cvEndJoint:
                self.cvJointLoc = self.guideName + "_JointLoc" + str(
                    self.enteredNJoints)
                self.cvEndJoint = self.guideName + "_JointEnd"
                self.jGuide = self.guideName + "_JGuide" + str(
                    self.enteredNJoints)
                # re-parent the children guides:
                childrenGuideBellowList = utils.getGuideChildrenList(
                    self.cvJointLoc)
                if childrenGuideBellowList:
                    for childGuide in childrenGuideBellowList:
                        cmds.parent(childGuide, self.cvJointLoc)
                # delete difference of nJoints:
                cmds.delete(self.guideName + "_JointLoc" +
                            str(self.enteredNJoints + 1))
                cmds.delete(self.guideName + "_JGuide" +
                            str(self.enteredNJoints + 1))
            # re-parent cvEndJoint:
            pTempParent = cmds.listRelatives(self.cvEndJoint, p=True)
            cmds.parent(self.cvEndJoint, self.cvJointLoc)

            #Ensure to remove temp parent from the unparenting done on the end joint
            if pTempParent:
                cmds.delete(pTempParent)
            cmds.setAttr(self.cvEndJoint + ".tz", 1.3)
            pTempParent = cmds.listRelatives(self.jGuideEnd, p=True)
            cmds.parent(self.jGuideEnd, self.jGuide, relative=True)
            if pTempParent:
                cmds.delete(pTempParent)

            cmds.setAttr(self.moduleGrp + ".nJoints", self.enteredNJoints)
            self.currentNJoints = self.enteredNJoints
            # re-build the preview mirror:
            Layout.LayoutClass.createPreviewMirror(self)
        cmds.select(self.moduleGrp)
Example #8
0
    def changeJointNumber(self, enteredNJoints, *args):
        """ Edit the number of joints in the guide.
        """
        utils.useDefaultRenderLayer()
        # get the number of joints entered by user:
        if enteredNJoints == 0:
            try:
                self.enteredNJoints = cmds.intField(self.nJointsIF, query=True, value=True)
            except:
                return
        else:
            self.enteredNJoints = enteredNJoints
        # get the number of joints existing:
        self.currentNJoints = cmds.getAttr(self.moduleGrp+".nJoints")
        # start analisys the difference between values:
        if self.enteredNJoints != self.currentNJoints:
            # unparent temporarely the Ends:
            self.cvEndJoint = self.guideName+"_JointEnd"
            cmds.parent(self.cvEndJoint, world=True)
            self.jGuideEnd = (self.guideName+"_JGuideEnd")
            cmds.parent(self.jGuideEnd, world=True)
            # verify if the nJoints is greather or less than the current
            if self.enteredNJoints > self.currentNJoints:
                for n in range(self.currentNJoints+1, self.enteredNJoints+1):
                    # create another N cvJointLoc:
                    self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc( ctrlName=self.guideName+"_JointLoc"+str(n), r=0.3 )
                    self.connectShapeSize(shapeSizeCH)
                    # set its nJoint value as n:
                    cmds.setAttr(self.cvJointLoc+".nJoint", n)
                    # parent it to the lastGuide:
                    cmds.parent(self.cvJointLoc, self.guideName+"_JointLoc"+str(n-1), relative=True)
                    cmds.setAttr(self.cvJointLoc+".translateZ", 2)
                    # create a joint to use like an arrowLine:
                    self.jGuide = cmds.joint(name=self.guideName+"_JGuide"+str(n), radius=0.001)
                    cmds.setAttr(self.jGuide+".template", 1)
                    #Prevent a intermidiate node to be added
                    cmds.parent(self.jGuide, self.guideName+"_JGuide"+str(n-1), relative=True)
                    #Do not maintain offset and ensure cv will be at the same place than the joint
                    cmds.parentConstraint(self.cvJointLoc, self.jGuide, maintainOffset=False, name=self.jGuide+"_ParentConstraint")
                    cmds.scaleConstraint(self.cvJointLoc, self.jGuide, maintainOffset=False, name=self.jGuide+"_ScaleConstraint")
            elif self.enteredNJoints < self.currentNJoints:
                # re-define cvEndJoint:
                self.cvJointLoc = self.guideName+"_JointLoc"+str(self.enteredNJoints)
                self.cvEndJoint = self.guideName+"_JointEnd"
                self.jGuide = self.guideName+"_JGuide"+str(self.enteredNJoints)
                # re-parent the children guides:
                childrenGuideBellowList = utils.getGuideChildrenList(self.cvJointLoc)
                if childrenGuideBellowList:
                    for childGuide in childrenGuideBellowList:
                        cmds.parent(childGuide, self.cvJointLoc)
                # delete difference of nJoints:
                cmds.delete(self.guideName+"_JointLoc"+str(self.enteredNJoints+1))
                cmds.delete(self.guideName+"_JGuide"+str(self.enteredNJoints+1))
            # re-parent cvEndJoint:
            pTempParent = cmds.listRelatives(self.cvEndJoint, p=True)
            cmds.parent(self.cvEndJoint, self.cvJointLoc)

            #Ensure to remove temp parent from the unparenting done on the end joint
            if pTempParent:
                cmds.delete(pTempParent)
            cmds.setAttr(self.cvEndJoint+".tz", 1.3)
            pTempParent = cmds.listRelatives(self.jGuideEnd, p=True)
            cmds.parent(self.jGuideEnd, self.jGuide, relative=True)
            if pTempParent:
                cmds.delete(pTempParent)

            cmds.setAttr(self.moduleGrp+".nJoints", self.enteredNJoints)
            self.currentNJoints = self.enteredNJoints
            # re-build the preview mirror:
            Layout.LayoutClass.createPreviewMirror(self)
        cmds.select(self.moduleGrp)
Example #9
0
 def changeJointNumber(self, enteredNJoints, *args):
     """ Edit the number of joints in the guide.
     """
     utils.useDefaultRenderLayer()
     # get the number of joints entered by user:
     if enteredNJoints == 0:
         try:
             self.enteredNJoints = cmds.intField(self.nJointsIF, query=True, value=True)
         except:
             return
     else:
         self.enteredNJoints = enteredNJoints
     # get the number of joints existing:
     self.currentNJoints = cmds.getAttr(self.moduleGrp+".nJoints")
     # start analisys the difference between values:
     if self.enteredNJoints != self.currentNJoints:
         # unparent temporarely the Ends:
         self.cvEndJoint = self.guideName+"_JointEnd"
         cmds.parent(self.cvEndJoint, world=True)
         self.jGuideEnd = (self.guideName+"_JGuideEnd")
         cmds.parent(self.jGuideEnd, world=True)
         # verify if the nJoints is greather or less than the current
         if self.enteredNJoints > self.currentNJoints:
             for n in range(self.currentNJoints+1, self.enteredNJoints+1):
                 # create another N cvJointLoc:
                 self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc( ctrlName=self.guideName+"_JointLoc"+str(n), r=0.2 )
                 self.connectShapeSize(shapeSizeCH)
                 # set its nJoint value as n:
                 cmds.setAttr(self.cvJointLoc+".nJoint", n)
                 # parent it to the lastGuide:
                 cmds.parent(self.cvJointLoc, self.guideName+"_JointLoc"+str(n-1), relative=True)
                 cmds.setAttr(self.cvJointLoc+".translateZ", 1)
                 cmds.setAttr(self.cvJointLoc+".rotateY", -1)
                 # create a joint to use like an arrowLine:
                 self.jGuide = cmds.joint(name=self.guideName+"_JGuide"+str(n), radius=0.001)
                 cmds.setAttr(self.jGuide+".template", 1)
                 cmds.parent(self.jGuide, self.guideName+"_JGuide"+str(n-1))
                 ctrls.directConnect(self.cvJointLoc, self.jGuide, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz'])
         elif self.enteredNJoints < self.currentNJoints:
             # re-define cvEndJoint:
             self.cvJointLoc = self.guideName+"_JointLoc"+str(self.enteredNJoints)
             self.cvEndJoint = self.guideName+"_JointEnd"
             self.jGuide = self.guideName+"_JGuide"+str(self.enteredNJoints)
             # re-parent the children guides:
             childrenGuideBellowList = utils.getGuideChildrenList(self.cvJointLoc)
             if childrenGuideBellowList:
                 for childGuide in childrenGuideBellowList:
                     cmds.parent(childGuide, self.cvJointLoc)
             # delete difference of nJoints:
             cmds.delete(self.guideName+"_JointLoc"+str(self.enteredNJoints+1))
             cmds.delete(self.guideName+"_JGuide"+str(self.enteredNJoints+1))
         # re-parent cvEndJoint:
         cmds.parent(self.cvEndJoint, self.cvJointLoc)
         cmds.setAttr(self.cvEndJoint+".tz", 1.3)
         cmds.parent(self.jGuideEnd, self.jGuide)
         # actualise the nJoints in the moduleGrp:
         cmds.setAttr(self.moduleGrp+".nJoints", self.enteredNJoints)
         self.currentNJoints = self.enteredNJoints
         # re-build the preview mirror:
         Layout.LayoutClass.createPreviewMirror(self)
     cmds.select(self.moduleGrp)
Example #10
0
 def changeJointNumber(self, enteredNJoints, *args):
     """ Edit the number of joints in the guide.
     """
     utils.useDefaultRenderLayer()
     # get the number of joints entered by user:
     if enteredNJoints == 0:
         try:
             self.enteredNJoints = cmds.intField(self.nJointsIF, query=True, value=True)
         except:
             return
     else:
         self.enteredNJoints = enteredNJoints
     # get the number of joints existing:
     self.currentNJoints = cmds.getAttr(self.moduleGrp + ".nJoints")
     # start analisys the difference between values:
     if self.enteredNJoints != self.currentNJoints:
         self.cvEndJoint = self.guideName + "_JointEnd"
         if self.currentNJoints > 1:
             # delete current point constraints:
             for n in range(2, self.currentNJoints):
                 cmds.delete(self.guideName + "_ParentConstraint" + str(n))
         # verify if the nJoints is greather or less than the current
         if self.enteredNJoints > self.currentNJoints:
             # add the new cvLocators:
             for n in range(self.currentNJoints + 1, self.enteredNJoints + 1):
                 # create another N cvLocator:
                 self.cvLocator, shapeSizeCH = ctrls.cvLocator(ctrlName=self.guideName + "_JointLoc" + str(n), r=0.3)
                 self.connectShapeSize(shapeSizeCH)
                 # set its nJoint value as n:
                 cmds.setAttr(self.cvLocator + ".nJoint", n)
                 # parent its group to the first cvJointLocator:
                 self.cvLocGrp = cmds.group(self.cvLocator, name=self.cvLocator + "_Grp")
                 cmds.parent(self.cvLocGrp, self.guideName + "_JointLoc" + str(n - 1), relative=True)
                 cmds.setAttr(self.cvLocGrp + ".translateZ", 2)
                 if n > 2:
                     cmds.parent(self.cvLocGrp, self.guideName + "_JointLoc1", absolute=True)
         elif self.enteredNJoints < self.currentNJoints:
             # re-parent cvEndJoint:
             self.cvLocator = self.guideName + "_JointLoc" + str(self.enteredNJoints)
             cmds.parent(self.cvEndJoint, world=True)
             # delete difference of nJoints:
             for n in range(self.enteredNJoints, self.currentNJoints):
                 # re-parent the children guides:
                 childrenGuideBellowList = utils.getGuideChildrenList(
                     self.guideName + "_JointLoc" + str(n + 1) + "_Grp")
                 if childrenGuideBellowList:
                     for childGuide in childrenGuideBellowList:
                         cmds.parent(childGuide, self.cvLocator)
                 cmds.delete(self.guideName + "_JointLoc" + str(n + 1) + "_Grp")
         # re-parent cvEndJoint:
         cmds.parent(self.cvEndJoint, self.cvLocator)
         cmds.setAttr(self.cvEndJoint + ".tz", 1.3)
         cmds.setAttr(self.cvEndJoint + ".visibility", 0)
         # re-create parentConstraints:
         if self.enteredNJoints > 1:
             for n in range(2, self.enteredNJoints):
                 self.parentConst = cmds.parentConstraint(self.guideName + "_JointLoc1", self.cvEndJoint, self.guideName + "_JointLoc" + str(n) + "_Grp", name=self.guideName + "_ParentConstraint" + str(n), maintainOffset=True)[0]
                 nParentValue = (n - 1) / float(self.enteredNJoints - 1)
                 cmds.setAttr(self.parentConst + ".Guide_JointLoc1W0", 1 - nParentValue)
                 cmds.setAttr(self.parentConst + ".Guide_JointEndW1", nParentValue)
                 ctrls.setLockHide([self.guideName + "_JointLoc" + str(n)], ['rx', 'ry', 'rz', 'sx', 'sy', 'sz'])
         # actualise the nJoints in the moduleGrp:
         cmds.setAttr(self.moduleGrp + ".nJoints", self.enteredNJoints)
         self.currentNJoints = self.enteredNJoints
         # re-build the preview mirror:
         Layout.LayoutClass.createPreviewMirror(self)
     cmds.select(self.moduleGrp)
Example #11
0
 def changeJointNumber(self, enteredNJoints, *args):
     """ Edit the number of joints in the guide.
     """
     utils.useDefaultRenderLayer()
     # get the number of joints entered by user:
     if enteredNJoints == 0:
         try:
             self.enteredNJoints = cmds.intField(self.nJointsIF, query=True, value=True)
         except:
             return
     else:
         self.enteredNJoints = enteredNJoints
     # get the number of joints existing:
     self.currentNJoints = cmds.getAttr(self.moduleGrp+".nJoints")
     # start analisys the difference between values:
     if self.enteredNJoints != self.currentNJoints:
         # check if the controls have scale changed values in order to avoid the transform groups created from maya without namespace:
         scaledCtrl = False
         scaledCtrlDic = {}
         for j in range(1, self.currentNJoints+1):
             if cmds.getAttr(self.guideName+"_JointLoc"+str(j)+".scaleX") != 1 or cmds.getAttr(self.guideName+"_JointLoc"+str(j)+".scaleY") != 1 or cmds.getAttr(self.guideName+"_JointLoc"+str(j)+".scaleZ") != 1:
                 scaledCtrl = True
                 # get scale values:
                 scaledX = cmds.getAttr(self.guideName+"_JointLoc"+str(j)+".scaleX")
                 scaledY = cmds.getAttr(self.guideName+"_JointLoc"+str(j)+".scaleY")
                 scaledZ = cmds.getAttr(self.guideName+"_JointLoc"+str(j)+".scaleZ")
                 # store scale values in the dictionary:
                 scaledCtrlDic[j] = [scaledX, scaledY, scaledZ]
                 # reset scales values to 1,1,1:
                 cmds.setAttr(self.guideName+"_JointLoc"+str(j)+".scaleX", 1)
                 cmds.setAttr(self.guideName+"_JointLoc"+str(j)+".scaleY", 1)
                 cmds.setAttr(self.guideName+"_JointLoc"+str(j)+".scaleZ", 1)
         # unparent temporarely the Ends:
         self.cvEndJoint = self.guideName+"_JointEnd"
         cmds.parent(self.cvEndJoint, world=True)
         self.jGuideEnd = (self.guideName+"_JGuideEnd")
         cmds.parent(self.jGuideEnd, world=True)
         # verify if the nJoints is greather or less than the current
         if self.enteredNJoints > self.currentNJoints:
             for n in range(self.currentNJoints+1, self.enteredNJoints+1):
                 # create another N cvJointLoc:
                 self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc( ctrlName=self.guideName+"_JointLoc"+str(n), r=0.3 )
                 self.connectShapeSize(shapeSizeCH)
                 # set its nJoint value as n:
                 cmds.setAttr(self.cvJointLoc+".nJoint", n)
                 # parent it to the lastGuide:
                 cmds.parent(self.cvJointLoc, self.guideName+"_JointLoc"+str(n-1), relative=True)
                 cmds.setAttr(self.cvJointLoc+".translateZ", 2)
                 # create a joint to use like an arrowLine:
                 self.jGuide = cmds.joint(name=self.guideName+"_JGuide"+str(n), radius=0.001)
                 cmds.setAttr(self.jGuide+".template", 1)
                 cmds.parent(self.jGuide, self.guideName+"_JGuide"+str(n-1))
                 cmds.parentConstraint(self.cvJointLoc, self.jGuide, maintainOffset=True, name=self.jGuide+"_ParentConstraint")
                 cmds.scaleConstraint(self.cvJointLoc, self.jGuide, maintainOffset=True, name=self.jGuide+"_ScaleConstraint")
         elif self.enteredNJoints < self.currentNJoints:
             # re-define cvEndJoint:
             self.cvJointLoc = self.guideName+"_JointLoc"+str(self.enteredNJoints)
             self.cvEndJoint = self.guideName+"_JointEnd"
             self.jGuide = self.guideName+"_JGuide"+str(self.enteredNJoints)
             # re-parent the children guides:
             childrenGuideBellowList = utils.getGuideChildrenList(self.cvJointLoc)
             if childrenGuideBellowList:
                 for childGuide in childrenGuideBellowList:
                     cmds.parent(childGuide, self.cvJointLoc)
             # delete difference of nJoints:
             cmds.delete(self.guideName+"_JointLoc"+str(self.enteredNJoints+1))
             cmds.delete(self.guideName+"_JGuide"+str(self.enteredNJoints+1))
         # re-parent cvEndJoint:
         cmds.parent(self.cvEndJoint, self.cvJointLoc)
         cmds.setAttr(self.cvEndJoint+".tz", 1.3)
         cmds.parent(self.jGuideEnd, self.jGuide)
         # actualise the nJoints in the moduleGrp:
         cmds.setAttr(self.moduleGrp+".nJoints", self.enteredNJoints)
         self.currentNJoints = self.enteredNJoints
         # reset changed scale values again:
         if scaledCtrl:
             for j in scaledCtrlDic:
                 if cmds.objExists(self.guideName+"_JointLoc"+str(j)):
                     cmds.setAttr(self.guideName+"_JointLoc"+str(j)+".scaleX", scaledCtrlDic[j][0])
                     cmds.setAttr(self.guideName+"_JointLoc"+str(j)+".scaleY", scaledCtrlDic[j][1])
                     cmds.setAttr(self.guideName+"_JointLoc"+str(j)+".scaleZ", scaledCtrlDic[j][2])
         # re-build the preview mirror:
         Layout.LayoutClass.createPreviewMirror(self)
     cmds.select(self.moduleGrp)
Example #12
0
 def changeJointNumber(self, enteredNJoints, *args):
     """ Edit the number of joints in the guide.
     """
     utils.useDefaultRenderLayer()
     # get the number of joints entered by user:
     if enteredNJoints == 0:
         try:
             self.enteredNJoints = cmds.intField(self.nJointsIF,
                                                 query=True,
                                                 value=True)
         except:
             return
     else:
         self.enteredNJoints = enteredNJoints
     # get the number of joints existing:
     self.currentNJoints = cmds.getAttr(self.moduleGrp + ".nJoints")
     # start analisys the difference between values:
     if self.enteredNJoints != self.currentNJoints:
         # check if the controls have scale changed values in order to avoid the transform groups created from maya without namespace:
         scaledCtrl = False
         scaledCtrlDic = {}
         for j in range(1, self.currentNJoints + 1):
             if cmds.getAttr(self.guideName + "_JointLoc" + str(j) +
                             ".scaleX") != 1 or cmds.getAttr(
                                 self.guideName + "_JointLoc" + str(j) +
                                 ".scaleY") != 1 or cmds.getAttr(
                                     self.guideName + "_JointLoc" + str(j) +
                                     ".scaleZ") != 1:
                 scaledCtrl = True
                 # get scale values:
                 scaledX = cmds.getAttr(self.guideName + "_JointLoc" +
                                        str(j) + ".scaleX")
                 scaledY = cmds.getAttr(self.guideName + "_JointLoc" +
                                        str(j) + ".scaleY")
                 scaledZ = cmds.getAttr(self.guideName + "_JointLoc" +
                                        str(j) + ".scaleZ")
                 # store scale values in the dictionary:
                 scaledCtrlDic[j] = [scaledX, scaledY, scaledZ]
                 # reset scales values to 1,1,1:
                 cmds.setAttr(
                     self.guideName + "_JointLoc" + str(j) + ".scaleX", 1)
                 cmds.setAttr(
                     self.guideName + "_JointLoc" + str(j) + ".scaleY", 1)
                 cmds.setAttr(
                     self.guideName + "_JointLoc" + str(j) + ".scaleZ", 1)
         # unparent temporarely the Ends:
         self.cvEndJoint = self.guideName + "_JointEnd"
         cmds.parent(self.cvEndJoint, world=True)
         self.jGuideEnd = (self.guideName + "_JGuideEnd")
         cmds.parent(self.jGuideEnd, world=True)
         # verify if the nJoints is greather or less than the current
         if self.enteredNJoints > self.currentNJoints:
             for n in range(self.currentNJoints + 1,
                            self.enteredNJoints + 1):
                 # create another N cvJointLoc:
                 self.cvJointLoc, shapeSizeCH = ctrls.cvJointLoc(
                     ctrlName=self.guideName + "_JointLoc" + str(n), r=0.3)
                 self.connectShapeSize(shapeSizeCH)
                 # set its nJoint value as n:
                 cmds.setAttr(self.cvJointLoc + ".nJoint", n)
                 # parent it to the lastGuide:
                 cmds.parent(self.cvJointLoc,
                             self.guideName + "_JointLoc" + str(n - 1),
                             relative=True)
                 cmds.setAttr(self.cvJointLoc + ".translateZ", 2)
                 # create a joint to use like an arrowLine:
                 self.jGuide = cmds.joint(name=self.guideName + "_JGuide" +
                                          str(n),
                                          radius=0.001)
                 cmds.setAttr(self.jGuide + ".template", 1)
                 cmds.parent(self.jGuide,
                             self.guideName + "_JGuide" + str(n - 1))
                 cmds.parentConstraint(self.cvJointLoc,
                                       self.jGuide,
                                       maintainOffset=True,
                                       name=self.jGuide +
                                       "_ParentConstraint")
                 cmds.scaleConstraint(self.cvJointLoc,
                                      self.jGuide,
                                      maintainOffset=True,
                                      name=self.jGuide + "_ScaleConstraint")
         elif self.enteredNJoints < self.currentNJoints:
             # re-define cvEndJoint:
             self.cvJointLoc = self.guideName + "_JointLoc" + str(
                 self.enteredNJoints)
             self.cvEndJoint = self.guideName + "_JointEnd"
             self.jGuide = self.guideName + "_JGuide" + str(
                 self.enteredNJoints)
             # re-parent the children guides:
             childrenGuideBellowList = utils.getGuideChildrenList(
                 self.cvJointLoc)
             if childrenGuideBellowList:
                 for childGuide in childrenGuideBellowList:
                     cmds.parent(childGuide, self.cvJointLoc)
             # delete difference of nJoints:
             cmds.delete(self.guideName + "_JointLoc" +
                         str(self.enteredNJoints + 1))
             cmds.delete(self.guideName + "_JGuide" +
                         str(self.enteredNJoints + 1))
         # re-parent cvEndJoint:
         cmds.parent(self.cvEndJoint, self.cvJointLoc)
         cmds.setAttr(self.cvEndJoint + ".tz", 1.3)
         cmds.parent(self.jGuideEnd, self.jGuide)
         # actualise the nJoints in the moduleGrp:
         cmds.setAttr(self.moduleGrp + ".nJoints", self.enteredNJoints)
         self.currentNJoints = self.enteredNJoints
         # reset changed scale values again:
         if scaledCtrl:
             for j in scaledCtrlDic:
                 if cmds.objExists(self.guideName + "_JointLoc" + str(j)):
                     cmds.setAttr(
                         self.guideName + "_JointLoc" + str(j) + ".scaleX",
                         scaledCtrlDic[j][0])
                     cmds.setAttr(
                         self.guideName + "_JointLoc" + str(j) + ".scaleY",
                         scaledCtrlDic[j][1])
                     cmds.setAttr(
                         self.guideName + "_JointLoc" + str(j) + ".scaleZ",
                         scaledCtrlDic[j][2])
         # re-build the preview mirror:
         Layout.LayoutClass.createPreviewMirror(self)
     cmds.select(self.moduleGrp)