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


Python cmds.listAttr方法代碼示例

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


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

示例1: reset_all_keyable_attributes

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def reset_all_keyable_attributes(dagnodes, *args):  # @unusedVariable
    """Resets to default values all keyable attributes on the given node

    Args:
        dagnodes (list): Maya transform nodes to reset
        *args: State of the menu item (if existing) send by mgear's dagmenu
    """

    for node in dagnodes:
        keyable_attrs = cmds.listAttr(node, keyable=True)
        reset_selected_channels_value([node], keyable_attrs)


##################################################
# Transfer space
################################################## 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:18,代碼來源:anim_utils.py

示例2: blendShapeSampling

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def blendShapeSampling(node, interval=1):
    """
    Args:
      node (str)
      interval (int)
    
    Returns:
      int
    """
    assert cmds.nodeType(node) == 'blendShape', \
        "node must be a blendShape type"
    start = cmds.currentTime(q=1)
    
    attrs = cmds.listAttr('%s.weight' % node, m=1)
    attrData = {node: [[attr, 0.0, 1.0] for attr in attrs]}
    
    currTime = attrsSampling(attrData, interval)

    end = currTime-1
    utils.trimTimeRange(start, end)
    cmds.currentTime(start)

#---------------------------------------------------------------------- 
開發者ID:WebberHuang,項目名稱:DeformationLearningSolver,代碼行數:25,代碼來源:samplingFunc.py

示例3: keys

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def keys(self):

		# TODO MIKE: I had to do a try except here for the the object called "|groundPlane_transform".
		# It's apparently always in the scene and error with that line.
		try:
			keys = cmds.listAttr(cross3d.SceneWrapper._mObjName(self._nativePointer), userDefined=True)
			if keys:
				return keys
		except ValueError:
			pass
		return []
		
		# http://forums.cgsociety.org/showthread.php?t=888612
		# Note: I was unable to find a way to identify userDefined keys in the following method
		# so I used the maya.cmds method. If possible this finish this method and replace the 
		# above code.
		#depNode = om.MFnDependencyNode(mObj)
		#total = depNode.attributeCount()
		#count = 0
		#while count < total:
		#	attr = depNode.attribute(count)
		#	plug = om.MPlug(mObj, attr)
		#	count += 1
		#	print count, attr.apiTypeStr(), plug.name() 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:26,代碼來源:mayauserprops.py

示例4: _normalizeAttributeShortName

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def _normalizeAttributeShortName(cls, name, uniqueOnObj=None):
		""" Creates a shortName for the provided attribute name by calling MayaSceneWrapper._normalizeAttributeName.
		It then adds the first character to any capital letters in the rest of the name. The name is then lowercased.
		If uniqueOnObj is provided with a object, it will ensure the returned attribute name is 
		unique by attaching a 3 digit padded number to it. It will be the lowest available number.
		:param name: The string used to generate the short name.
		:param uniqueOnObj: Ensure the name is unque. Defaults to None.
		:return: string
		"""
		name = cls._normalizeAttributeName(name)
		if len(name):
			name = name[0] + re.sub(r'[a-z]', '', name[1:])
		name = name.lower()
		if uniqueOnObj:

			# Ensure a unique object name by adding a value to the number.
			# TODO MIKE: Same issue with the "|groundPlane_transform".
			try:
				names = set(cmds.listAttr(cls._mObjName(uniqueOnObj), shortNames=True))
				name = api.Scene._findUniqueName(name, names, incFormat='{name}{count}')
			except ValueError:
				pass

		return name 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:26,代碼來源:mayascenewrapper.py

示例5: convertSkelSettingsToNN

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def convertSkelSettingsToNN(delete=1):
        orig = 'SkeletonSettings_Cache'
        if cmds.objExists(orig):
            if cmds.nodeType(orig) == 'unknown':
                new = cmds.createNode('network')
                for att in cmds.listAttr(orig):
                    if not cmds.attributeQuery(att, node=new, exists=1):
                        typ = cmds.attributeQuery(att, node=orig, at=1)
                        if typ == 'typed':
                            cmds.addAttr(new, longName=att, dt='string')
                            if cmds.getAttr(orig + '.' + att):
                                cmds.setAttr(new + '.' + att, cmds.getAttr(orig + '.' + att), type='string')
                        elif typ == 'enum':
                            cmds.addAttr(new, longName=att, at='enum', enumName=cmds.attributeQuery(att, node=orig, listEnum=1)[0])
                cmds.delete(orig)
                cmds.rename(new, 'SkeletonSettings_Cache') 
開發者ID:chrisevans3d,項目名稱:uExport,代碼行數:18,代碼來源:uExport.py

示例6: node_attributes

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def node_attributes(node):
    """
    Get Maya node attributes
    """
    attributes = cmds.listAttr(node)
    attr = {}
    attr["node_name"] = node
    attr["node_type"] = cmds.nodeType(node)
    for attribute in attributes:
        if "." in attribute:
            continue
        try:
            val = cmds.getAttr(node + "." + attribute)
        except RuntimeError:
            continue
        attr[attribute] = val
    return attr 
開發者ID:ababak,項目名稱:maya2katana,代碼行數:19,代碼來源:utils.py

示例7: channels

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def channels(self):
        '''
        The keySelection's channels list.
        '''

        if not self._channels:

            if self._curves:
                for c in self._curves:
                    self._channels.append(getChannelFromAnimCurve(c))
            elif self._nodes:
                for obj in self._nodes:
                    keyable = mc.listAttr(obj, keyable=True, unlocked=True, hasData=True, settable=True)
                    if keyable:
                        for attr in keyable:
                            self._channels.append('.'.join((obj, attr)))

        return self._channels 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:20,代碼來源:ml_utilities.py

示例8: read

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [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

示例9: reorderAttributes

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def reorderAttributes(self, objList, attrList, *args):
        """ Reorder Attributes of a given objectList following the desiredAttribute list.
            Useful for organize the Option_Ctrl attributes, for example.
        """
        if objList and attrList:
            for obj in objList:
                # load dpReorderAttribute:
                dpRAttr = dpReorderAttr.ReorderAttr(self, self.langDic, self.langName, False)
                # Reordering Option_Ctrl attributos progress window
                progressAmount = 0
                cmds.progressWindow(title='Reordering Attributes', progress=progressAmount, status='Reordering: 0%', isInterruptable=False)
                nbDesAttr = len(attrList)
                delta = 0
                for i, desAttr in enumerate(attrList):
                    # update progress window
                    progressAmount += 1
                    cmds.progressWindow(edit=True, maxValue=nbDesAttr, progress=progressAmount, status=('Reordering: ' + `progressAmount` + ' '+ obj + ' attributes'))
                    # get current user defined attributes:
                    currentAttrList = cmds.listAttr(obj, userDefined=True)
                    if desAttr in currentAttrList:
                        cAttrIndex = currentAttrList.index(desAttr)
                        maxRange = cAttrIndex+1-i+delta
                        for n in range(1, maxRange):
                            dpRAttr.dpMoveAttr(1, [obj], [desAttr])
                    else:
                        delta = delta+1
                cmds.progressWindow(endProgress=True)
                dpRAttr.dpCloseReorderAttrUI() 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:30,代碼來源:dpAutoRig.py

示例10: copyAttr

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def copyAttr(self, sourceItem=False, attrList=False, verbose=False, *args):
        """ Get and store in a dictionary the attributes from sourceItem.
            Returns the dictionary with attribute values.
        """
        # getting sourceItem:
        if not sourceItem:
            selList = cmds.ls(selection=True, long=True)
            if selList:
                sourceItem = selList[0]
            else:
                print self.dpUIinst.langDic[self.dpUIinst.langName]["e015_selectToCopyAttr"]
        if cmds.objExists(sourceItem):
            if not attrList:
                # getting channelBox selected attributes:
                currentAttrList = cmds.channelBox('mainChannelBox', query=True, selectedMainAttributes=True)
                if not currentAttrList:
                    # list all attributes if nothing is selected:
                    currentAttrList = cmds.listAttr(sourceItem, visible=True, keyable=True)
                attrList = currentAttrList
            if attrList:
                # store attribute values in a dic:
                self.attrValueDic = {}
                for attr in attrList:
                    if cmds.objExists(sourceItem+'.'+attr):
                        value = cmds.getAttr(sourceItem+'.'+attr)
                        self.attrValueDic[attr] = value
                if verbose:
                    print self.dpUIinst.langDic[self.dpUIinst.langName]["i125_copiedAttr"]
        return self.attrValueDic 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:31,代碼來源:dpControls.py

示例11: zeroOut

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def zeroOut(transformList=[], offset=False):
    """ Create a group over the transform, parent the transform in it and set zero all transformations of the transform node.
        If don't have a transformList given, try to get the current selection.
        If want to create with offset, it'll be a, offset group between zeroGrp and transform.
        Return a list of names of the zeroOut groups.
    """
    zeroList = []
    if not transformList:
        transformList = cmds.ls(selection=True)
    if transformList:
        for transform in transformList:
            zeroGrp = cmds.duplicate(transform, name=transform+'_Zero_Grp')[0]
            zeroUserAttrList = cmds.listAttr(zeroGrp, userDefined=True)
            if zeroUserAttrList:
                for zUserAttr in zeroUserAttrList:
                    try:
                        cmds.deleteAttr(zeroGrp+"."+zUserAttr)
                    except:
                        pass
            allChildrenList = cmds.listRelatives(zeroGrp, allDescendents=True, children=True, fullPath=True)
            if allChildrenList:
                cmds.delete(allChildrenList)
            if offset:
                offsetGrp = cmds.duplicate(zeroGrp, name=transform+'_Offset_Grp')[0]
                cmds.parent(transform, offsetGrp, absolute=True)
                cmds.parent(offsetGrp, zeroGrp, absolute=True)
            else:
                cmds.parent(transform, zeroGrp, absolute=True)
            zeroList.append(zeroGrp)
    return zeroList 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:32,代碼來源:dpUtils.py

示例12: reconnectAttr

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def reconnectAttr(self):
        base2d = self.place2dItems[0]
        del self.place2dItems[0]
        for place2d in self.place2dItems:
            attributes = cmds.listAttr(place2d)
            for attr in attributes:
                #接続されたノードを返す。pフラグでアトリビュート名を合わせて取得。
                connectItems = cmds.listConnections(place2d+'.'+attr, p=True, d=True, s=False)
                #接続を取得した変數がnoneTypeでなければ(接続があれば)
                if connectItems is not None:
                    for cItem in connectItems:
                        #アトリビュート接続
                        try:
                            cmds.connectAttr(base2d+'.'+attr, cItem, f=True)
                        except:
                            print 'can not connect : '+base2d+'.'+attr+' to '+cItem
                #ソース側の接続
                connectItems = cmds.listConnections(place2d+'.'+attr, p=True, d=False, s=True)
                if connectItems is not None:
                    for cItem in connectItems:
                        try:
                            cmds.connectAttr(cItem, base2d+'.'+attr, f=True)
                        except:
                            print 'can not connect : '+cItem+' to '+base2d+'.'+attr
        for place2d in self.place2dItems:
            deleteFlag = True#削除フラグ
            attributes = cmds.listAttr(place2d)
            for attr in attributes:
                if attr != 'message':
                    #接続されたノードを返す。pフラグでアトリビュート名を合わせて取得。
                    connectItems = cmds.listConnections(place2d+'.'+attr, p=True)
                    #接続を取得した変數がnoneTypeでなければ(接続があれば)
                    if not isinstance(connectItems,type(None)):
                        deleteFlag = False#削除フラグをFalseに
            if deleteFlag is True:
                cmds.delete(place2d)
                
            
    #再帰処理しながら末端のplace2dノードを探索する 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:41,代碼來源:texture.py

示例13: save_cluster

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def save_cluster(node):
    #ノードの中からスキンクラスタを取得してくる#inMesh直上がSkinClusterとは限らないので修正
    srcDeformerCluster = cmds.ls(cmds.listHistory(node),type='cluster')
    if not srcDeformerCluster:
        return#スキンクラスタがなかったら関數抜ける
    #スキンクラスタのパラメータ色々を取得しておく
    srcDeformerCluster = srcDeformerCluster[0]
    attributes = cmds.listAttr(srcDeformerCluster)
    weightList = cmds.getAttr(srcDeformerCluster+'.weightList[0]')
    envelope = cmds.getAttr(srcDeformerCluster+'.envelope')
    clusterMssage = cmds.getAttr(srcDeformerCluster+'.message')
    clusterWeight = cmds.getAttr(srcDeformerCluster+'.weightList[0].weights') 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:14,代碼來源:freeze.py

示例14: listAttrForMirror

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def listAttrForMirror(node):
    """List attributes to invert the value for mirror posing

    Args:
        node (PyNode): The Node with the attributes to invert

    Returns:
        list: Attributes to invert
    """
    # TODO: should "ro" be here?
    res = ["tx", "ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz"]
    res.extend(pm.listAttr(node, userDefined=True, shortNames=True))
    res = list(filter(lambda x: not x.startswith("inv"), res))

    return res 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:17,代碼來源:anim_utils.py

示例15: updateSearch

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import listAttr [as 別名]
def updateSearch(self, matchString, nodes):    
        """
        Loop over all keyable attributes and match them with the search string.
        
        :param str matchString: Search string to match with attributes
        :param list nodes: List of nodes to process the attributes from
        """
        # reset of search string is empty
        if not matchString:
            cmds.channelBox(CHANNELBOX, edit=True, fixedAttrList=[])
            return
    
        # split match string
        matches = []
        matchStrings = matchString.lower().split()
        
        # get matching attributes
        for node in nodes:
            attrs = cmds.listAttr(node, k=True, v=True)
            
            for attr in attrs:
                if (
                    not attr in matches and 
                    self.matchSearch(attr, matchStrings)
                ):
                    matches.append(attr)
               
        # append null if not matches are found ( cannot use empty list )
        if not matches:
            matches.append("null")

        # filter channel box
        cmds.channelBox(CHANNELBOX, edit=True, fixedAttrList=matches)
        
    # ------------------------------------------------------------------------ 
開發者ID:robertjoosten,項目名稱:maya-channel-box-plus,代碼行數:37,代碼來源:ui.py


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