本文整理汇总了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
示例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
示例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')
示例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))
示例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
示例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
示例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
示例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())
示例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()))
示例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
示例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
示例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
示例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)
示例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
示例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()