当前位置: 首页>>代码示例>>Python>>正文


Python NodeUtility.getFrameRootAllChildren方法代码示例

本文整理汇总了Python中marigold.utility.NodeUtility.getFrameRootAllChildren方法的典型用法代码示例。如果您正苦于以下问题:Python NodeUtility.getFrameRootAllChildren方法的具体用法?Python NodeUtility.getFrameRootAllChildren怎么用?Python NodeUtility.getFrameRootAllChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marigold.utility.NodeUtility的用法示例。


在下文中一共展示了NodeUtility.getFrameRootAllChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mirrorModule

# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getFrameRootAllChildren [as 别名]
def mirrorModule():
    # Mirrors a module.
    selList = cmds.ls( selection=True, long=True )
    if len( selList ) == 1:
        # Prompt for axis.
        mirrorAxis = int( cmds.layoutDialog( ui=mirrorObjectPrompt ) )
        
        inBitObj = selList[0]
    
        # Check if selected bit is the root.
        if NodeUtility.attributeCheck( inBitObj, 'frameRoot' ):
            # This is the root bit of the module. From here we know we can get the
            # meta node by accessing the frameRoot attribute.
            metaNode = NodeUtility.getNodeAttrDestination( inBitObj, 'frameRoot' )[0]
        else:
            # The selected bit is not the root. Run through each custom attribute
            # to find one connected to the meta node.
            attrList = cmds.listAttr( inBitObj, userDefined=True )
            for attr in attrList:
                connection = NodeUtility.getNodeAttrDestination( inBitObj, attr )
                if NodeUtility.attributeCheck( connection[0], 'metaType' ):
                    metaNode = connection[0]
                    break
                
        # Now that we have the meta node, we need the XML file name and it's location.
        metaClassPlug = NodeUtility.getPlug( metaNode, 'metaClass' )
        metaClassValue = NodeUtility.getPlugValue( metaClassPlug )
        
        metaBuildFolderPlug = NodeUtility.getPlug( metaNode, 'buildFolder' )
        metaBuildFolderValue = NodeUtility.getPlugValue( metaBuildFolderPlug )
        
        # Create the target module.
        '''
        NEED TO FIX THIS!
        targetRootBit = buildFrameModule( metaBuildFolderValue, metaClassValue )
        '''
    
        # Loop through each object in the source module.
        metaRootBit = NodeUtility.getNodeAttrSource( metaNode, 'rootBit' )[0]
        
        sourceChildBits = NodeUtility.getFrameRootAllChildren( metaRootBit )
        targetChildBits = NodeUtility.getFrameRootAllChildren( targetRootBit )
        
        sourceBits = []
        targetBits = []
        
        for i,bit in enumerate( sourceChildBits ):
            sourceBits.append( bit )
        sourceBits.insert( 0, metaRootBit )
        
        for i, bit in enumerate( targetChildBits ):
            targetBits.append( bit )
        targetBits.insert( 0, targetRootBit )
        
        for bit in xrange( len(sourceBits) ):
            # Mirror the source onto the target.
            mirrorObject( inSourceObj=sourceBits[bit], inTargetObj=targetBits[bit], inMirrorAxis=mirrorAxis )
开发者ID:EriLee,项目名称:marigold,代码行数:59,代码来源:TransformUtility.py

示例2: writeModuleXML

# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getFrameRootAllChildren [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:
#.........这里部分代码省略.........
开发者ID:EriLee,项目名称:marigold,代码行数:103,代码来源:XMLUtility.py


注:本文中的marigold.utility.NodeUtility.getFrameRootAllChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。