Python maya.cmds.setAttr() Examples

The following are 30 code examples of maya.cmds.setAttr(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maya.cmds , or try the search function .
Example #1
Source File: pipeline.py    From core with MIT License 7 votes vote down vote up
def lock():
    """Lock scene

    Add an invisible node to your Maya scene with the name of the
    current file, indicating that this file is "locked" and cannot
    be modified any further.

    """

    if not cmds.objExists("lock"):
        with lib.maintained_selection():
            cmds.createNode("objectSet", name="lock")
            cmds.addAttr("lock", ln="basename", dataType="string")

            # Permanently hide from outliner
            cmds.setAttr("lock.verticesOnlySet", True)

    fname = cmds.file(query=True, sceneName=True)
    basename = os.path.basename(fname)
    cmds.setAttr("lock.basename", basename, type="string") 
Example #2
Source File: create.py    From maya-spline-ik with GNU General Public License v3.0 7 votes vote down vote up
def __createControl(self, cls, shape, clr, i=None, suffix=""):
        # create root control
        offset, ctrl = control.createControlShape(
            "{0}{1}".format(self.name, suffix),
            shape,
            clr,
            i
        )
        
        # position control
        pos = cluster.getClusterPosition(cls)
        cmds.setAttr("{0}.translate".format(offset), *pos)

        # parent cluster
        cmds.parent(cls, ctrl)

        return offset, ctrl
        
    # ------------------------------------------------------------------------ 
Example #3
Source File: dpBaseControlClass.py    From dpAutoRigSystem with GNU General Public License v2.0 7 votes vote down vote up
def setControlDirection(self, cvNode, cvDirection, *args):
        """ Rotate the node given to have the correct direction orientation.
        """
        if cvDirection == "-X":
            cmds.setAttr(cvNode+".rotateX", 90)
            cmds.setAttr(cvNode+".rotateY", -90)
        elif cvDirection == "+X":
            cmds.setAttr(cvNode+".rotateX", -90)
            cmds.setAttr(cvNode+".rotateY", -90)
        elif cvDirection == "-Y":
            cmds.setAttr(cvNode+".rotateZ", 180)
        elif cvDirection == "-Z":
            cmds.setAttr(cvNode+".rotateX", -90)
        elif cvDirection == "+Z":
            cmds.setAttr(cvNode+".rotateX", 90)
        else:
            pass #default +Y, just pass
        cmds.makeIdentity(cvNode, rotate=True, apply=True)
        # rotate and freezeTransformation from given cvRot vector:
        cmds.rotate(self.cvRot[0], self.cvRot[1], self.cvRot[2], self.cvCurve)
        cmds.makeIdentity(self.cvCurve, rotate=True, apply=True) 
Example #4
Source File: dpControls.py    From dpAutoRigSystem with GNU General Public License v2.0 7 votes vote down vote up
def cvLocator(self, ctrlName, r=1, d=1, guide=False, *args):
        """Create and return a cvLocator curve to be usually used in the guideSystem and the clusterHandle to shapeSize.
        """
        curveInstance = self.getControlInstance("Locator")
        curve = curveInstance.cvMain(False, "Locator", ctrlName, r, d, '+Y', (0, 0, 0), 1, guide)
        if guide:
            # create an attribute to be used as guide by module:
            cmds.addAttr(curve, longName="nJoint", attributeType='long')
            cmds.setAttr(curve+".nJoint", 1)
            # colorize curveShape:
            self.colorShape([curve], 'blue')
            # shapeSize setup:
            shapeSizeCluster = self.shapeSizeSetup(curve)
            return [curve, shapeSizeCluster]
        return curve


    #@utils.profiler 
Example #5
Source File: dpSmile.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def generateCombineCurves(self, useUI, cvID, cvName, cvSize, cvDegree, cvDirection, *args):
        """ Combine controls in order to return it.
        """
        # load module instance
        circleInstance = self.dpUIinst.initControlModule('dpCircle', self.controlsGuideDir)
        mouthInstance = self.dpUIinst.initControlModule('dpCurvedCircleUp', self.controlsGuideDir)
        # creating curve shapes:
        curve1 = circleInstance.cvMain(False, cvID, cvName, cvSize, cvDegree)
        curve2 = circleInstance.cvMain(False, cvID, cvName, cvSize*0.3, cvDegree)
        curve3 = circleInstance.cvMain(False, cvID, cvName, cvSize*0.3, cvDegree)
        curve4 = mouthInstance.cvMain(False, cvID, cvName, cvSize, cvDegree)
        cmds.setAttr(curve2+".translateX", 0.4*cvSize)
        cmds.setAttr(curve2+".translateY", 0.3*cvSize)
        cmds.setAttr(curve3+".translateX", -0.4*cvSize)
        cmds.setAttr(curve3+".translateY", 0.3*cvSize)
        mainCurve = self.combineCurves([curve1, curve2, curve3, curve4])
        return mainCurve 
Example #6
Source File: dpLayoutClass.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def loadGeo(self, *args):
        """ Loads the selected node to geoTextField in selectedModuleLayout.
        """
        isGeometry = False
        selList = cmds.ls(selection=True)
        if selList:
            if cmds.objExists(selList[0]):
                childList = cmds.listRelatives(selList[0], children=True, allDescendents=True)
                if childList:
                    for item in childList:
                        itemType = cmds.objectType(item)
                        if itemType == "mesh" or itemType == "nurbsSurface":
                            isGeometry = True
        if isGeometry:
            cmds.textField(self.geoTF, edit=True, text=selList[0])
            cmds.setAttr(self.moduleGrp+".geo", selList[0], type='string') 
Example #7
Source File: dpLimb.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def changeStyle(self, style, *args):
        """ Change the style to be applyed custom actions to be more animator friendly.
            We will optimise: ik controls mirrored correctely, quadruped front legs using ikSpring solver, good parents and constraints
        """
        self.cvCornerBLoc = self.guideName + "_CornerB"
        # for Default style:
        if style == self.langDic[self.langName]['m042_default']:
            cmds.setAttr(self.cvCornerBLoc + ".visibility", 0)
            cmds.setAttr(self.moduleGrp + ".style", 0)
        # for Biped style:
        if style == self.langDic[self.langName]['m026_biped']:
            cmds.setAttr(self.cvCornerBLoc + ".visibility", 0)
            cmds.setAttr(self.moduleGrp + ".style", 1)
        # for Quadruped style:
        if style == self.langDic[self.langName]['m037_quadruped']:
            cmds.setAttr(self.cvCornerBLoc + ".visibility", 1)
            cmds.setAttr(self.moduleGrp + ".style", 2)
        # for Quadruped Spring style:
        if style == self.langDic[self.langName]['m043_quadSpring']:
            cmds.setAttr(self.cvCornerBLoc + ".visibility", 1)
            cmds.setAttr(self.moduleGrp + ".style", 3)
        # for Quadruped Extra style:
        if style == self.langDic[self.langName]['m155_quadrupedExtra']:
            cmds.setAttr(self.cvCornerBLoc + ".visibility", 1)
            cmds.setAttr(self.moduleGrp + ".style", 4) 
Example #8
Source File: dpLimb.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def reOrientGuide(self, *args):
        """ This function reOrient guides orientations, creating temporary aimConstraints for them.
        """
        # re-declaring guide names:
        self.cvBeforeLoc = self.guideName + "_Before"
        self.cvMainLoc = self.guideName + "_Main"
        self.cvCornerLoc = self.guideName + "_Corner"
        self.cvExtremLoc = self.guideName + "_Extrem"

        # re-orient rotations:
        tempToDelBefore = cmds.aimConstraint(self.cvMainLoc, self.cvBeforeLoc, aimVector=(0.0, 0.0, 1.0), upVector=(1.0, 0.0, 0.0))
        tempToDelMain = cmds.aimConstraint(self.cvCornerLoc, self.cvMainLoc, aimVector=(0.0, 0.0, 1.0), upVector=(1.0, 0.0, 0.0))
        cmds.delete(tempToDelBefore, tempToDelMain)
        cmds.setAttr(self.cvExtremLoc + '.rotateX', 0)
        cmds.setAttr(self.cvExtremLoc + '.rotateY', 0)
        cmds.setAttr(self.cvExtremLoc + '.rotateZ', 0) 
Example #9
Source File: dpEye.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def changeEyelid(self, *args):
        """ Set the attribute value for eyelid.
        """
        # re-declaring variables:
        self.cvUpperEyelidLoc = self.guideName+"_UpperEyelidLoc"
        self.cvLowerEyelidLoc = self.guideName+"_LowerEyelidLoc"
        self.jEyelid = self.guideName+"_JEyelid"
        self.jUpperEyelid = self.guideName+"_JUpperEyelid"
        self.jLowerEyelid = self.guideName+"_JLowerEyelid"
        # getting value:
        currentEyelidValue = cmds.checkBox(self.eyelidCB, query=True, value=True)
        # setting values:
        cmds.setAttr(self.moduleGrp+".eyelid", currentEyelidValue)
        cmds.setAttr(self.cvUpperEyelidLoc+".visibility", currentEyelidValue)
        cmds.setAttr(self.cvLowerEyelidLoc+".visibility", currentEyelidValue)
        cmds.setAttr(self.jEyelid+".visibility", currentEyelidValue)
        cmds.setAttr(self.jUpperEyelid+".visibility", currentEyelidValue)
        cmds.setAttr(self.jLowerEyelid+".visibility", currentEyelidValue) 
Example #10
Source File: dpEye.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def createEyelidJoints(self, side, lid, middle, cvEyelidLoc, jointLabelNumber, *args):
        ''' Create the eyelid joints to be used in the needed setup.
            Returns EyelidBaseJxt and EyelidJnt created for rotate and skinning.
        '''
        # declating a concatenated name used for base to compose:
        baseName = side+self.userGuideName+"_"+self.langDic[self.langName][lid]+"_"+self.langDic[self.langName]['c042_eyelid']+middle
        # creating joints:
        eyelidBaseZeroJxt = cmds.joint(name=baseName+"_Base_Zero_Jxt", rotationOrder="yzx", scaleCompensate=False)
        eyelidBaseJxt = cmds.joint(name=baseName+"_Base_Jxt", rotationOrder="yzx", scaleCompensate=False)
        eyelidZeroJxt = cmds.joint(name=baseName+"_Zero_Jxt", rotationOrder="yzx", scaleCompensate=False)
        eyelidJnt = cmds.joint(name=baseName+"_Jnt", rotationOrder="yzx", scaleCompensate=False)
        cmds.addAttr(eyelidJnt, longName='dpAR_joint', attributeType='float', keyable=False)
        utils.setJointLabel(eyelidJnt, jointLabelNumber, 18, self.userGuideName+"_"+self.langDic[self.langName][lid]+"_"+self.langDic[self.langName]['c042_eyelid']+middle)
        cmds.select(eyelidZeroJxt)
        eyelidSupportJxt = cmds.joint(name=baseName+"_Jxt", rotationOrder="yzx", scaleCompensate=False)
        cmds.setAttr(eyelidSupportJxt+".translateX", self.ctrlRadius*0.1)
        # positioning and orienting correctely eyelid joints:
        cmds.delete(cmds.aimConstraint(cvEyelidLoc, eyelidBaseZeroJxt, aimVector=(0,0,1), worldUpType="objectrotation", worldUpObject=self.eyelidJxt))
        cmds.delete(cmds.parentConstraint(cvEyelidLoc, eyelidZeroJxt, mo=False))
        cmds.setAttr(eyelidZeroJxt+".rotateX", 0)
        cmds.setAttr(eyelidZeroJxt+".rotateY", 0)
        cmds.setAttr(eyelidZeroJxt+".rotateZ", 0)
        cmds.select(self.eyelidJxt)
        return eyelidBaseJxt, eyelidJnt 
Example #11
Source File: dpSpine.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
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.addAttr(self.moduleGrp, longName="style", attributeType='enum', enumName=self.langDic[self.langName]['m042_default']+':'+self.langDic[self.langName]['m026_biped'])
        cmds.setAttr(self.moduleGrp+".nJoints", 1)
        self.cvJointLoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.5, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        self.cvEndJoint, shapeSizeCH = self.ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1, d=1, guide=True)
        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))
        self.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) 
Example #12
Source File: commands.py    From core with MIT License 6 votes vote down vote up
def reset_resolution():
    project = io.find_one({"type": "project"})

    try:
        resolution_width = project["data"].get(
            "resolutionWidth",
            # backwards compatibility
            project["data"].get("resolution_width", 1920)
        )
        resolution_height = project["data"].get(
            "resolutionHeight",
            # backwards compatibility
            project["data"].get("resolution_height", 1080)
        )
    except KeyError:
        cmds.warning("No resolution information found for %s"
                     % project["name"])
        return

    cmds.setAttr("defaultResolution.width", resolution_width)
    cmds.setAttr("defaultResolution.height", resolution_height) 
Example #13
Source File: dpControls.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def pasteAttr(self, destinationList=False, verbose=False, *args):
        """ Get to destination list and set the dictionary values on them.
        """
        # getting destinationList:
        if not destinationList:
            destinationList = cmds.ls(selection=True, long=True)
        if destinationList and self.attrValueDic:
            # set dic values to destinationList:
            for destItem in destinationList:
                for attr in self.attrValueDic:
                    try:
                        cmds.setAttr(destItem+'.'+attr, self.attrValueDic[attr])
                    except:
                        try:
                            cmds.setAttr(destItem+'.'+attr, self.attrValueDic[attr], type='string')
                        except:
                            pass
                            if verbose:
                                print self.dpUIinst.langDic[self.dpUIinst.langName]["e016_notPastedAttr"], attr
            if verbose:
                print self.dpUIinst.langDic[self.dpUIinst.langName]["i126_pastedAttr"] 
Example #14
Source File: dpControls.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def shapeSizeSetup(self, transformNode, *args):
        """ Find shapes, create a cluster deformer to all and set the pivot to transform pivot.
            Returns the created cluster.
        """
        clusterHandle = None
        childShapeList = cmds.listRelatives(transformNode, shapes=True, children=True)
    #    print "Child length {0}".format(len(childShapeList))
        if childShapeList:
            thisNamespace = childShapeList[0].split(":")[0]
            cmds.namespace(set=thisNamespace, force=True)
            clusterName = transformNode.split(":")[1]+"_ShapeSizeCH"
            clusterHandle = cmds.cluster(childShapeList, name=clusterName)[1]
            cmds.setAttr(clusterHandle+".visibility", 0)
            cmds.xform(clusterHandle, scalePivot=(0, 0, 0), worldSpace=True)
            cmds.namespace(set=":")
        else:
            print "There are not children shape to create shapeSize setup of:", transformNode
        return clusterHandle 
Example #15
Source File: create.py    From maya-spline-ik with GNU General Public License v3.0 5 votes vote down vote up
def __createSlideControls(self):
        # variables
        offsets = []
        controls = []
        
        # loop controls
        for suffix in ["slide", "slide_min", "slide_max"]:
            ctrlOffset, ctrl = control.createControlShape(
                "{0}_{1}".format(self.name, suffix),
                self.slideControlShape,
                self.slideControlColour
            )
            
            # scale constraint
            cmds.scaleConstraint(self.rootControl, ctrlOffset)

            # append to list
            offsets.append(ctrlOffset)
            controls.append(ctrl)
            
        # scale controls
        scale = [0.75, 0.5, 0.5]
        for ctrl, s in zip(controls, scale):
            cmds.setAttr("{0}.scale".format(ctrl), s, s, s)
            cmds.makeIdentity(ctrl, apply=True, scale=True)
        
        # parent controls
        cmds.parent(
            offsets,
            self.rootControl
        )

        return controls 
Example #16
Source File: dpControls.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def resetCurve(self, changeDegree=False, transformList=False, *args):
        """ Read the current curve degree of selected curve controls and change it to another one.
            1 to 3
            or
            3 to 1.
        """
        if not transformList:
            transformList = cmds.ls(selection=True, type="transform")
        if transformList:
            for item in transformList:
                if cmds.objExists(item+".dpControl") and cmds.getAttr(item+".dpControl") == 1:
                    # getting current control values from stored attributes:
                    curType = cmds.getAttr(item+".className")
                    curSize = cmds.getAttr(item+".size")
                    curDegree = cmds.getAttr(item+".degree")
                    curDir = cmds.getAttr(item+".direction")
                    curRotX = cmds.getAttr(item+".cvRotX")
                    curRotY = cmds.getAttr(item+".cvRotY")
                    curRotZ = cmds.getAttr(item+".cvRotZ")
                    if changeDegree:
                        # changing current curve degree:
                        if curDegree == 1: #linear
                            curDegree = 3 #cubic
                        else: #cubic
                            curDegree = 1 #linear
                        cmds.setAttr(item+".degree", curDegree)
                    curve = self.cvControl(curType, "Temp_Ctrl", curSize, curDegree, curDir, (curRotX, curRotY, curRotZ), 1)
                    self.transferShape(deleteSource=True, clearDestinationShapes=True, sourceItem=curve, destinationList=[item], applyColor=True)
            cmds.select(transformList) 
Example #17
Source File: dpControls.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def setAndFreeze(nodeName="", tx=None, ty=None, tz=None, rx=None, ry=None, rz=None, sx=None, sy=None, sz=None, freeze=True):
        """This function set attribute values and do a freezeTransfomation.
        """
        if nodeName != "":
            attrNameList  = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']
            attrValueList = [tx, ty, tz, rx, ry, rz, sx, sy, sz]
            # setting attribute values:
            for v, attrValue in enumerate(attrValueList):
                if attrValue:
                    try:
                        cmds.setAttr(nodeName+'.'+attrNameList[v], attrValue)
                    except:
                        pass
            # looking the need of freeze:
            if freeze:
                freezeT = False
                freezeR = False
                freezeS = False
                if tx != None or ty != None or tz != None:
                    freezeT = True
                if rx != None or ry != None or rz != None:
                    freezeR = True
                if sx != None or sy != None or sz != None:
                    freezeS = True
                try:
                    cmds.makeIdentity(nodeName, apply=freeze, translate=freezeT, rotate=freezeR, scale=freezeS)
                except:
                    pass 
Example #18
Source File: dpControls.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def cvJointLoc(self, ctrlName, r=0.3, d=1, rot=(0, 0, 0), guide=True, *args):
        """Create and return a cvJointLocator curve to be usually used in the guideSystem and the clusterHandle to shapeSize.
        """
        # create locator curve:
        cvLoc = self.cvLocator(ctrlName+"_CvLoc", r, d)
        # create arrow curves:
        cvArrow1 = cmds.curve(n=ctrlName+"_CvArrow1", d=3, p=[(-0.1*r, 0.9*r, 0.2*r), (-0.1*r, 0.9*r, 0.23*r), (-0.1*r, 0.9*r, 0.27*r), (-0.1*r, 0.9*r, 0.29*r), (-0.1*r, 0.9*r, 0.3*r), (-0.372*r, 0.9*r, 0.24*r), (-0.45*r, 0.9*r, -0.13*r), (-0.18*r, 0.9*r, -0.345*r), (-0.17*r, 0.9*r, -0.31*r), (-0.26*r, 0.9*r, -0.41*r), (-0.21*r, 0.9*r, -0.41*r), (-0.05*r, 0.9*r, -0.4*r), (0, 0.9*r, -0.4*r), (-0.029*r, 0.9*r, -0.33*r), (-0.048*r, 0.9*r, -0.22*r), (-0.055*r, 0.9*r, -0.16*r), (-0.15*r, 0.9*r, -0.272*r), (-0.12*r, 0.9*r, -0.27*r), (-0.35*r, 0.9*r, -0.1*r), (-0.29*r, 0.9*r, 0.15*r), (-0.16*r, 0.9*r, 0.21*r), (-0.1*r, 0.9*r, 0.2*r)] )
        cvArrow2 = cmds.curve(n=ctrlName+"_CvArrow2", d=3, p=[(0.1*r, 0.9*r, -0.2*r), (0.1*r, 0.9*r, -0.23*r), (0.1*r, 0.9*r, -0.27*r), (0.1*r, 0.9*r, -0.29*r), (0.1*r, 0.9*r, -0.3*r), (0.372*r, 0.9*r, -0.24*r), (0.45*r, 0.9*r, 0.13*r), (0.18*r, 0.9*r, 0.345*r), (0.17*r, 0.9*r, 0.31*r), (0.26*r, 0.9*r, 0.41*r), (0.21*r, 0.9*r, 0.41*r), (0.05*r, 0.9*r, 0.4*r), (0, 0.9*r, 0.4*r), (0.029*r, 0.9*r, 0.33*r), (0.048*r, 0.9*r, 0.22*r), (0.055*r, 0.9*r, 0.16*r), (0.15*r, 0.9*r, 0.272*r), (0.12*r, 0.9*r, 0.27*r), (0.35*r, 0.9*r, 0.1*r), (0.29*r, 0.9*r, -0.15*r), (0.16*r, 0.9*r, -0.21*r), (0.1*r, 0.9*r, -0.2*r)] )
        cvArrow3 = cmds.curve(n=ctrlName+"_CvArrow3", d=3, p=[(-0.1*r, -0.9*r, 0.2*r), (-0.1*r, -0.9*r, 0.23*r), (-0.1*r, -0.9*r, 0.27*r), (-0.1*r, -0.9*r, 0.29*r), (-0.1*r, -0.9*r, 0.3*r), (-0.372*r, -0.9*r, 0.24*r), (-0.45*r, -0.9*r, -0.13*r), (-0.18*r, -0.9*r, -0.345*r), (-0.17*r, -0.9*r, -0.31*r), (-0.26*r, -0.9*r, -0.41*r), (-0.21*r, -0.9*r, -0.41*r), (-0.05*r, -0.9*r, -0.4*r), (0, -0.9*r, -0.4*r), (-0.029*r, -0.9*r, -0.33*r), (-0.048*r, -0.9*r, -0.22*r), (-0.055*r, -0.9*r, -0.16*r), (-0.15*r, -0.9*r, -0.272*r), (-0.12*r, -0.9*r, -0.27*r), (-0.35*r, -0.9*r, -0.1*r), (-0.29*r, -0.9*r, 0.15*r), (-0.16*r, -0.9*r, 0.21*r), (-0.1*r, -0.9*r, 0.2*r)] )
        cvArrow4 = cmds.curve(n=ctrlName+"_CvArrow4", d=3, p=[(0.1*r, -0.9*r, -0.2*r), (0.1*r, -0.9*r, -0.23*r), (0.1*r, -0.9*r, -0.27*r), (0.1*r, -0.9*r, -0.29*r), (0.1*r, -0.9*r, -0.3*r), (0.372*r, -0.9*r, -0.24*r), (0.45*r, -0.9*r, 0.13*r), (0.18*r, -0.9*r, 0.345*r), (0.17*r, -0.9*r, 0.31*r), (0.26*r, -0.9*r, 0.41*r), (0.21*r, -0.9*r, 0.41*r), (0.05*r, -0.9*r, 0.4*r), (0, -0.9*r, 0.4*r), (0.029*r, -0.9*r, 0.33*r), (0.048*r, -0.9*r, 0.22*r), (0.055*r, -0.9*r, 0.16*r), (0.15*r, -0.9*r, 0.272*r), (0.12*r, -0.9*r, 0.27*r), (0.35*r, -0.9*r, 0.1*r), (0.29*r, -0.9*r, -0.15*r), (0.16*r, -0.9*r, -0.21*r), (0.1*r, -0.9*r, -0.2*r)] )
        cvArrow5 = cmds.curve(n=ctrlName+"_CvArrow5", d=1, p=[(0, 0, 1.2*r), (0.09*r, 0, 1*r), (-0.09*r, 0, 1*r), (0, 0, 1.2*r)] )
        cvArrow6 = cmds.curve(n=ctrlName+"_CvArrow6", d=1, p=[(0, 0, 1.2*r), (0, 0.09*r, 1*r), (0, -0.09*r, 1*r), (0, 0, 1.2*r)] )
        # rename curveShape:
        locArrowList = [cvLoc, cvArrow1, cvArrow2, cvArrow3, cvArrow4, cvArrow5, cvArrow6]
        self.renameShape(locArrowList)
        # create ball curve:
        cvTemplateBall = self.cvControl("Ball", ctrlName+"_CvBall", r=0.7*r, d=3)
        # parent shapes to transform:
        locCtrl = cmds.group(name=ctrlName, empty=True)
        ballChildrenList = cmds.listRelatives(cvTemplateBall, shapes=True, children=True)
        for ballChildren in ballChildrenList:
            cmds.setAttr(ballChildren+".template", 1)
        self.transferShape(True, False, cvTemplateBall, [locCtrl])
        for transform in locArrowList:
            self.transferShape(True, False, transform, [locCtrl])
        # set rotation direction:
        cmds.setAttr(locCtrl+".rotateX", rot[0])
        cmds.setAttr(locCtrl+".rotateY", rot[1])
        cmds.setAttr(locCtrl+".rotateZ", rot[2])
        cmds.makeIdentity(locCtrl, rotate=True, apply=True)
        # create an attribute to be used as guide by module:
        cmds.addAttr(locCtrl, longName="nJoint", attributeType='long')
        cmds.setAttr(locCtrl+".nJoint", 1)
        # colorize curveShapes:
        self.colorShape([locCtrl], 'blue')
        # shapeSize setup:
        shapeSizeCluster = self.shapeSizeSetup(locCtrl)
        cmds.select(clear=True)
        return [locCtrl, shapeSizeCluster] 
Example #19
Source File: dpDodecagram.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def generateCombineCurves(self, useUI, cvID, cvName, cvSize, cvDegree, cvDirection, *args):
        """ Combine controls in order to return it.
        """
        # load module instance
        hexagonInstance = self.dpUIinst.initControlModule('dpCircle', self.controlsGuideDir)
        # creating curve shapes:
        curve1 = hexagonInstance.cvMain(False, cvID, cvName, cvSize, cvDegree)
        curve2 = hexagonInstance.cvMain(False, cvID, cvName, cvSize, cvDegree)
        cmds.setAttr(curve2+".rotateZ", 90)
        mainCurve = self.combineCurves([curve1, curve2])
        return mainCurve 
Example #20
Source File: dpControls.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def setNotRenderable(self, objList, *args):
        """Receive a list of objects, find its shapes if necessary and set all as not renderable.
        """
        # declare a list of attributes for render:
        renderAttrList = ["castsShadows", "receiveShadows", "motionBlur", "primaryVisibility", "smoothShading", "visibleInReflections", "visibleInRefractions", "doubleSided", "miTransparencyCast", "miTransparencyReceive", "miReflectionReceive", "miRefractionReceive", "miFinalGatherCast", "miFinalGatherReceive"]
        shapeTypeList = ['nurbsCurve', 'nurbsSurface', 'mesh', 'subdiv']
        # find all children shapes:
        if objList:
            for obj in objList:
                objType = cmds.objectType(obj)
                # verify if the object is the shape type:
                if objType in shapeTypeList:
                    # set attributes as not renderable:
                    for attr in renderAttrList:
                        try:
                            cmds.setAttr(obj+"."+attr, 0)
                        except:
                            #print "Error: Cannot set not renderable ", attr, "as zero for", obj
                            pass
                # verify if the object is a transform type:
                elif objType == "transform":
                    # find all shapes children of the transform object:
                    shapeList = cmds.listRelatives(obj, shapes=True, children=True)
                    if shapeList:
                        for shape in shapeList:
                            # set attributes as not renderable:
                            for attr in renderAttrList:
                                try:
                                    cmds.setAttr(shape+"."+attr, 0)
                                except:
                                    #print "Error: Cannot set not renderable ", attr, "as zero for", shape
                                    pass 
Example #21
Source File: dpControls.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def setLockHide(self, objList, attrList, l=True, k=False, *args):
        """Set lock or hide to attributes for object in lists.
        """
        if objList and attrList:
            for obj in objList:
                for attr in attrList:
                    try:
                        # set lock and hide of given attributes:
                        cmds.setAttr(obj+"."+attr, lock=l, keyable=k)
                    except:
                        print "Error: Cannot set", obj, ".", attr, "as lock=", l, "and keyable=", k 
Example #22
Source File: create.py    From maya-spline-ik with GNU General Public License v3.0 5 votes vote down vote up
def __normalizeSlideAttributes(self):
        normalized = []
        attributes = [
            "slide_center", 
            "slide_shift", 
            "slide_shift_min", 
            "slide_shift_max"
        ]
        
        # loop attributes
        for attr in attributes:
            mdl = cmds.createNode(
                "multDoubleLinear",
                n="{0}_{1}_norm_mdl".format(self.name, attr)
            )

            cmds.setAttr("{0}.input1".format(mdl), 0.1)
            cmds.connectAttr(
                "{0}.{1}".format(self.slideControl, attr),
                "{0}.input2".format(mdl)
            )

            normalized.append("{0}.output".format(mdl))

        return normalized 
Example #23
Source File: dpWheel.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def changeGeo(self, *args):
        """ Update moduleGrp geo attribute from UI textField.
        """
        newGeoValue = cmds.textField(self.geoTF, query=True, text=True)
        cmds.setAttr(self.moduleGrp+".geo", newGeoValue, type='string') 
Example #24
Source File: dpWheel.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def changeShowControls(self, *args):
        """ Update moduleGrp showControls attribute from UI.
        """
        newShowControlsValue = cmds.checkBox(self.showControlsCB, query=True, value=True)
        cmds.setAttr(self.moduleGrp+".showControls", newShowControlsValue) 
Example #25
Source File: dpWheel.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def changeSteering(self, *args):
        """ Update moduleGrp steering attribute from UI.
        """
        newSterringValue = cmds.checkBox(self.steeringCB, query=True, value=True)
        cmds.setAttr(self.moduleGrp+".steering", newSterringValue) 
Example #26
Source File: dpLayoutClass.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def changeDegree(self, item, *args):
        """ This function receives the degree menu name item and set it as a string in the guide base (moduleGrp).
        """
        # verify integrity of the guideModule:
        if self.verifyGuideModuleIntegrity():
            if item == '3 - Cubic':
                cmds.setAttr(self.moduleGrp+".degree", 3)
            else:
                cmds.setAttr(self.moduleGrp+".degree", 1) 
Example #27
Source File: dpLayoutClass.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def changeMirror(self, item, *args):
        """ This function receives the mirror menu item and set it as a string in the guide base (moduleGrp).
            Also, call the builder of the preview mirror (for the viewport).
        """
        # verify integrity of the guideModule:
        if self.verifyGuideModuleIntegrity():
            # check if the father guide is in X=0 in order to permit mirror:
            stopMirrorOperation = self.checkFatherMirror()
            if not stopMirrorOperation:
                # loading Maya matrix node (for mirror porpuses)
                loadedMatrixPlugin = utils.checkLoadedPlugin("decomposeMatrix", "matrixNodes", self.langDic[self.langName]['e002_decomposeMatrixNotFound'])
                if loadedMatrixPlugin:
                    self.mirrorAxis = item
                    cmds.setAttr(self.moduleGrp+".mirrorAxis", self.mirrorAxis, type='string')
                    self.createPreviewMirror() 
Example #28
Source File: dpLayoutClass.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def changeShapeSize(self, *args):
        """ Set the attribute value for shapeSize.
        """
        cmds.setAttr(self.moduleGrp+".shapeSize", cmds.floatField(self.shapeSizeFF, query=True, value=True)) 
Example #29
Source File: dpLayoutClass.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def changeFlip(self, *args):
        """ Set the attribute value for flip.
        """
        cmds.setAttr(self.moduleGrp+".flip", cmds.checkBox(self.flipCB, query=True, value=True)) 
Example #30
Source File: dpBaseControlClass.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def addControlInfo(self, cvNode, className=True, size=True, degree=True, direction=True, rot=True, dpGuide=False, *args):
        """ Add some information in the curve transform node of the control.
        """
        cmds.addAttr(cvNode, longName="dpControl", attributeType='bool')
        cmds.setAttr(cvNode+".dpControl", 1)
        if dpGuide:
            cmds.addAttr(cvNode, longName="dpGuide", attributeType='bool')
            cmds.setAttr(cvNode+".dpGuide", 1)
        cmds.addAttr(cvNode, longName="version", dataType='string')
        cmds.setAttr(cvNode+".version", self.dpUIinst.dpARVersion, type="string")
        if self.cvID:
            cmds.addAttr(cvNode, longName="controlID", dataType='string')
            cmds.setAttr(cvNode+".controlID", self.cvID, type="string")
        if className:
            cmds.addAttr(cvNode, longName="className", dataType='string')
            cmds.setAttr(cvNode+".className", self.guideModuleName, type="string")
        if size:
            cmds.addAttr(cvNode, longName="size", attributeType='float')
            cmds.setAttr(cvNode+".size", self.cvSize)
        if degree:
            cmds.addAttr(cvNode, longName="degree", attributeType='short')
            cmds.setAttr(cvNode+".degree", self.cvDegree)
        if direction:
            cmds.addAttr(cvNode, longName="direction", dataType='string')
            cmds.setAttr(cvNode+".direction", self.cvDirection, type="string")
        if rot:
            cmds.addAttr(cvNode, longName="cvRotX", attributeType='double')
            cmds.addAttr(cvNode, longName="cvRotY", attributeType='double')
            cmds.addAttr(cvNode, longName="cvRotZ", attributeType='double')
            cmds.setAttr(cvNode+".cvRotX", self.cvRot[0])
            cmds.setAttr(cvNode+".cvRotY", self.cvRot[1])
            cmds.setAttr(cvNode+".cvRotZ", self.cvRot[2])