def initExport(option): dependencyList = FarmAPI.GetSortedDependencyList()[0] filepath = FarmAPI.GetKatanaFileName() # TODO - validity check saved = FarmAPI.IsSceneValid(FarmAPI.NODES_ALL) if not saved: # errormsg = FarmAPI.GetErrorMessages() result = UI4.Widgets.MessageBox.Warning('Unsaved Changes', 'Save your file', acceptText='Save', cancelText='Cancel') if result == 0: # Save KatanaFile.Save(filepath) else: # cancel return # TODO - Get Katana version katanaVersion = "2.54" rendererVersion = "21.4" # get renderservice renderer = dependencyList['service'] requ_lics = '' if renderer == 'arnold': rendererVersion = RenderingAPI.RendererInfo.GetPlugin( 'ArnoldRendererInfo').getRegisteredRendererVersion() extension = '.ass' requ_lics += 'Arnold;' elif renderer == 'prman': rendererVersion = RenderingAPI.RendererInfo.GetPlugin( 'PRManRendererInfo').getRegisteredRendererVersion() renderer = 'RenderMan' extension = '.rib' requ_lics += 'RenderMan;' else: UI4.Widgets.MessageBox.Warning('Unsupported Renderer', 'Unknown Renderer') return use_yeti = dependencyList['useYetiLic'] if use_yeti: requ_lics += "Yeti" software = 'Katana' software = 'Katana' if option == 'local': software = renderer # print 'dependency list ', dependencyList fileDir = dependencyList['outputFolder'] # print 'FILEDDIR ', fileDir fileName = dependencyList['fileName'] if fileName == '': UI4.Widgets.MessageBox.Warning('Warning', 'Add a name parameter') return # tmp name for xml and katana farm file xmlFileName = getNewTempFileName(fileDir, fileName) tmpFile = open(xmlFileName, 'w') dst = tmpFile.name[:-4] + '.katana' comment_file = tmpFile.name[:-4] + '_comment.txt' comment = '' use_comment = dependencyList['useComment'] if use_comment: comment = dependencyList['comment'] with open(comment_file, 'w') as f: f.write(comment) if (option == 'local'): # check file/dir if not os.path.isdir(fileDir): if UI4.Widgets.MessageBox.Warning('Warning', 'Directory does not exist.\n' + fileDir + '\n\nCreate it?', acceptText='Yes', cancelText='No'): return else: os.mkdir(fileDir) sceneName = os.path.join(fileDir, fileName) + '_<FN4>' + extension else: sceneName = dst # sceneName = FarmAPI.GetKatanaFileName() # check framerange framerange = dependencyList['range'] if framerange is None: UI4.Widgets.MessageBox.Warning('Warning', 'Add a valid framerange') return startframe = int(framerange[0]) endframe = int(framerange[1]) if endframe <= startframe: UI4.Widgets.MessageBox.Warning('Warning', 'Add a valid framerange') return # distribution check threadCount = int(dependencyList['useThreads']) if threadCount <= 0: UI4.Widgets.MessageBox.Warning('Warning', 'You must use at least one thread') return availableThreads = multiprocessing.cpu_count() if (threadCount > availableThreads) and (option == 'local'): UI4.Widgets.MessageBox.Warning( 'Warning', 'Your machine is restricted to max.' + str(availableThreads)) return packageSize = int(dependencyList['packageSize']) if packageSize <= 0: UI4.Widgets.MessageBox.Warning('Warning', 'Add a valid packageSize') return # denoiser post script flags if int(dependencyList['useRendermanDenoiserPostScript']) == 1: filter = dependencyList['denoiseFilter'] filter_cmd = 'denoise -v variance -f {}'.format(filter) if dependencyList['useFilterOverride']: filter_override = dependencyList['denoiseFilterOverride'] for override in filter_override: filter_cmd += '+{}'.format(override) # create job newJob = rrJob() if (option == 'local'): newJob.version = rendererVersion else: newJob.version = katanaVersion newJob.rendererVersionName = renderer newJob.rendererVersion = rendererVersion newJob.software = software newJob.renderer = renderer newJob.RequiredLicenses = requ_lics #"Yeti" # TODO newJob.sceneName = sceneName newJob.sceneDatabaseDir = "" newJob.seqStart = startframe newJob.seqEnd = endframe newJob.seqStep = dependencyList['stepSize'] # TODO - get dynamic newJob.seqFileOffset = 0 newJob.seqFrameSet = "" newJob.imageWidth = 99 # TODO - get dynamic newJob.imageHeight = 99 newJob.imageDir = fileDir newJob.imageFileName = fileName + '_####_variance.exr' newJob.imageFramePadding = 4 # TODO - get dynamic newJob.imageExtension = "" # ".exr" # TODO get dynamic newJob.imagePreNumberLetter = "" newJob.imageSingleOutput = False newJob.imageStereoR = "" newJob.imageStereoL = "" newJob.sceneOS = getOSString() # TODO - get dynamic newJob.camera = "" newJob.layer = dependencyList['name'] newJob.channel = "" newJob.maxChannels = 0 newJob.channelFileName = [] newJob.channelExtension = [] newJob.isActive = False newJob.sendAppBit = "" newJob.preID = "" newJob.waitForPreID = "" if dependencyList['useRendermanDenoiserPostScript']: newJob.CustomA = filter_cmd else: newJob.CustomA = "" newJob.CustomB = "comment: {}".format(comment) newJob.CustomC = "" newJob.LocalTexturesFile = "" newJob.rrSubmitVersion = "%rrVersion%" newJob.packageSize = packageSize newJob.threadCount = threadCount newJob.renderNode = dependencyList['name'] # write xml file root = newJob.writeToXMLstart(None) job = newJob.writeToXMLJob(root) newJob.writeToXMLEnd(tmpFile, root) # copy katanna recipie shutil.copy(filepath, dst) # submit job if option == 'local': # start control session for local conversion scriptDir = os.path.dirname(os.path.realpath(__file__)) sessionScript = os.path.join(scriptDir, 'session/ControlSessions.py') subp = subprocess.Popen(['python', sessionScript, tmpFile.name, dst], close_fds=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) elif option == 'farm': os.system(getRRSubmitterPath() + " \"" + xmlFileName + "\"")
def setup_ui(self): l_nodes_raw = NodegraphAPI.GetAllNodesByType('Render') l_nodes = [] for n in l_nodes_raw: np = n.getInputPortByIndex(0) if np.getNumConnectedPorts(): l_nodes.append(n) l_renders = FarmAPI.GetSortedDependencyList(l_nodes) l_aovs = [] for render_node in l_renders: if len(render_node['outputs']) > 0: for aov in render_node['outputs']: l_aovs.append([render_node['name'], aov[ 'name'], aov['outputLocation']]) # setting output directory to display in label if len(l_renders) > 0: if len(l_renders[0]['outputs']) > 1: output_location_of_some_layer = l_renders[ 0]['outputs'][1]['outputLocation'] self.output_directory, layer = os.path.split( output_location_of_some_layer) self.ui.label_5.setText(self.output_directory) else: self.ui.label_5.setText("Output path not found. Contact TD.") checkboxList = [] nodes_L, nodes_R = [], [] for item in l_aovs: title = item[0] checkboxList.append(title) checkboxList = sorted(list(set(checkboxList))) for i in range(len(checkboxList)): name = checkboxList[i] if name[len(name) - 1] == "L": nodes_L.append(name) else: nodes_R.append(name) # Add to list showing L nodes self.ui.tableWidget.setRowCount(len(nodes_L)) for i in range(len(nodes_L)): name = nodes_L[i] item = QtGui.QTableWidgetItem('%s' % name) check = Qt.Checked item.setCheckState(check) self.ui.tableWidget.setItem(i, 0, item) sf_mode = QTableWidgetItem(u"*双击编辑") check = Qt.Unchecked sf_mode.setCheckState(check) self.ui.tableWidget.setItem(i, 1, sf_mode) # Add to list showing R and other nodes self.ui.tableWidget_2.setRowCount(len(nodes_R)) for i in range(len(nodes_R)): name = nodes_R[i] item = QtGui.QTableWidgetItem('%s' % name) check = Qt.Checked item.setCheckState(check) self.ui.tableWidget_2.setItem(i, 0, item) sf_mode = QTableWidgetItem(u"*双击编辑") check = Qt.Unchecked sf_mode.setCheckState(check) self.ui.tableWidget_2.setItem(i, 1, sf_mode) f_range = FarmAPI.GetSceneFrameRange() self.ui.lineEdit.setText(str(f_range['start'])) self.ui.lineEdit_2.setText(str(f_range['end'])) return