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


Python cmds.attributeQuery方法代碼示例

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


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

示例1: loadSelectedSet

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def loadSelectedSet(self):
        selection = BT_GetSelectedSet()
        if not selection:
            return False

        if not cmds.attributeQuery('Blend_Node', ex = True, n = selection):
            cmds.warning('Blend_Node attribute not found! This set might not be connected to a BlendTransforms node yet.')
            return False
        
        self.ui.poseList.clear()
        self.ui.setEdit.setText(selection)

        poses = BT_GetPosesFromSet(selection)
        if not poses:
            return False

        self.ui.poseList.addItems(poses)
        return True 
開發者ID:duncanskertchly,項目名稱:BlendTransforms,代碼行數:20,代碼來源:BlendTransforms.py

示例2: enumStringToValue

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def enumStringToValue(attr, lowercase=False):
    """
    Creates a dictionary mapper for enum values. This util can be used
    to set enum attributes with string values.

    :param str attr:
    :param bool lowercase: 
    :return: enumStringToValue
    :rtype: dict
    """
    node, attr = tuple(attr.split(".", 1))

    enumString = cmds.attributeQuery(attr, node=node, listEnum=True)[0]
    enumDict = {}

    for i, str in enumerate(enumString.split(":")):
        if lowercase:
            str = str.lower()

        enumDict[str] = i

    return enumDict 
開發者ID:robertjoosten,項目名稱:maya-spline-ik,代碼行數:24,代碼來源:attribute.py

示例3: convertSkelSettingsToNN

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

示例4: attributeMenuItem

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def attributeMenuItem(node, attr):

    plug = node+'.'+attr
    niceName = mc.attributeName(plug, nice=True)

    #get attribute type
    attrType = mc.getAttr(plug, type=True)

    if attrType == 'enum':
        listEnum = mc.attributeQuery(attr, node=node, listEnum=True)[0]
        if not ':' in listEnum:
            return
        listEnum = listEnum.split(':')
        mc.menuItem(label=niceName, subMenu=True)
        for value, label in enumerate(listEnum):
            mc.menuItem(label=label, command=partial(mc.setAttr, plug, value))
        mc.setParent('..', menu=True)
    elif attrType == 'bool':
        value = mc.getAttr(plug)
        label = 'Toggle '+ niceName
        mc.menuItem(label=label, command=partial(mc.setAttr, plug, not value)) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:23,代碼來源:ml_puppet.py

示例5: getRootAndCOM

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def getRootAndCOM(node):
    '''
    Given either the root or COM, return root and COM based on connections.
    '''

    com = None
    root = None

    if mc.attributeQuery(COM_ATTR, node=node, exists=True):
        com = node
        messageCon = mc.listConnections(com+'.'+COM_ATTR, source=True, destination=False)
        if not messageCon:
            raise RuntimeError('Could not determine root from COM, please select root and run again.')
        root = messageCon[0]
    else:
        messageCon = mc.listConnections(node+'.message', source=False, destination=True, plugs=True)
        if messageCon:
            for each in messageCon:
                eachNode, attr = each.rsplit('.',1)
                if attr == COM_ATTR:
                    com = eachNode
                    root = node
                    break

    return root, com 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:27,代碼來源:ml_centerOfMass.py

示例6: disconnect

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def disconnect(self, node, connectionType):
        import maya.cmds as cmds

        connections = []
        for connection in node.connections(type=connectionType, plugs=True):
            src = connection
            dst = connection.connections(
                destination=True, source=False, plugs=True
            )[0]

            # Skip locked attributes
            if dst.get(lock=True):
                continue

            connections.append({"source": src, "destination": dst})
            connection // dst

            # Reset attribute
            values = cmds.attributeQuery(
                dst.name(includeNode=False),
                node=node.name(),
                listDefault=True
            )
            try:
                cmds.setAttr(
                    node.name() + '.' + dst.name(includeNode=False), *values
                )
            except:
                pass

        return connections 
開發者ID:bumpybox,項目名稱:pyblish-bumpybox,代碼行數:33,代碼來源:extract_formats.py

示例7: BT_Setup

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def BT_Setup(set = None):
    
    if not set:
        return False

    transforms = cmds.listConnections(set +'.dagSetMembers')
    if not transforms:
        return False

    if not cmds.attributeQuery('Blend_Node', n = set, ex = True):
        cmds.addAttr(set, ln = 'Blend_Node', k = False, h = True, dt = 'string')
    else:
        return False

    btNode = cmds.createNode("BlendTransforms")
    cmds.setAttr(set +'.Blend_Node', btNode, type = "string")

    for i in range(0, len(transforms)):
        baseMatrix = cmds.xform(transforms[i], q = True, m = True)
        baseScale = cmds.getAttr(transforms[i] +'.scale')[0]
        baseRotOffset = [0.0, 0.0, 0.0]

        if cmds.objectType(transforms[i], isType = 'joint'):
            baseRotOffset = cmds.getAttr(transforms[i] +'.jointOrient')[0]

        btAttr = 'transforms[' +str(i) +'].baseMatrix'
        btScaleAttr = 'transforms[' +str(i) +'].baseScale'
        btRotOffsetAttr = 'transforms[' +str(i) +'].baseRotOffset'

        BT_MatrixValuesToNode(values = baseMatrix, node = btNode, attr = btAttr)
        BT_Double3ValuesToNode(values = baseScale, node = btNode, attr = btScaleAttr)
        BT_Double3ValuesToNode(values = baseRotOffset, node = btNode, attr = btRotOffsetAttr)
        BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i])

    return True 
開發者ID:duncanskertchly,項目名稱:BlendTransforms,代碼行數:37,代碼來源:BlendTransforms.py

示例8: rotationOrder

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def rotationOrder(self):
		""" Returns the cross3d.constants.RotationOrder enum for this object or zero """
		tform = self._mObjName(self._nativeTransform)
		selected = cmds.getAttr('{}.rotateOrder'.format(tform))
		enumValues = cmds.attributeQuery('rotateOrder', node=tform, listEnum=True)
		if enumValues:
			enumValues = enumValues[0].split(':')
		return RotationOrder.valueByLabel(enumValues[selected].upper()) 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:10,代碼來源:mayasceneobject.py

示例9: _setNativeRotationOrder

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def _setNativeRotationOrder(cls, nativePointer, order):
		""" Sets the transform rotation order for the provided object to the provided value.
		
		Args:
			order: cross3d.constants.RotationOrder enum
		"""
		# Set the rotation order for the camera.
		tform = cls._mObjName(cls._asMOBject(nativePointer))
		enumValues = cmds.attributeQuery('rotateOrder', node=tform, listEnum=True)
		if enumValues:
			enumValues = enumValues[0].split(':')
			rotName = RotationOrder.labelByValue(order)
			cmds.setAttr('{}.rotateOrder'.format(tform), enumValues.index(rotName.lower())) 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:15,代碼來源:mayasceneobject.py

示例10: can_access

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def can_access(self, datum, field_name):
        try:
            return cmds.ls(datum) and cmds.attributeQuery(field_name, node=datum, w=True)
        except RuntimeError:
            return False
        except TypeError:
            return False 
開發者ID:theodox,項目名稱:mGui,代碼行數:9,代碼來源:bindings.py

示例11: attrExists

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def attrExists(attr):
    if '.' in attr:
        node, att = attr.split('.')
        return cmds.attributeQuery(att, node=node, ex=1)
    else:
        cmds.warning('attrExists: No attr passed in: ' + attr)
        return False 
開發者ID:chrisevans3d,項目名稱:uExport,代碼行數:9,代碼來源:uExport.py

示例12: findImported

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def findImported(self):
        """
        findImported()  ->  list of (str nodeName, Asset)
            
            Searches the scene for all assets that have been imported
            and returns a list of tuples. The first element of each
            tuple is the name of the top node of the item in the scene,
            and the second element is the Asset object.
        """

        transforms = cmds.ls(type="transform", long=True)
        if not transforms:
            return []
        
        results = []

        for t in transforms:
            
            if not cmds.attributeQuery(self.ATTR_ASSET_NAME, node=t, exists=True):
                continue
            
            name = cmds.getAttr("%s.%s" % (t, self.ATTR_ASSET_NAME))
            show = cmds.getAttr("%s.%s" % (t, self.ATTR_ASSET_SHOW))

            self.show = show
            asset = self.list(name)

            if asset:
                asset = asset[0]
            else:
                asset = None

            results.append( (t, asset) )

        return results 
開發者ID:justinfx,項目名稱:tutorials,代碼行數:37,代碼來源:assetImporter4.py

示例13: attribute_type

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def attribute_type(a):
    tokens = a.split(".")
    node = tokens[0]
    attribute = tokens[-1]
    if attribute.startswith("worldMatrix"):
        # attributeQuery doesn't seem to work with worldMatrix
        return "matrix"
    return cmds.attributeQuery(attribute, node=node, at=True) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:10,代碼來源:dge.py

示例14: get_ramp_attr

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def get_ramp_attr(node_name, attr):
    """
    Translate the old attribute names if needed
    """
    if cmds.attributeQuery("colorRamp", node=node_name, exists=True):
        new_ramp_attributes = {
            r"^colors\[(\d+)\]$": r"^colorRamp\[(\d+)\]\.colorRamp_Color$",
            "colors[{index}]": "colorRamp[{index}].colorRamp_Color",
            "{node}.colors[{index}]": "{node}.colorRamp[{index}].colorRamp_Color",
            "{node}.positions[{index}]": "{node}.colorRamp[{index}].colorRamp_Position",
            "{node}.positions": "{node}.colorRamp",
        }
        attr = new_ramp_attributes.get(attr, attr)
    return attr 
開發者ID:ababak,項目名稱:maya2katana,代碼行數:16,代碼來源:__init__.py

示例15: editPivot

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import attributeQuery [as 別名]
def editPivot(self, *args):
        sel = mc.ls(sl=True)

        if not sel:
            om.MGlobal.displayWarning('Nothing selected.')
            return

        if len(sel) > 1:
            om.MGlobal.displayWarning('Only works on one node at a time.')
            return

        if mc.attributeQuery('ml_pivot_handle', exists=True, node=sel[0]):
            #we have a pivot handle selected
            return

        self.node = sel[0]

        if is_pivot_connected(sel[0]):
            driverAttr = pivot_driver_attr(sel[0])
            if driverAttr:
                self.editPivotDriver(driverAttr)
            else:
                om.MGlobal.displayWarning('Pivot attribute is connected, unable to edit.')
            return

        self.editPivotHandle() 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:28,代碼來源:ml_pivot.py


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