当前位置: 首页>>代码示例>>Python>>正文


Python cmds.getAttr方法代码示例

本文整理汇总了Python中maya.cmds.getAttr方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.getAttr方法的具体用法?Python cmds.getAttr怎么用?Python cmds.getAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.getAttr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dpSelectAllCtrls

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def dpSelectAllCtrls(self, allGrpNode, *args):
        """ Select all controls using All_Grp.
        """
        ctrlsToSelectList = []
        if cmds.objExists(allGrpNode+"."+self.ctrlsAttr):
            ctrlsAttr = cmds.getAttr(allGrpNode+"."+self.ctrlsAttr)
            if ctrlsAttr:
                currentNamespace = ""
                if ":" in allGrpNode:
                    currentNamespace = allGrpNode[:allGrpNode.find(":")]
                ctrlsList = ctrlsAttr.split(";")
                if ctrlsList:
                    for ctrlName in ctrlsList:
                        if ctrlName:
                            if currentNamespace:
                                ctrlsToSelectList.append(currentNamespace+":"+ctrlName)
                            else:
                                ctrlsToSelectList.append(ctrlName)
                    cmds.select(ctrlsToSelectList)
                    print self.langDic[self.langName]["m169_selectedCtrls"]+str(ctrlsToSelectList)
            else:
                mel.eval("warning \""+self.langDic[self.langName]["e019_notFoundAllGrp"]+"\";") 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:24,代码来源:dpSelectAllControls.py

示例2: playblast_snapshot

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def playblast_snapshot(path = None,format = None, compression = None, hud = None, offscreen = None, range=None, scale = None):
    current_image_format = cmds.getAttr("defaultRenderGlobals.imageFormat")
    cmds.setAttr("defaultRenderGlobals.imageFormat", 32) # *.png

    if range is None:
        
        range = playback_selection_range()
        print range
        if range is None:
        
            start = cmds.playbackOptions( q=True,min=True )
            end  = cmds.playbackOptions( q=True,max=True )
            range = [start, end]
 	
    cmds.playblast(frame =int((range[0] + range[1])/2), cf = path, fmt="image",  orn=hud, os=offscreen, wh = scene_resolution(), p=scale, v=False) 
    
    cmds.setAttr("defaultRenderGlobals.imageFormat", current_image_format) 
开发者ID:liorbenhorin,项目名称:pipeline,代码行数:19,代码来源:maya_warpper.py

示例3: parse_active_scene

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def parse_active_scene():
    """Parse active scene for arguments for capture()

    *Resolution taken from render settings.

    """

    time_control = mel.eval("$gPlayBackSlider = $gPlayBackSlider")

    return {
        "start_frame": cmds.playbackOptions(minTime=True, query=True),
        "end_frame": cmds.playbackOptions(maxTime=True, query=True),
        "width": cmds.getAttr("defaultResolution.width"),
        "height": cmds.getAttr("defaultResolution.height"),
        "compression": cmds.optionVar(query="playblastCompression"),
        "filename": (cmds.optionVar(query="playblastFile")
                     if cmds.optionVar(query="playblastSaveToFile") else None),
        "format": cmds.optionVar(query="playblastFormat"),
        "off_screen": (True if cmds.optionVar(query="playblastOffscreen")
                       else False),
        "show_ornaments": (True if cmds.optionVar(query="playblastShowOrnaments")
                       else False),
        "quality": cmds.optionVar(query="playblastQuality"),
        "sound": cmds.timeControl(time_control, q=True, sound=True) or None
    } 
开发者ID:bumpybox,项目名称:pyblish-bumpybox,代码行数:27,代码来源:capture.py

示例4: getBaseCtrl

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def getBaseCtrl(self, sCtrlType, sAttrName, sCtrlName, fRadius, iDegree = 1, iSection = 8):
        nCtrl = None
        self.ctrlCreated = False
        try:
            nCtrl= self.masterGrp.getAttr(sAttrName)
        except pymel.MayaAttributeError:
            try:
                nCtrl = pymel.PyNode(self.prefix + sCtrlName)
            except pymel.MayaNodeError:
                if (sCtrlName != (self.prefix + "Option_Ctrl")):
                    nCtrl = pymel.PyNode(self.ctrls.cvControl(sCtrlType, sCtrlName, r=fRadius, d=iDegree, dir="+X"))
                else:
                    nCtrl = pymel.PyNode(self.ctrls.cvCharacter(sCtrlType, sCtrlName, r=(fRadius*0.2)))
                self.ctrlCreated = True
            finally:
                #Since there is no connection between the master and the node found, create the connection
                self.masterGrp.addAttr(sAttrName, attributeType='message')
                nCtrl.message.connect(self.masterGrp.attr(sAttrName))

        return nCtrl 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:22,代码来源:dpAutoRig.py

示例5: verifyGuideModuleIntegrity

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def verifyGuideModuleIntegrity(self, *args):
        """ This function verify the integrity of the current module.
            Returns True if Ok and False if Fail.
        """
        # conditionals to be elegible as a rigged guide module:
        if cmds.objExists(self.moduleGrp):
            if cmds.objExists(self.moduleGrp+'.guideBase'):
                if cmds.getAttr(self.moduleGrp+'.guideBase') == 1:
                    return True
                else:
                    try:
                        self.deleteModule()
                        mel.eval('warning \"'+ self.langDic[self.langName]['e000_GuideNotFound'] +' - '+ self.moduleGrp +'\";')
                    except:
                        pass
                    return False 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:18,代码来源:dpBaseClass.py

示例6: setSourceColorOverride

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def setSourceColorOverride(self, sourceItem, destinationList, *args):
        """ Check if there's a colorOverride for destination shapes
            and try to set it to source shapes.
        """
        colorList = []
        for item in destinationList:
            childShapeList = cmds.listRelatives(item, shapes=True, type="nurbsCurve", fullPath=True)
            if childShapeList:
                for childShape in childShapeList:
                    if cmds.getAttr(childShape+".overrideEnabled") == 1:
                        if cmds.getAttr(childShape+".overrideRGBColors") == 1:
                            colorList.append(cmds.getAttr(childShape+".overrideColorR"))
                            colorList.append(cmds.getAttr(childShape+".overrideColorG"))
                            colorList.append(cmds.getAttr(childShape+".overrideColorB"))
                            self.colorShape([sourceItem], colorList, True)
                        else:
                            colorList.append(cmds.getAttr(childShape+".overrideColor"))
                            self.colorShape([sourceItem], colorList[0])
                        break 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:21,代码来源:dpControls.py

示例7: findModuleLastNumber

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def findModuleLastNumber(className, typeName):
    """ Find the last used number of this type of module.
        Return its highest number.
    """
    # work with rigged modules in the scene:
    numberList = []
    guideTypeCount = 0
    # list all transforms and find the existing value in them names:
    transformList = cmds.ls(selection=False, transforms=True)
    for transform in transformList:
        if cmds.objExists(transform+"."+typeName):
            if cmds.getAttr(transform+"."+typeName) == className:
                numberList.append(className)
        # try check if there is a masterGrp and get its counter:
        if cmds.objExists(transform+".masterGrp") and cmds.getAttr(transform+".masterGrp") == 1:
            guideTypeCount = cmds.getAttr(transform+'.dp'+className+'Count')
    if(guideTypeCount > len(numberList)):
        return guideTypeCount
    else:
        return len(numberList) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:22,代码来源:dpUtils.py

示例8: getOriginedFromDic

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def getOriginedFromDic():
    """ List all transforms in the scene, verify if there is an originedFrom string attribute and store it value in a dictionary.
        Return a dictionary with originedFrom string as keys and transform nodes as values of these keys.
    """
    originedFromDic = {}
    allTransformList = cmds.ls(selection=False, type="transform")
    if allTransformList:
        for transform in allTransformList:
            if cmds.objExists(transform+".originedFrom"):
                tempOriginedFrom = cmds.getAttr(transform+".originedFrom")
                if tempOriginedFrom:
                    if not ";" in tempOriginedFrom:
                        originedFromDic[tempOriginedFrom] = transform
                    else:
                        tempOriginedFromList = tempOriginedFrom.split(";")
                        for orignedFromString in tempOriginedFromList:
                            originedFromDic[orignedFromString] = transform
    return originedFromDic 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:20,代码来源:dpUtils.py

示例9: clearNodeGrp

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def clearNodeGrp(nodeGrpName='dpAR_GuideMirror_Grp', attrFind='guideBaseMirror', unparent=False):
    """ Check if there is any node with the attribute attrFind in the nodeGrpName and then unparent its children and delete it.
    """
    if cmds.objExists(nodeGrpName):
        foundChildrenList = []
        childrenList = cmds.listRelatives(nodeGrpName, children=True, type="transform")
        if childrenList:
            for child in childrenList:
                if cmds.objExists(child+"."+attrFind) and cmds.getAttr(child+"."+attrFind) == 1:
                    foundChildrenList.append(child)
        if len(foundChildrenList) != 0:
            if unparent:
                for item in foundChildrenList:
                    cmds.parent(item, world=True)
                cmds.delete(nodeGrpName)
        else:
            cmds.delete(nodeGrpName) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:19,代码来源:dpUtils.py

示例10: splitCurveToParametersByParameter

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def splitCurveToParametersByParameter(curve, num):
    """
    Get a list of parameters evenly spaced along a curve, based on the
    division of its parameters. Ranges are normalizes to be between 0-1.

    :param str curve:
    :param int num:

    :return: parameters
    :rtype: list
    """
    increment = 1.0 / (num - 1)
    parameters = [i * increment for i in range(num)]

    if cmds.getAttr("{0}.form".format(curve)) == 2:
        parameters.insert(0, parameters[-1])
        parameters.pop(-1)

    return parameters


# ---------------------------------------------------------------------------- 
开发者ID:robertjoosten,项目名称:maya-spline-ik,代码行数:24,代码来源:curve.py

示例11: reset_actor

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def reset_actor():
    from . import sisidebar_sub
    sel = cmds.ls(sl=True, l=True)
    joints = cmds.ls(sl=True, l=True, type='joint')
    if not joints:
        joints = []
    for s in sel:
        if cmds.nodeType(s) == 'KTG_ModelRoot':
            child_joints = cmds.ls(cmds.listRelatives(s, ad=True, f=True), l=True, type='joint')
            if child_joints:
                joints += child_joints
    if not sel:
        joints = cmds.ls(l=True, type='joint')
    for j in joints:
        con_info = cmds.connectionInfo(j+'.bindPose', dfs=True)
        if not con_info:
            continue
        con_info = con_info[0]
        bind_info = con_info.replace('world', 'xform')
        pose = cmds.getAttr(bind_info)
        cmds.xform(j, m=pose)
    sisidebar_sub.get_matrix() 
开发者ID:ShikouYamaue,项目名称:SISideBar,代码行数:24,代码来源:transform.py

示例12: recordNodesMatrices

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def recordNodesMatrices(nodes, desiredTime):
    """get the matrices of the nodes provided and return a dict of
    node:matrix

    Args:
        nodes (list): of nodes

    Returns:
        dict: node:node matrix
    """
    nodeToMat_dict = {}
    for fk in nodes:
        fk = pm.PyNode(fk)
        nodeToMat_dict[fk.name()] = fk.getAttr("worldMatrix", time=desiredTime)

    return nodeToMat_dict 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:18,代码来源:anim_utils.py

示例13: _applied_camera_options

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def _applied_camera_options(options, panel):
    """Context manager for applying `options` to `camera`"""

    camera = cmds.modelPanel(panel, query=True, camera=True)
    options = dict(CameraOptions, **(options or {}))

    old_options = dict()
    for opt in options.copy():
        try:
            old_options[opt] = cmds.getAttr(camera + "." + opt)
        except:
            sys.stderr.write("Could not get camera attribute "
                             "for capture: %s" % opt)
            options.pop(opt)

    for opt, value in options.iteritems():
        cmds.setAttr(camera + "." + opt, value)

    try:
        yield
    finally:
        if old_options:
            for opt, value in old_options.iteritems():
                cmds.setAttr(camera + "." + opt, value) 
开发者ID:bumpybox,项目名称:pyblish-bumpybox,代码行数:26,代码来源:capture.py

示例14: is_locked

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def is_locked():
    """Query whether current scene is locked"""
    fname = cmds.file(query=True, sceneName=True)
    basename = os.path.basename(fname)

    if self._ignore_lock:
        return False

    try:
        return cmds.getAttr("lock.basename") == basename
    except ValueError:
        return False 
开发者ID:getavalon,项目名称:core,代码行数:14,代码来源:pipeline.py

示例15: read

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import getAttr [as 别名]
def read(node):
    """Return user-defined attributes from `node`"""

    data = dict()

    for attr in cmds.listAttr(node, userDefined=True) or list():
        try:
            value = cmds.getAttr(node + "." + attr, asString=True)

        except RuntimeError:
            # For Message type attribute or others that have connections,
            # take source node name as value.
            source = cmds.listConnections(node + "." + attr,
                                          source=True,
                                          destination=False)
            source = cmds.ls(source, long=True) or [None]
            value = source[0]

        except ValueError:
            # Some attributes cannot be read directly,
            # such as mesh and color attributes. These
            # are considered non-essential to this
            # particular publishing pipeline.
            value = None

        data[attr] = value

    return data 
开发者ID:getavalon,项目名称:core,代码行数:30,代码来源:lib.py


注:本文中的maya.cmds.getAttr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。