コード例 #1
0
ファイル: __init__.py プロジェクト: EriLee/marigold
def addComponentToObject( inClassType, **kwargs ):    
    if kwargs.has_key('inObject'):
        targetObj = kwargs['inObject']
        print 'targetObj: {0}'.format( targetObj )
        del kwargs['inObject']
        prevSel = None
    else:
        selList = cmds.ls( selection=True, long=True )
        if len( selList ) is 1:
            targetObj = selList[0]
            prevSel = selList[0]
    
    if targetObj is not None:
        component_class = str_to_class( inClassType )
        newNode = component_class.createCompNode( inClassType, **kwargs )
        
        # Add the component attribute to the object.
        NodeUtility.addPlug( targetObj, newNode.name(), 'attributeType', 'message' )
        nodePlug = '{0}.parentName'.format( newNode.name() )
        objectPlug = '{0}.{1}'.format( targetObj, newNode.name() )
        NodeUtility.connectPlugs( objectPlug, nodePlug )
        if prevSel is not None:
            cmds.select( prevSel )
            
        return newNode
コード例 #2
0
ファイル: qtui.py プロジェクト: EriLee/marigold
 def addComponentToObject( self, inClassType ):
     selList = cmds.ls( selection=True, long=True )
     if len( selList ) is 1:
         prevSel = selList[0]
         component_class = Components.str_to_class( inClassType )
         newNode = component_class.createCompNode( inClassType )
         
         # Add the component attribute to the object.
         FrameUtility.addPlug( selList[0], newNode.name(), 'attributeType', 'message' )
         nodePlug = '{0}.parentName'.format( newNode.name() )
         objectPlug = '{0}.{1}'.format( selList[0], newNode.name() )
         NodeUtility.connectPlugs( objectPlug, nodePlug )
         cmds.select( prevSel )
コード例 #3
0
ファイル: mainGUI.py プロジェクト: EriLee/marigold
 def addComponentToObject( self, inClassType ):
     '''
     '''
     selList = cmds.ls( selection=True, long=True )
     if len( selList ) is 1:
         prevSel = selList[0]
         newNode = componentNodes.jointComponentNode().createCompNode( inClassType )
         # Add the component attribute to the object.
         FrameUtility.addPlug( selList[0], newNode.name(), 'attributeType', 'message' )
         #cmds.addAttr( inObject, longName='jointComponent', attributeType='message', storable=False )
         nodePlug = '{0}.parentName'.format( newNode.name() )
         objectPlug = '{0}.{1}'.format( selList[0], newNode.name() )
         NodeUtility.connectPlugs( objectPlug, nodePlug )
         cmds.select( prevSel )
コード例 #4
0
ファイル: FrameUtility.py プロジェクト: EriLee/marigold
def buildFrameModule( inDir=None, inXMLFile=None ):
    from marigold.meta.metaNode import MetaNode
    
    # Get the XML settings for the frame module.
    dirPath = XMLUtility.getPresetPath( XMLUtility.FRAME_PRESETS_PATH+inDir )
    fullPath = dirPath+'/'+inXMLFile+'.xml'
    xmlDict = readFrameModuleXML( fullPath )
    
    # Get the metanode.
    metanode = xmlDict['metanode']
    meta = metanode['name']
    metaPlugs = metanode['plugs']
    metaType = metanode['metaType']
    metaClass = metanode['metaClass']
    
    metanode = MetaNode( inNodeName=meta, inNodeMetaType=metaType )
    metanode = cmds.ls( selection=True )[0]
    
    metaPlugs = xmlDict['metanode']['plugs']
    for plug in metaPlugs:
        if not NodeUtility.attributeCheck( metanode, plug['name'] ):
            addPlug( metanode, plug['name'], plug['attrType'], plug['attrDataType'] )
        if plug['connected'] == 'False':
            setPlug( metanode, plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
    
    # Get the bits.
    bits = xmlDict['bits']
    
    # Make a group for the module.
    for bit in bits:
        if bit['name'] == 'frame_root':
            for plug in bit['plugs']:
                if plug['name'] == 'prefix':
                    modulePrefix = plug['value']
                    break
                
    moduleGroup = '|{0}'.format( cmds.group( em=True, name=modulePrefix+'_'+metaClass ) )

    # Make each bit.
    tick = 0
    storeBitConnections = []

    while tick < len(bits):
        bitName = bits[0]['name']
        if bits[0]['parent'] == 'None':
            # This is the root bit. The | is there to represent this. We don't need it now.
            # Plus it causes problems with the full path name stuff (double ||). So we
            # remove it.
            bitParent = moduleGroup
        else:
            bitParent = moduleGroup+bits[0]['parent']
        bitPlugs = bits[0]['plugs']
        bitShape = bits[0]['shape']
        
        # Make the bit.
        if cmds.objExists( bitParent ):
            newBit = cmds.makeGLBit( name=bitName, objecttype=bits[0]['shapeType'] )            
            cmds.parent( newBit, bitParent )
            
            # From this point we use the long name for the bit. This avoids any
            # name clashes.
            fullBitName = '{0}{1}'.format( bitParent, newBit )
            # Get the frame_root for the module. We want to return this at the very end.
            if bitName == 'frame_root':
                rootFullName = fullBitName
            
            # Setup plugs for transform and custom attributes.
            for plug in bitPlugs:
                if not NodeUtility.attributeCheck( fullBitName, plug['name'] ):
                    addPlug( fullBitName, plug['name'], plug['attrType'], plug['attrDataType'] )
                    if plug['value'] is not None:
                        setPlug( fullBitName, plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
                else:          
                    # Setup position and rotation.
                    setPlug( fullBitName, plug['name'], plug['value'] )
            
                # Connect plug to meta node.
                for mplug in metaPlugs:
                    if '{0}.{1}'.format(bitName, plug['name']) == mplug['value']:
                        inSourcePlug = fullBitName+'.'+plug['name']
                        inDestinationPlug = metanode+'.'+mplug['name']
                        NodeUtility.connectPlugs( inSourcePlug, inDestinationPlug )
                        
            # Setup plugs for shape attributes.
            shapeName = cmds.listRelatives( fullBitName, shapes=True )
            fullShapeName = '{0}|{1}'.format( fullBitName, shapeName[0] )
            for plug in bitShape:
                if plug['attrDataType'] == 'TdataCompound':
                    # We skip compound nodes at this stage. They are for the child arrow drawing and must be
                    # hooked up after all the objects are created.
                    connectionChild = '{0}{1}'.format( moduleGroup, plug['value'] )
                    storeBitConnections.append( { 'parent':fullBitName, 'child':connectionChild } )
                else:
                    setPlug( fullShapeName, plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
                           
            bits.remove( bits[0] )
        else:
            tick = tick+1
            pass
    
    # Now do the hook ups for the child arrows.
    for i in storeBitConnections:
        setBitChild( i['parent'], i['child'] )
    
    return rootFullName