예제 #1
0
 def preset_buttons( self, inPresetType ):
     '''
     Creates a module or character root, complete with appropriate meta nodes.
     
     @param inPresetType: Int. 1 is a module root. 2 is a character root.
     '''
     if inPresetType == 1:
         # Create module root.
         
         # Create the root bit.
         rootBit = cmds.makeGLBit( objecttype='glTorus', name='moduleRoot', color=(1.0,0.1,0.1),
                                   torSides=3, torRings=8, torOtRad=1.1, torInRad=1, drawPlace=0 )
         # Create the meta node.
         # Connect the node to the bit.
         pass 
     elif inPresetType == 2:
         # Create character root.
         
         # Create the root bit.
         rootBit = cmds.makeGLBit( objecttype='glTorus', name='characterRoot', color=(1.0,0.1,0.1),
                                   torSides=3, torRings=8, torOtRad=3.1, torInRad=3, drawPlace=1 )
         
         # Create the meta node.
         # Connect the node to the bit.
         pass
예제 #2
0
파일: mainGUI.py 프로젝트: EriLee/marigold
 def bitsGUI( self ):
     col = cmds.columnLayout( adjustableColumn=True, columnAttach=('both', 5), parent=self.fillArea )
     cmds.separator( style='none', height=4, width=413 )
     
     # Primitives section.
     cmds.text( label='BIT PRIMITIVES', height=20, font='boldLabelFont', backgroundColor=[0.2,0.2,0.2] )
     cmds.separator( style='none', height=5 )
     cmds.gridLayout( numberOfColumns=5, cellWidthHeight=( 50, 50 ) )
     cmds.button( label='Sphere', command=lambda b, a1='glSphere': cmds.makeGLBit( objecttype=a1 ) )
     cmds.button( label='Box', command=lambda b, a1='glBox': cmds.makeGLBit( objecttype=a1 ) )
     cmds.button( label='Cylinder', command=lambda b, a1='glCylinder': cmds.makeGLBit( objecttype=a1 ) )
     cmds.button( label='Cone', command=lambda b, a1='glCone': cmds.makeGLBit( objecttype=a1 ) )
     cmds.button( label='Torus', command=lambda b, a1='glTorus': cmds.makeGLBit( objecttype=a1 ) )
     cmds.setParent( '..' )#gridLayout
     cmds.separator( style='none', height=10 )
     
     # Transform section.
     cmds.text( label='TRANSFORM TOOLS', height=20, font='boldLabelFont', backgroundColor=[0.2,0.2,0.2] )
     cmds.separator( style='none', height=5 )
     cmds.gridLayout( numberOfColumns=3, cellWidthHeight=( 50, 50 ) )
     cmds.iconTextButton( annotation='match translation', style='iconOnly',
                          image1='icon_match_translation.png',
                          command=lambda a1='tran': TransformUtility.matchTransforms(a1) )
     cmds.iconTextButton( annotation='match rotation', style='iconOnly',
                          image1='icon_match_rotation.png',
                          label='match rotation', command=lambda a1='rot': TransformUtility.matchTransforms(a1) )
     cmds.iconTextButton( annotation='match all', style='iconOnly',
                          image1='icon_match_all.png',
                          label='match all', command=lambda a1='all': TransformUtility.matchTransforms(a1) )
     cmds.setParent( '..' )#gridLayout
     cmds.separator( style='none', height=10 )
     
     cmds.setParent( '..' )#col 
예제 #3
0
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
예제 #4
0
def loadModule( inFolder, inFileName ):
    '''
    Loads a module into the scene.
    
    @param inFolder: String. Name for the sub-folder the module XML is located.
    @param inFileName: String. Name of the module XML. 
    '''
    dirPath = getPresetPath( FRAME_PRESETS_PATH+inFolder )
    fullPath = dirPath+'/'+inFileName+'.xml'
    xmlFile = readModuleXML( fullPath )
    
    # Create a temp group to put the module inside while creating.
    moduleGroup = '|{0}'.format( cmds.group( em=True, name='TEMP' ) )
    
    # Grab all the bits.
    bits = xmlFile['bits']
    
    # Make each bit.
    tick = 0
    storeBitConnections = []

    while tick < len(bits):
        if bits[0]['parent'] == 'None':
            bitParent = moduleGroup
        else:
            bitParent = moduleGroup+bits[0]['parent']
        
        bitName = bits[0]['name']
        bitPlugs = bits[0]['plugs']
        shapePlugs = bits[0]['shape']
        bitComponents = bits[0]['components']
        
        # 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 )
            
            # Setup plugs for transform and custom attributes.
            for plug in bitPlugs:
                if not NodeUtility.attributeCheck( fullBitName, plug['name'] ):
                    NodeUtility.addPlug( fullBitName, plug['name'], plug['attrType'], plug['attrDataType'] )
                    if plug['value'] is not None:
                        NodeUtility.setPlug( fullBitName, plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
                else:          
                    # Setup position and rotation.
                    NodeUtility.setPlug( fullBitName, plug['name'], plug['value'] )
            
            # Setup plugs for shape attributes.
            shapeName = cmds.listRelatives( fullBitName, shapes=True )
            fullShapeName = '{0}|{1}'.format( fullBitName, shapeName[0] )
            for plug in shapePlugs:
                if plug['attrDataType'] == 'TdataCompound' or plug['attrDataType'] == 'matrix':
                    # 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 } )
                elif plug['attrDataType'] == 'message':
                    print 'MESSAGE'
                else:
                    NodeUtility.setPlug( fullShapeName, plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
            
            # Setup bit components.
            for comp in bitComponents:
                compType = comp['name']
                
                # We have to special case components that have additional kwargs.
                if compType == 'CurveControlComponent':
                    # Handle curve control component type.
                    for plug in comp['plugs']:
                        if plug['name'] == 'curveType':
                            curveType = plug['value']
                    newComp = components.addComponentToObject( compType, inObject=fullBitName, curveType=curveType )
                else:
                    # Handle basic component.
                    newComp = components.addComponentToObject( compType, inObject=fullBitName )

                for plug in comp['plugs']:
                    # Bit of a hack with the parentName attribute. This attr is setup when the component is created.
                    # So there is no need to apply the stored plug value from the XML.
                    if plug['attrDataType'] == 'message':
                        if plug['name'] != 'parentName':
                            if plug['value'] != 'None':
                                sourcePlug = plug['value'].split('.')
                                NodeUtility.connectNodes( sourcePlug[0], sourcePlug[1], newComp.name(), plug['name'] )
                    else:
                        NodeUtility.setPlug( newComp.name(), plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
                    
            # Remove the bit from the list
            bits.remove( bits[0] )
        #tick = tick+1
            
    # Now do the hook ups for the child arrows.
    for i in storeBitConnections:
        NodeUtility.setBitChild( i['parent'], i['child'] )
예제 #5
0
파일: BitsUI.py 프로젝트: EriLee/marigold
    def doIt( self, *args ):
        # Window settings.
        self.winWidth = 206
        self.winHeight = 400
        self.iconWidth = 32
        self.iconHeight = 32
        
        # Window colors
        self.rowColors = [[0.4,0.4,0.4],[0.5,0.5,0.5]]
        
        # Clean up old uis before opening a new one.
        try:
            cmds.deleteUI( self.winName )
        except:
            pass
        
        # Setup the form layout.
        self.mainWindow = cmds.window( self.winName, title=self.winTitle, sizeable=False, resizeToFitChildren=False )
        self.form = cmds.formLayout()
        self.tabs = cmds.tabLayout( innerMarginWidth=5, innerMarginHeight=5 )
                
        # Attach the tabs layout to the form layout.
        cmds.formLayout( self.form, edit=True, attachForm=( (self.tabs, 'top', 0), (self.tabs, 'left', 0), (self.tabs, 'bottom', 0), (self.tabs, 'right', 0) ) )
        
        # Create each of the tabs.
        # TAB: META NODES: START
        self.tabMeta = cmds.rowColumnLayout( numberOfRows=2, width=self.winWidth )
        
        self.colMeta = cmds.rowColumnLayout( numberOfColumns=1, height=self.winHeight/2 )
        cmds.text( label='Meta Nodes', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
        cmds.separator( style='none', height=4 )
        self.gridMeta = cmds.gridLayout( numberOfColumns=4, cellWidthHeight=( 50, 50 ) )        
        cmds.button( label='Basic', command=lambda b, a1='frameModule': metaNode.MetaNode( inNodeMetaType=a1 ) )
        cmds.button( label='Character', command=lambda b, a1=False: metaNode.MetaCharacter( doModel=a1 ) )
        cmds.setParent( '..' )#self.gridMeta
        cmds.setParent( '..' )#self.colMeta
        
        self.colMetaTools = cmds.rowColumnLayout( numberOfColumns=1 )
        cmds.text( label='Tools', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
        cmds.separator( style='none', height=4 )
        self.rowMetaTools = cmds.rowColumnLayout( numberOfRows=1 )
        cmds.button( label='Meta Node List', annotation='meta node list',
                     command=lambda b: SelectMetaUI.selectMetaUI() )                       
        cmds.setParent( '..' )#self.rowMetaTools
        cmds.setParent( '..' )#self.colMetaTools

        cmds.setParent( '..' )#self.tabMeta
        # TAB: META NODES: END
        
        # TAB: BITS, START
        self.tabBits = cmds.rowColumnLayout( numberOfRows=3, width=self.winWidth )
        
        self.bitsCol = cmds.rowColumnLayout( numberOfColumns=1, height=self.winHeight/3 )
        cmds.text( label='Bit Primitives', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
        cmds.separator( style='none', height=4 )
        self.bitsGrid = cmds.gridLayout( numberOfColumns=4, cellWidthHeight=( 50, 50 ) )
        cmds.button( label='Sphere', command=lambda b, a1='glSphere': cmds.makeGLBit( objecttype=a1 ) )
        cmds.button( label='Box', command=lambda b, a1='glBox': cmds.makeGLBit( objecttype=a1 ) )
        cmds.button( label='Cylinder', command=lambda b, a1='glCylinder': cmds.makeGLBit( objecttype=a1 ) )
        cmds.button( label='Cone', command=lambda b, a1='glCone': cmds.makeGLBit( objecttype=a1 ) )
        cmds.button( label='Torus', command=lambda b, a1='glTorus': cmds.makeGLBit( objecttype=a1 ) )
        cmds.setParent( '..' )#self.bitsGrid
        cmds.setParent( '..' )#self.bitsCol
        
        self.toolsCol = cmds.rowColumnLayout( numberOfColumns=1 )
        cmds.text( label='Transform Tools', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
        cmds.separator( style='none', height=4 )
        self.toolRow = cmds.rowColumnLayout( numberOfRows=1 )
        cmds.iconTextButton( annotation='match translation', style='iconOnly',
                             width=self.winWidth/3, image1='icon_match_translation.png',
                             command=lambda a1='tran': TransformUtility.matchTransforms(a1) )
        cmds.iconTextButton( annotation='match rotation', style='iconOnly',
                             width=self.winWidth/3, image1='icon_match_rotation.png',
                             label='match rotation', command=lambda a1='rot': TransformUtility.matchTransforms(a1) )
        cmds.iconTextButton( annotation='match all', style='iconOnly',
                             width=self.winWidth/3, image1='icon_match_all.png',
                             label='match all', command=lambda a1='all': TransformUtility.matchTransforms(a1) )                             
        cmds.setParent( '..' )#self.toolRow
        cmds.setParent( '..' )#self.toolsCol

        self.childCol = cmds.rowColumnLayout( numberOfColumns=1 )
        cmds.text( label='General Tools', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
        cmds.separator( style='none', height=4 )
        self.childRow = cmds.rowColumnLayout( numberOfColumns=2 )
        cmds.button( label='Add Child', command=lambda b: NodeUtility.setBitChild() )
        cmds.button( label='Remove Child', command=lambda b: NodeUtility.deleteBitChild() )
        cmds.button( label='Copy Settings', command=lambda b: NodeUtility.copyBitSettings() )
        cmds.setParent( '..' )#self.childRow
        cmds.setParent( '..' )#self.childCol
        
        cmds.setParent( '..' )#self.tabBits
        # TAB: BITS, END
        
        # TAB: ATTRIBUTES, START
        self.tabAttrs = cmds.rowColumnLayout( numberOfRows=2 )
        
        # Top
        self.attrTop = cmds.rowColumnLayout( numberOfColumns=1 )
        cmds.text( label='Attribute List', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
        cmds.separator( style='none', height=4 )
        
        # Top rows.
        self.attrList = cmds.scrollLayout( horizontalScrollBarThickness=16, verticalScrollBarThickness=16, height=150 )
        self.fillAttrList()
        cmds.setParent( '..' )#attrList
        # Bottom buttons
        cmds.rowColumnLayout( numberOfColumns=2 )
        #cmds.button( label='Add Custom Attribute' )
        cmds.button( label='Delete Attributes', command=lambda b: deleteAttrUI.createDeleteAttrUI() )
        cmds.button( label='Add Selected', command=lambda b: self.addAttrsFromList() )
        cmds.separator( style='none', height=10 )
        cmds.setParent( '..' )#button columns
        cmds.setParent( '..' )#self.attrTop
        
        self.attrPresets = cmds.rowColumnLayout( numberOfColumns=1 )
        cmds.text( label='Attribute Presets', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
        cmds.separator( style='none', height=4 )
        self.presets = cmds.gridLayout( numberOfColumns=4, cellWidthHeight=( 50, 50 ) )
        self.fillAttrPresets()
        cmds.setParent( '..' )#self.presets
        cmds.setParent( '..' )#self.attrPresets
        
        cmds.setParent( '..' )#self.tabAttrs
        # TAB: ATTRIBUTES, END
        
        # TAB: XML: START
        self.tabXML = cmds.rowColumnLayout( numberOfRows=2, width=self.winWidth )
        
        self.colXML = cmds.rowColumnLayout( numberOfColumns=1, height=self.winHeight/2 )
        cmds.text( label='XML Tools', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
        cmds.separator( style='none', height=4 )        
        cmds.button( label='Save Frame Module XML', command=lambda b: FrameUtility.createFrameModuleXML() )
        cmds.setParent( '..' )#self.colXML

        cmds.setParent( '..' )#self.tabXML
        # TAB: XML: END
        
        # Added the tabs to the tab layout.
        cmds.tabLayout( self.tabs, edit=True, tabLabel=( (self.tabMeta, 'Metas'),
                                                         (self.tabBits, 'Bits'),
                                                         (self.tabAttrs, 'Attributes'),
                                                         (self.tabXML, 'XML') ) )

        # Show the window.
        cmds.showWindow( self.winName )
예제 #6
0
파일: qtui.py 프로젝트: EriLee/marigold
 def primitive_buttons( self ):
     sender = self.sender()
     bit_name = 'gl{0}'.format( sender.text() )
     cmds.makeGLBit( objecttype=bit_name )