Beispiel #1
0
    def onSelectionChange( self ):
        '''
        Function called by the scripted event in componentsGUI().
        Updates the componentGUI whenever the user selects a different object.
        '''
        selList = cmds.ls( selection=1, long=True )
        if not self.selectedLockActive:
            clearLayout( self.componentsLayout )
            if len( selList ) == 1:
                shortName = selList[0].split( '|' )
                selName = shortName[ len(shortName)-1 ]
                self.selectedLabel.setText( selName )
                self.SELECTED_OBJECT_LONGNAME = selList[0]
                componentsClassList = Components.getComponents( self.SELECTED_OBJECT_LONGNAME )
                
                # Add the component node GUI widgets to the component section.
                if componentsClassList is not None:
                    for nodeName in componentsClassList:
                        component = componentsClassList[ nodeName ]
                        nodeName = nodeName
                        componentClass = Components.str_to_class( component )
                        componentGui = componentClass( component ).componentGui( nodeName, parent=self )
                        self.componentsLayout.addWidget( componentGui )
                        

            elif len( selList ) > 1:
                if not self.selectedLockActive:
                    self.SELECTED_OBJECT_LONGNAME = None
                    self.selectedLabel.setText( 'select only one module bit' )
            else:
                if not self.selectedLockActive:
                    self.SELECTED_OBJECT_LONGNAME = None
                    self.selectedLabel.setText( 'nothing selected' )
Beispiel #2
0
 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 )
Beispiel #3
0
    def onSelectionChange( self ):
        '''
        Function called by the scripted event in componentsGUI().
        Updates the componentGUI whenever the user selects a different object.
        '''
        TEST = False
        selList = cmds.ls( selection=1, long=True )
        if not self.selected_lock_active:
            self.clear_layout( self.components_layout )
            if len( selList ) == 1:
                shortName = selList[0].split( '|' )
                selName = shortName[ len(shortName)-1 ]
                self.selected_label.setText( selName )
                self.SELECTED_OBJECT_LONGNAME = selList[0]
                components_class_list = getComponents( self.SELECTED_OBJECT_LONGNAME )
                
                # Add the component node GUI widgets to the component section.
                if components_class_list is not None:
                    for node_name in components_class_list:
                        component = components_class_list[ node_name ]
                        node_name = node_name
                        if TEST:
                            # TEST GUIs
                            self.components_layout.addWidget( componentGui( node_name ) )
                            print 'ADDING NODE GUI FOR: {0}'.format( node_name )
                            print 'comp: {0}'.format( component )
                        else:
                            component_class = Components.str_to_class( component )
                            component_gui = component_class( component ).componentGui( node_name )
                            self.components_layout.addWidget( component_gui )
                        

            elif len( selList ) > 1:
                if not self.selected_lock_active:
                    self.SELECTED_OBJECT_LONGNAME = None
                    self.selected_label.setText( 'select only one module bit' )
            else:
                if not self.selected_lock_active:
                    self.SELECTED_OBJECT_LONGNAME = None
                    self.selected_label.setText( 'nothing selected' )