def __init__(self):
        try:
            Utils.UndoStack.DisableCapture()
            try:
                self.setName("UsdMaterialBake")
                self.setType("UsdMaterialBake")

                networkVersion = "1.0"
                parameters_XML = _parameters_XML.format(
                    networkVersion=networkVersion)
                self.getParameters().parseXML(parameters_XML)

                self.addInputPort("orig")
                self.addInputPort("default")
                self.addOutputPort("out")

                dot = NodegraphAPI.CreateNode('Dot', self)
                dot.getInputPortByIndex(0).connect(self.getSendPort("orig"))
                dot.getOutputPortByIndex(0).connect(self.getReturnPort("out"))
                NodegraphAPI.SetNodePosition(dot, (0, 200))
                NodegraphAPI.SetNodeShapeAttr(self, 'basicDisplay', 1)
                NodegraphAPI.SetNodeShapeAttr(self, 'iconName', '')
            finally:
                Utils.UndoStack.EnableCapture()

        except Exception:
            log.exception("CREATE UsdMaterialBake FAILED.")
            raise
        self.__timer = None
        self.__interruptWidget = None
示例#2
0
    def __init__(self,populate=True):
        NodegraphAPI.SetNodeShapeAttr(self, 'basicDisplay', 1)
        def _populate():

            def createNodeParam(node,param_name):
                param = self.getParameters().createChildString(param_name,'')
                param.setExpressionFlag(True)
                param.setExpression('@%s'%node.getName())
            
            #===================================================================
            # CREATE NODES
            #===================================================================
            
            def AddGlobalGraphStateVariable(name, options):
                from Katana import  NodegraphAPI
                
                variablesGroup = NodegraphAPI.GetRootNode().getParameter('variables')
   
                variableParam = variablesGroup.createChildGroup(name)
                variableParam.createChildNumber('enable', 1)
                variableParam.createChildString('value', options[0])
                optionsParam = variableParam.createChildStringArray('options', len(options))
                for optionParam, optionValue in zip(optionsParam.getChildren(), options):
                    optionParam.setValue(optionValue, 0)
                return variableParam.getName()

    
            
            node_list = []
            self.addOutputPort('out')
            self.addInputPort('in')
            self.getSendPort('in').connect(self.getReturnPort('out'))
            self.sequence_lg = self.createBlockGroup(self, 'sequence')
            self.sequence_lg.getParameter('hash').setValue('master',0)
            self.shot_lg = NodegraphAPI.GetNode(self.sequence_lg.getParameter('nodeReference.shot_group').getValue(0))
            
            node_list.append(self.sequence_lg)

            
            Utils.EventModule.ProcessAllEvents()

            self.connectInsideGroup(node_list, self)
            
            
            #===================================================================
            # SET UP PARAMETERS
            #===================================================================
            self.createNodeReference(self,self.sequence_lg,'sequence_node',param=None)
            self.createNodeReference(self,self.shot_lg,'shot_node',param=None)
            self.gaffer_three_display_param = self.getParameters().createChildString('gaffer_display','')
            self.gaffer_three_display_param.setHintString(repr({'widget':'teleparam'}))
            
            self.publish_dir = self.getParameters().createChildString('publish_dir',settings.SEQUENCE_PATH)
            
            if NodegraphAPI.GetNode('rootNode').getParameter('variables.sequence'):
                self.sequence = NodegraphAPI.GetNode('rootNode').getParameter('variables.sequence.value').getValue(0)
            else:
                AddGlobalGraphStateVariable('sequence',['default'])
                self.sequence = 'default'
            if not os.path.exists(settings.SEQUENCE_PATH + '/%s'%self.sequence):
                #print 'not' , settings.SEQUENCE_PATH + '/%s'%sequence
                os.mkdir(settings.SEQUENCE_PATH + '/%s'%self.sequence)
                os.mkdir(settings.SEQUENCE_PATH + '/%s/blocks'%self.sequence)
                os.mkdir(settings.SEQUENCE_PATH + '/%s/shots'%self.sequence)
            self.publish_dir.setHintString(repr({'widget': 'fileInput'}))
            '''
            version_options = []
            if NodegraphAPI.GetNode('rootNode').getParameter('variables.sequence'):
                sequence = NodegraphAPI.GetNode('rootNode').getParameter('variables.sequence.value').getValue(0)
                if os.path.isdir('%s/%s/sequence/%s'%(settings.SEQUENCE_PATH,sequence,sequence)):
                    #print '%s/light/%s/sequence/%s'%(settings.SEQUENCE_PATH,sequence,sequence)
                    version_options = os.listdir('%s/%s/sequence/%s'%(settings.SEQUENCE_PATH,sequence,sequence))
                    
            self.sequence_param = self.getParameters().createChildString('version','v001')
            self.sequence_param.setHintString(repr({'widget': 'popup', 'options': version_options}))
            
            sequence_options = []
            #shot_options = []
            if NodegraphAPI.GetRootNode().getParameter('variables.sequence'):
                for child in NodegraphAPI.GetNode('rootNode').getParameter('variables.sequence.options').getChildren():
                    sequence_options.append(child.getValue(0))
            '''
            #if NodegraphAPI.GetRootNode().getParameter('variables.shot'):
                #for child in NodegraphAPI.GetNode('rootNode').getParameter('variables.shot.options').getChildren():
                    #shot_options.append(child.getValue(0))
                    
            self.sequence_param = self.getParameters().createChildString('sequence',self.sequence)
            self.sequence_param.setHintString(repr({'readOnly': 'True'}))
            #self.sequence_param.setHintString(repr({'widget': 'popup', 'options': sequence_options}))
            
            #self.sequence_param = self.getParameters().createChildString('shot','030')
            #self.sequence_param.setHintString(repr({'widget': 'popup', 'options': shot_options}))
            
            self.populateShots()
        if populate == True:
            _populate()
        elif populate == False:
            pass