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