当前位置: 首页>>代码示例>>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;未经允许,请勿转载。