當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.setAttr方法代碼示例

本文整理匯總了Python中maya.cmds.setAttr方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.setAttr方法的具體用法?Python cmds.setAttr怎麽用?Python cmds.setAttr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.setAttr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: reset_resolution

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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) 
開發者ID:getavalon,項目名稱:core,代碼行數:23,代碼來源:commands.py

示例2: lock

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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") 
開發者ID:getavalon,項目名稱:core,代碼行數:22,代碼來源:pipeline.py

示例3: setControlDirection

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:23,代碼來源:dpBaseControlClass.py

示例4: generateCombineCurves

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:19,代碼來源:dpSmile.py

示例5: changeStyle

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:27,代碼來源:dpLimb.py

示例6: reOrientGuide

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:18,代碼來源:dpLimb.py

示例7: changeEyelid

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:20,代碼來源:dpEye.py

示例8: createEyelidJoints

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:26,代碼來源:dpEye.py

示例9: createGuide

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:22,代碼來源:dpSpine.py

示例10: loadGeo

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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') 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:18,代碼來源:dpLayoutClass.py

示例11: cvLocator

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:20,代碼來源:dpControls.py

示例12: pasteAttr

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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"] 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:23,代碼來源:dpControls.py

示例13: shapeSizeSetup

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:20,代碼來源:dpControls.py

示例14: __createControl

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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
        
    # ------------------------------------------------------------------------ 
開發者ID:robertjoosten,項目名稱:maya-spline-ik,代碼行數:21,代碼來源:create.py

示例15: __normalizeSlideAttributes

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setAttr [as 別名]
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 
開發者ID:robertjoosten,項目名稱:maya-spline-ik,代碼行數:27,代碼來源:create.py


注:本文中的maya.cmds.setAttr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。