def getComponents( inObj ): ''' Creates the components GUI. ''' if inObj is not None: components_list = FrameUtility.getFrameBitSettings( inObj ) else: components_list = None # If the newly selected bit has components then update the UI to show them. # Check to see if any of the components are connected to a meta node. # We do this check so that we don't create a bunch of UI elements # unnecessarily. if components_list is not None and metaNodeCheck( inObj, components_list ): # Loop through each component on the bit. components_class_list = {} for node_name in components_list: # Check to see if the component is connected to a meta node. metaNode = NodeUtility.getNodeAttrDestination( inObj, node_name ) if metaNode: # It has a meta node. # Get the meta node properties. This returns a dict. meta_properties = FrameUtility.getFrameBitSettings( metaNode[0] ) component_class = meta_properties[ 'classType' ] # test hack!!! components_class_list[ node_name ] = component_class return components_class_list else: return None
def componentsGUI( self, inBit=None ): ''' Creates the components GUI. ''' if inBit is None: components = None else: # Get the components of the selected bit. components = FrameUtility.getFrameBitSettings( inBit ) # Clean up the compArea layout prior to adding new children by # removing the previously selected bit's information from the UI. mainChildren = cmds.columnLayout( self.fillArea, query=True, childArray=True ) if mainChildren is not None: for child in mainChildren: cmds.deleteUI( child ) col = cmds.columnLayout( adjustableColumn=True, columnAttach=('both', 5), parent=self.fillArea ) # HIGHLIGHTED cmds.separator( style='none', height=4, width=413 ) self.selName = cmds.text( label=str.upper( 'nothing selected' ), height=20, font='boldLabelFont', backgroundColor=[0.2,0.2,0.2] ) cmds.separator( style='none', height=10 ) # If the newly selected bit has components then update the UI to show them. # Check to see if any of the components are connected to a meta node. # We do this check so that we don't create a bunch of UI elements # unnecessarily. if components is not None and self.metaNodeCheck( inBit, components ): # Create the scroll layout. mainScroll = cmds.scrollLayout( parent=col ) # Loop through each component on the bit. for comName in components: # Check to see if the component is connected to a meta node. metaNode = NodeUtility.getNodeAttrDestination( inBit, comName ) if metaNode: # It has a meta node. # Get the meta node parameters. metaParameters = FrameUtility.getFrameBitSettings( metaNode[0] ) # Make the component UI elements. frameOne = cmds.frameLayout( parent=mainScroll, borderStyle='out', label=comName, collapsable=True ) cmds.popupMenu() #bit name, component name, meta node name cmds.menuItem( label='Delete Component', command=lambda b, a1=inBit, a2=comName, a3=metaNode[0]:self.deleteComponent(a1, a2, a3) ) cmds.menuItem( label='Build Component', command=lambda b, a1=metaNode[0]:self.buildComponent(a1) ) compColumn = cmds.rowColumnLayout( numberOfColumns=1 ) # Loop through the parameters and add them to the component UI. for param in metaParameters: #print isinstance(param, unicode) if not( param == u'parentName' or param == u'classType' ): propRow = cmds.rowColumnLayout( numberOfColumns=4, columnWidth=[(1,100),(2,100),(3,40),(4,40)], columnSpacing=[(1,10),(2,10),(3,10),(4,2)] ) cmds.text( label=param, align='left' ) cmds.textField( text=metaParameters[param], enterCommand=lambda b, a1=metaNode[0], a2=param:self.updateComponentParameter(a1, a2, b) ) cmds.setParent( '..' )#propRow cmds.setParent( '..' )#compColumn cmds.setParent( '..' )#frameOne cmds.setParent( '..' )#mainScroll cmds.setParent( '..' )#col # Selection script job self.selJob = cmds.scriptJob( event=[ 'SelectionChanged', self.onSelectionChange ], parent=col, protected=True )