本文整理汇总了Python中marigold.utility.NodeUtility.getAttrMessageValue方法的典型用法代码示例。如果您正苦于以下问题:Python NodeUtility.getAttrMessageValue方法的具体用法?Python NodeUtility.getAttrMessageValue怎么用?Python NodeUtility.getAttrMessageValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marigold.utility.NodeUtility
的用法示例。
在下文中一共展示了NodeUtility.getAttrMessageValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: writeModuleXML
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getAttrMessageValue [as 别名]
def writeModuleXML( inRootObjectName, inModuleType, inModuleName ):
'''
Function for writing module xml.
@param inRootObjectName: String. Name of module root object.
@param inModuleType: String. Type of module. This determines which sub-folder the XML is saved.
@param inModuleName: String. Name of the module XML file.
'''
# Get list of the module hierarchy. Root is always first
hierarchyList = NodeUtility.getFrameRootAllChildren( inRootObjectName )
hierarchyList.insert( 0, inRootObjectName )
# START: Writing XML
xmlLines = []
xmlLines.append( '<data>' )
for item in hierarchyList:
# BIT INFO
itemName = getObjectShortName( item )
itemParent = NodeUtility.cleanParentFullName( item )
itemMatrix = TransformUtility.getMatrix( item, 'matrix' )
itemPosition = TransformUtility.getMatrixTranslation( itemMatrix, OpenMaya.MSpace.kTransform )
itemRotation = TransformUtility.getMatrixRotation( itemMatrix, 'eulerVector' )
# START: Bit
xmlLines.append( '\t<bit name=\"{0}\" parent=\"{1}\">'.format( itemName, itemParent ) )
xmlLines.append( '\t\t<plug name=\"translateX\">{0}</plug>'.format( itemPosition.x ) )
xmlLines.append( '\t\t<plug name=\"translateY\">{0}</plug>'.format( itemPosition.y ) )
xmlLines.append( '\t\t<plug name=\"translateZ\">{0}</plug>'.format( itemPosition.z ) )
xmlLines.append( '\t\t<plug name=\"rotateX\">{0}</plug>'.format( math.degrees(itemRotation.x) ) )
xmlLines.append( '\t\t<plug name=\"rotateY\">{0}</plug>'.format( math.degrees(itemRotation.y) ) )
xmlLines.append( '\t\t<plug name=\"rotateZ\">{0}</plug>'.format( math.degrees(itemRotation.z) ) )
# SHAPE
itemShape = NodeUtility.getDagPath( itemName ).child( 0 )
depFn = OpenMaya.MFnDependencyNode( itemShape )
shapeType = depFn.typeName()
if shapeType.find( 'gl' ) != -1:
itemShapeName = cmds.listRelatives( itemName, shapes=True, fullPath=True )[0]
# Start shape
xmlLines.append( '\t\t<shape name=\"{0}\">'.format( shapeType ) )
# Get the shape's local position and scale.
for attr in cmds.listAttr( itemShapeName, channelBox=True ):
types = NodeUtility.getAttrTypes( itemShapeName, attr )
aPlug = NodeUtility.getPlug( itemShapeName, attr )
xmlLines.append( '\t\t\t<plug name=\"{0}\" attrType=\"{1}\" attrDataType=\"{2}\">{3}</plug>'.format( attr, types[0], types[1], NodeUtility.getPlugValue(aPlug) ) )
# Get the shape's custom attributes.
for attr in cmds.listAttr( itemShapeName, multi=True, keyable=True ):
types = NodeUtility.getAttrTypes( itemShapeName, attr )
if attr.find( '[' ) is not -1:
# Special case handle array attributes. The [] needs to be removed so we can get
# the base name for the attribute. From there we can then loop through it's children.
# First we get the connection since these plugs won't return a value, but rather a
# connected node.
connection = NodeUtility.getNodeAttrSource( itemShapeName, attr )
bitChildren = cmds.listRelatives( itemName, type='transform', children=True, fullPath=True )
for child in bitChildren:
childSplit = child.split('|')
if childSplit[-1] == connection[0]:
plugValue = child
# Now we get the compound attribute's name by removing the index brackets.
attrSplit = attr.split('[')
attr = attrSplit[0]
else:
aPlug = NodeUtility.getPlug( itemShapeName, attr )
plugValue = NodeUtility.getPlugValue( aPlug )
if types[0] is not False:
xmlLines.append( '\t\t\t<plug name=\"{0}\" attrType=\"{1}\" attrDataType=\"{2}\">{3}</plug>'.format( attr, types[0], types[1], plugValue ) )
# End shape
xmlLines.append( '\t\t</shape>' )
# BIT COMPONENTS
print 'item: {0}'.format( item )
bitComponents = components.getComponents( item )
for comp in bitComponents:
# Component info
compName = ''.join(i for i in comp if not i.isdigit())
# Start component.
xmlLines.append( '\t\t<component name=\"{0}\">'.format( compName ) )
compSettings = NodeUtility.getModuleComponentSettings( comp )
for attr in compSettings:
types = NodeUtility.getAttrTypes( comp, attr )
# Special case message plugs.
if types[1] == 'message':
messageValues = NodeUtility.getAttrMessageValue( comp, attr )
if isinstance( messageValues, unicode ):
plugValue = messageValues
elif isinstance( messageValues, list ):
plugValue = None
else:
#.........这里部分代码省略.........