當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。