def execute(self, operation, file_path, **kwargs): """ Main hook entry point :operation: String Scene operation to perform :file_path: String File path to use if the operation requires it (e.g. open) :returns: Depends on operation: 'current_path' - Return the current scene file path as a String all others - None """ if operation == "current_path": # return the current scene path return FarmAPI.GetKatanaFileName() elif operation == "open": # do new scene as Maya doesn't like opening # the scene it currently has open! KatanaFile.Load(file_path) elif operation == "save": current_file = FarmAPI.GetKatanaFileName() # save the current scene: KatanaFile.Save(current_file)
def save_query(log): cancel = False if HOST == STANDALONE: from tentaculo.api import standalone cancel = standalone.message_function("save_query")[0] elif HOST == MAYA or HOST == MAYA2: file_name = mc.file(query=True, sceneName=True) need_save = mc.file(query=True, modified=True) if len(file_name) > 0 and need_save: ret = mc.confirmDialog(title='Closing file', message='Save current file?', messageAlign='center', button=['Yes', 'No', 'Cancel'], defaultButton='Yes', cancelButton='Cancel', dismissString='Cancel') if ret == "Yes": mc.file(save=True, type="mayaAscii") elif ret == "Cancel": cancel = True elif HOST == NUKE: cancel = not nuke.scriptClose() elif HOST == HOUDINI: need_save = hou.hipFile.hasUnsavedChanges() if need_save: hou.hipFile.clear() cancel = hou.hipFile.hasUnsavedChanges() elif HOST == MAX: cancel = not MaxPlus.FileManager.CheckForSave() elif HOST == C4D: doc = c4d.documents.GetActiveDocument() if doc is not None and doc.GetChanged(): cancel = not c4d.documents.SaveDocument( doc, doc.GetDocumentPath() + "/" + doc.GetDocumentName(), c4d.SAVEDOCUMENTFLAGS_DIALOGSALLOWED, c4d.FORMAT_C4DEXPORT) elif HOST == BLENDER: if bpy.data.is_dirty: bpy.ops.wm.save_mainfile(check_existing=True) cancel = bpy.data.is_dirty elif HOST == KATANA: if KatanaFile.IsFileDirty(): mb = UI4.App.Application.QtGui.QMessageBox(app_window()) mb.setText("Closing file") mb.setInformativeText("Save current file?") mb.setStandardButtons( UI4.App.Application.QtGui.QMessageBox.Yes | UI4.App.Application.QtGui.QMessageBox.No | UI4.App.Application.QtGui.QMessageBox.Cancel) ret = mb.exec_() if ret == UI4.App.Application.QtGui.QMessageBox.Yes: KatanaFile.Save( NodegraphAPI.NodegraphGlobals.GetProjectAssetID()) cancel = ret == UI4.App.Application.QtGui.QMessageBox.Cancel return not cancel
def save_file(log, fname=None): if fname is None: fname = "temp" file_path = fname if HOST == STANDALONE: from tentaculo.api import standalone standalone.message_function("save_file", [file_path]) elif HOST == MAYA or HOST == MAYA2: mc.file(rename=file_path) file_path = mc.file(save=True, type="mayaAscii") elif HOST == NUKE: nuke.scriptSaveAs(file_path, overwrite=1) elif HOST == HOUDINI: hou.hipFile.setName(file_path) hou.hipFile.save() elif HOST == MAX: MaxPlus.FileManager.Save(file_path) elif HOST == C4D: doc = c4d.documents.GetActiveDocument() if doc is not None: c4d.documents.SaveDocument(doc, str(file_path), c4d.SAVEDOCUMENTFLAGS_0, c4d.FORMAT_C4DEXPORT) elif HOST == BLENDER: bpy.ops.wm.save_mainfile(filepath=file_path) elif HOST == KATANA: KatanaFile.Save(file_path) return file_path
def export_katana_nodes(knodes, katana_scene, force=False): ''' :description to export the katana nodes from the current scene , force true is to overwrite the scene, if scene exists :param knodes <list> :param katana_scene <str> :param force <bool> :example from core import scene knodes = NodegraphAPI.GetAllSelectedNodes() katana_scene = '/venture/shows/katana_tutorials/tmp/export_03.katana' scene.export_katana_nodes(knodes, katana_scene) ''' knodes = nodegraph.get_katana_nodes(knodes) if not knodes: print '#warnings: not found valid katana nodes' return if os.path.isfile(katana_scene) and not force: print '#warnings: already found katana scene' return if not os.path.isdir(os.path.dirname(katana_scene)): os.makedirs(os.path.dirname(katana_scene)) KatanaFile.Export(katana_scene, knodes, extraOptionsDict=None) print '#info: export nodes' for knode in knodes: print '\t', knode.getName() return True
def _save_session(path): """ Save the current session to the supplied path. """ # Ensure that the folder is created when saving KatanaFile.Save( path )
def kanana_analyse(katana_scene, anal_txt): print katana_scene print anal_txt #yourKatanaScene = "/home/ladaojeiang/yes/demos/katana_files/aovs_prman.katana" KatanaFile.Load( katana_scene) # Loading scene /yourDirectory/yourFile.katana render_info_dict = {} render_nodes = NodegraphAPI.GetAllNodesByType("Render") if len(render_nodes) != 0: print len(render_nodes) print render_nodes for render_node in render_nodes: if render_node.isBypassed() == False: render_outputs = {} Source_list = [] Variance_list = [] Final_list = [] render_name = render_node.getName() print render_name render_node_info = Nodes3DAPI.RenderNodeUtil.GetRenderNodeInfo( render_node) for render_output_name in render_node_info.getAllOutputNames(): render_output = render_node_info.getOutputInfoByName( render_output_name, 0)['outputFile'] #print render_output if render_output.find('tmp') == 1: #print render_output pass elif render_output.find('Source') > 0: Source_list.append(render_output) elif render_output.find('Variance') > 0: Variance_list.append(render_output) elif render_output.find('Final') > 0: Final_list.append(render_output) render_outputs['Source'] = Source_list render_outputs['Variance'] = Variance_list render_outputs['Final'] = Final_list render_info_dict[render_name] = render_outputs else: render_name = render_node.getName() print render_name + " is not render , this node is disabled" print len(render_info_dict.keys()) #print render_info_dict anal_txt_handle = file(anal_txt, 'w') anal_txt_handle.write(json.dumps(render_info_dict)) anal_txt_handle.close() else: print 'the render node 0, analysis failed!' if os.path.exists(anal_txt): os.remove(anal_txt) sys.exit(1)
def _import_project(path): """ Import a katana project into the current session. :param path: The file path to import. :type path: str """ root = NodegraphAPI.GetRootNode() return KatanaFile.Import(path, floatNodes=True, parentNode=root)
def writeScript(katanaFile=None, jsonFile): from Katana import KatanaFile, NodegraphAPI if katanaFile is not None: KatanaFile.Load(katanaFile) json_data = {} print "\n\n########################" for node in NodegraphAPI.GetAllNodes(): if node.getType() == "ArnoldShadingNode": node_name = node.getName() shader_type = node.getParameter('nodeType').getValue(0) if shader_type.startswith("lc_"): #~ check if shader_type in SHADERMAPPING if not shader_type in SHADERMAPPING: print "#ERROR#", shader_type continue json_data[node_name] = [] #~ read paramter value and record it! json_data[node_name].append(shader_type) shader_data = [] for para_name in SHADERMAPPING[shader_type][1]: node.checkDynamicParameters() k_parameter_value = node.getParameter( 'parameters.%s.value' % para_name) k_parameter_enable = node.getParameter( 'parameters.%s.enable' % para_name) #~ if parameter connected to a node if isPortConnected(node, para_name): connected_node = node.getInputPort( para_name).getConnectedPorts()[0].getNode() # if k_parameter_value.getType() == "numberArray": # if node_name == "bg_remap_color": # print node.getInputPort(para_name).getConnectedPorts()[0].getNode() # else: # connected_node = node.getInputPort(para_name).getConnectedPorts()[0].getNode() shader_data.append( (False, para_name, True, connected_node.getName())) #~ if parameter is a value else: value = [] enable = False if k_parameter_enable.getValue(0): enable = True if k_parameter_value.getType() == "numberArray": for child in k_parameter_value.getChildren(): value.append(child.getValue(0)) else: value.append(k_parameter_value.getValue(0)) shader_data.append((enable, para_name, False, value)) json_data[node_name].append(shader_data) print "#$~", jsonFile outfile = open(jsonFile, 'w') json.dump(json_data, outfile, ensure_ascii=False, sort_keys=True, indent=4) outfile.close() print "########################\n"
def displaySaveDialog(self): fname = str( QFileDialog.getSaveFileName(self, 'Save file', '/s/prodanim/asterix2', "Katana files (*.katana)")) if fname == '': print 'No file has been saved' else: KatanaFile.Save(fname) print 'Saving : ' + fname
def new_katana_scene(): ''' :description to create new katana scene :param None :example from core import scene scene.new_katana_scene() ''' KatanaFile.New() return True
def create_file(log, filepath, origin_path=None): dir = os.path.dirname(filepath) if not os.path.exists(dir): raise Exception('{0} does not exist'.format(dir)) if origin_path is None: origin_path = filepath if HOST == STANDALONE: from tentaculo.api import standalone standalone.message_function("create_file", [filepath]) elif HOST == MAYA or HOST == MAYA2: check_workspace_maya(log, origin_path) mc.file(new=True, force=True) mc.file(rename=filepath) mc.file(save=True, type="mayaAscii") elif HOST == NUKE: nuke.scriptClear() nuke.scriptSaveAs(filepath, overwrite=1) elif HOST == HOUDINI: hou.hipFile.clear(suppress_save_prompt=True) hou.hipFile.save(filepath) elif HOST == MAX: MaxPlus.FileManager.Reset(noPrompt=True) MaxPlus.FileManager.Save(filepath) elif HOST == C4D: c4d.documents.CloseAllDocuments() newDoc = c4d.documents.BaseDocument() c4d.documents.InsertBaseDocument(newDoc) c4d.documents.SaveDocument(newDoc, str(filepath), c4d.SAVEDOCUMENTFLAGS_0, c4d.FORMAT_C4DEXPORT) c4d.documents.LoadFile(str(filepath)) elif HOST == BLENDER: bpy.ops.wm.read_homefile() bpy.ops.wm.save_mainfile(filepath=filepath, check_existing=False) elif HOST == KATANA: KatanaFile.New() KatanaFile.Save(filepath) return filepath
def displayOpenDialog(self): fname = str( QFileDialog.getOpenFileName(self, 'Open file', '/s/prodanim/asterix2', "Katana files (*.katana)")) if fname == '': print 'No file has been open' if self.sender().objectName() == 'openAction': KatanaFile.Load(fname) print 'Loading : ' + fname else: currentSelection = NodegraphAPI.GetAllSelectedNodes() #deselect all the node to select only the 2 created nodes and put them floating under the mouse for node in currentSelection: NodegraphAPI.SetNodeSelected(node, False) KatanaFile.Import(fname, floatNodes=True) print 'importing : ' + fname nodeList = NodegraphAPI.GetAllSelectedNodes() # Find Nodegraph tab and float nodes nodegraphTab = Tabs.FindTopTab('Node Graph') if nodegraphTab: nodegraphTab.floatNodes(nodeList)
def check(file): from Katana import KatanaFile, NodegraphAPI KatanaFile.Load(file) print "" for node in NodegraphAPI.GetAllNodes(): if node.getType() == "ArnoldShadingNode": node_name = node.getName() shader_type = node.getParameter('nodeType').getValue(0) if shader_type.startswith("lc_"): #~ check if shader_type in SHADERMAPPING print "#ERROR#", node_name, shader_type continue
def xml_element_to_nodes(xml_element, parent=None): ''' :description to create katana nodes from xml element :param xml_element <PyXmlIO.Element> :param parent <Nodegraph Node Object> :example from core import scene scene.xml_element_to_nodes(xml_element) ''' if not parent: parent = NodegraphAPI.GetRootNode() knodes = KatanaFile.Paste(xml_element, parent) return knodes
def add_new_cp_uv(): node=cku.get_lgt_shot_maker_node() if cku.get_node_children_by_name(node,'CopyUv_\d*$') or \ cku.get_node_children_by_name(node,'CopyUV_\d*$'): return old_cp=cku.get_node_children_by_name(node,'CopyUv_Ani_Srf_\d*',operation=lambda x:x.setBypassed(True)) if old_cp: new_cp_op=cku.replace_me_with(old_cp[0], new_node='CopyUV_Lc', bypass_old_node=True) if new_cp_op: print '\n\nAdd new copy uv op node to fix srf v000 transfering uv bug.\n\n' new_cp_op.setName('CopyUV_') KatanaFile.Save(FarmAPI.GetKatanaFileName())
def open_katana_scene(katana_scene): ''' :description to open the specific katana scene :param katana_scene <str> :example from core import scene scene.open_katana_scene() ''' if not os.path.isfile(katana_scene): print '#warnings: not found katana scene' return KatanaFile.Load(katana_scene, isCrashFile=False) print '#info: open katana scene', katana_scene return True
def kanana_analyse(katana_scene,anal_txt): #yourKatanaScene = "/home/ladaojeiang/yes/demos/katana_files/aovs_prman.katana" KatanaFile.Load( katana_scene ) # Loading scene /yourDirectory/yourFile.katana render_info_dict={} render_nodes = NodegraphAPI.GetAllNodesByType("Render") if len(render_nodes) != 0: for render_node in render_nodes: render_output_dict={} render_frame_dict={} render_name=render_node.getName() #print render_node.getParameters().getXML() #print render_name render_node_info=Nodes3DAPI.RenderNodeUtil.GetRenderNodeInfo(render_node) for render_output_name in render_node_info.getAllOutputNames(): #print render_node_info.getOutputInfoByName(render_output_name,0) render_output=render_node_info.getOutputInfoByName(render_output_name,0)['outputFile'] print render_output_name,render_output if render_output.find('Temp')>0: print ("the %s output is %s ,it is tmp ,dont copy" % (render_output_name,render_output)) else: render_output_dict[render_output_name]=render_output #print render_output_dict #if render_node.getParameter('farmSettings.setActiveFrameRange').getValue(0)=="Yes": render_start= render_node.getParameter('farmSettings.activeFrameRange.start').getValue(0) render_end= render_node.getParameter('farmSettings.activeFrameRange.end').getValue(0) #print range(0,Nodes3DAPI.RenderNodeUtil.GetNumRenderOutputs(render_node)) #print Nodes3DAPI.RenderNodeUtil.GetDefaultIncludedOutputs(render_node).keys() render_frame_dict["start"]=render_start render_frame_dict["end"]=render_end #print render_start,render_end #print render_frame_dict render_info_dict[render_name]=render_output_dict,render_frame_dict print render_info_dict anal_txt_handle = file(anal_txt, 'w') anal_txt_handle.write(json.dumps(render_info_dict)) anal_txt_handle.close() else: print 'the render node 0, analysis failed!' if os.path.exists(anal_txt): os.remove(anal_txt) sys.exit(1)
def execute(self, work_template, primary_task, secondary_tasks, progress_cb, **kwargs): """ Main hook entry point :param work_template: template This is the template defined in the config that represents the current work file :param primary_task: The primary task that was published by the primary publish hook. Passed in here for reference. :param secondary_tasks: The list of secondary tasks that were published by the secondary publish hook. Passed in here for reference. :param progress_cb: Function A progress callback to log progress during pre-publish. Call: progress_cb(percentage, msg) to report progress to the UI :returns: None :raises: Raise a TankError to notify the user of a problem """ # get the engine name from the parent object (app/engine/etc.) engine_name = self.parent.engine.name progress_cb(0, "Versioning up the scene file") # get the current scene path: scene_path = os.path.abspath(FarmAPI.GetKatanaFileName()) # increment version and construct new file name: progress_cb(25, "Finding next version number") fields = work_template.get_fields(scene_path) next_version = self._get_next_work_file_version(work_template, fields) fields["version"] = next_version new_scene_path = work_template.apply_fields(fields) # log info self.parent.log_debug("Version up work file %s --> %s..." % (scene_path, new_scene_path)) # rename and save the file progress_cb(50, "Saving the scene file") KatanaFile.Save(new_scene_path) progress_cb(100)
def save_katana_scene(katana_scene, force=False): ''' :description to save the current scene, force true is to overwrite the scene, if scene exists :param katana_scene <str> :param force <bool> :example from core import scene scene.save_katana_scene() ''' if os.path.isfile(katana_scene) and not force: print '#warnings: already found katana scene' return if not os.path.isdir(os.path.dirname(katana_scene)): os.makedirs(os.path.dirname(katana_scene)) KatanaFile.Save(katana_scene, extraOptionsDict=None) print '#info: save katana scene', katana_scene return True
def import_katana_scene(katana_scene): ''' :description to import the katana scene :param katana_scene <str> :example from core import scene katana_scene = '/venture/shows/katana_tutorials/tmp/export_03.katana' scene.import_katana_scene(katana_scene) ''' if not os.path.isfile(katana_scene): print '#warnings: not found katana scene' return knodes = KatanaFile.Import(katana_scene, floatNodes=False) print '#info: import nodes' for knode in knodes: print '\t', knode.getName() return True
def createStandard(self): pos = NodegraphAPI.GetViewPortPosition(NodegraphAPI.GetRootNode()) renderer = RenderingAPI.RenderPlugins.GetDefaultRendererPluginName() if renderer == 'arnold': fileName = os.path.join(self.resources, 'arnold_standard.katana') elif renderer == 'prman': fileName = os.path.join(self.resources, 'prman_standard.katana') else: QtGui.QMessageBox.warning( None, 'Error', '{} plugin not found!'.format(renderer.upper())) return if os.path.exists(fileName): KatanaFile.Import(fileName, floatNodes=False) imported = NodegraphAPI.GetAllSelectedNodes()[-1] NodegraphAPI.SetNodePosition(imported, ((pos[0][0]), pos[0][1])) else: QtGui.QMessageBox.warning(None, 'Error', 'There is no standard material saved!')
def close_file(): if HOST == STANDALONE: from tentaculo.api import standalone standalone.message_function("close_file") elif HOST == MAYA or HOST == MAYA2: mc.file(new=True, force=True) elif HOST == NUKE: nuke.scriptClear() elif HOST == HOUDINI: hou.hipFile.clear(suppress_save_prompt=True) elif HOST == MAX: MaxPlus.FileManager.Reset(noPrompt=True) elif HOST == C4D: c4d.documents.CloseAllDocuments() elif HOST == BLENDER: bpy.ops.wm.read_homefile() elif HOST == KATANA: KatanaFile.New() return True
def convert(katanaFile, renderer, outputnode, startframe, endframe, imagename, imagedir, threadId): KatanaFile.Load(katanaFile) for i in range(int(startframe), (int(endframe) + 1)): NodegraphAPI.SetCurrentTime(i) fileExtension = '' if renderer == 'prman': fileExtension = 'rib' elif renderer == 'arnold': fileExtension = 'ass' fileName = os.path.join(imagedir, '%s%04d.%s') % (imagename, i, fileExtension) print '############################', fileName, '###############################' NodeDebugOutput.WriteRenderOutput(NodegraphAPI.GetNode(outputnode), renderer, filename=fileName) sys.stdout.write('[k2rrFrameConvProgress]_' + str(i) + '_thread_' + str(threadId) + '_') sys.stdout.write('[k2rrThreadFinished]_' + str(threadId) + '_')
def open_file(log, filepath, origin_path=None): if not os.path.exists(filepath): raise Exception('{0} does not exist'.format(filepath)) if origin_path is None: origin_path = filepath if HOST == STANDALONE: from tentaculo.api import standalone standalone.message_function("open_file", [filepath]) elif HOST == MAYA or HOST == MAYA2: check_workspace_maya(log, origin_path) mc.file(new=True, force=True) mc.file(filepath, open=True, force=True) log.debug('Maya openned %s', filepath) elif HOST == NUKE: nuke.scriptClear() nuke.Root().setModified(False) nuke.scriptOpen(filepath) log.debug("Nuke opened %s", filepath) elif HOST == HOUDINI: hou.hipFile.load(filepath.replace( '\\', '/')) #, suppress_save_prompt = True) log.debug("Houdini opened %s", filepath) elif HOST == MAX: MaxPlus.FileManager.Open(filepath) log.debug("Max opened %s", filepath) elif HOST == C4D: c4d.documents.LoadFile(str(filepath.replace('\\', '/'))) log.debug("Cinema 4D opened %s", filepath) elif HOST == BLENDER: bpy.ops.wm.open_mainfile(filepath=filepath) log.debug("Blender opened %s", filepath) elif HOST == KATANA: KatanaFile.Load(filepath) return filepath
def importMtl(self): pos = NodegraphAPI.GetViewPortPosition(NodegraphAPI.GetRootNode()) currentItemName = str(self.listWidget.currentItem().text()) checkCat = str(self.catedoryCB.currentText()) if not checkCat == 'ALL': fileName = os.path.join(self.directory, checkCat, currentItemName + '.katana') else: fileName = os.path.join( str(self.listWidget.currentItem().data( QtCore.Qt.UserRole).toPyObject()), currentItemName + '.katana') if os.path.exists(fileName): KatanaFile.Import(fileName, floatNodes=False) imported = NodegraphAPI.GetAllSelectedNodes()[-1] DrawingModule.SetCustomNodeColor(imported, 0.2, 0.4, 0.1) NodegraphAPI.SetNodePosition(imported, ((pos[0][0]), pos[0][1])) else: QtGui.QMessageBox.information( None, currentItemName, 'There is no Material for {}, try importing Look File!'.format( currentItemName))
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 + "\"")
if node_name: nodes.append(NodegraphAPI.GetNode(node_name)) else: nodes = NodegraphAPI.GetAllNodesByType("PrmanShadingNode") for node in nodes: if node.getParameter("nodeType").getValue(0) == "PxrTexture": print( node.getParameter("parameters.filename.value").getValue(0)) if __name__ == '__main__': katana_scene = sys.argv[1] task_json = sys.argv[2] system_json = sys.argv[3] #_tid_from_cmd = sys.argv[2] #_inf_from_cmd = sys.argv[3] KatanaFile.Load(katana_scene) print(katana_scene) print(task_json) print(system_json) print(os.path.basename(sys.executable.lower())) kanana_analyse = ray_Katana_rendernodes() kanana_analyse.kanana_rendernodes(task_json) katana_asset = ray_Katana_asset() task_dict = katana_asset.open_json(task_json) system_dict = katana_asset.open_json(system_json) katana_asset.get_Alembic_In() katana_asset.get_PrmanShadingNode()
def execute(self, operation, file_path, context, parent_action, file_version, read_only, **kwargs): """ Main hook entry point :param operation: String Scene operation to perform :param file_path: String File path to use if the operation requires it (e.g. open) :param context: Context The context the file operation is being performed in. :param parent_action: This is the action that this scene operation is being executed for. This can be one of: - open_file - new_file - save_file_as - version_up :param file_version: The version/revision of the file to be opened. If this is 'None' then the latest version should be opened. :param read_only: Specifies if the file should be opened read-only or not :returns: Depends on operation: 'current_path' - Return the current scene file path as a String 'reset' - True if scene was reset to an empty state, otherwise False all others - None """ if file_path: file_path = file_path.replace("/", os.path.sep) if operation == "current_path": # return the current script path return "/path/here".replace("/", os.path.sep) # TODO!! elif operation == "open": # open the specified script KatanaFile.Load(file_path) elif operation == "save": # save the current script: if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) KatanaFile.Save(file_path) # TODO: warning: this may not work... elif operation == "save_as": if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) KatanaFile.Save(file_path) elif operation == "reset": """ Reset the scene to an empty state """ while KatanaFile.IsFileDirty(): # Changes have been made to the scene res = QtGui.QMessageBox.question( None, "Save your scene?", "Your scene has unsaved changes. Save before proceeding?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel) if res == QtGui.QMessageBox.Cancel: return False elif res == QtGui.QMessageBox.No: break else: if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) KatanaFile.Save( file_path) # TODO: warning: this may not work... return True # Create a new engine instance from the existing one, with the new context # Specify "shot_step" environment if the current context specifies a step if context.step: env = context.tank.pipeline_configuration.get_environment( "shot_step", context=context) # Otherwise, just get a "project" level context else: env = context.tank.pipeline_configuration.get_environment( "project", context=context) name = "tk-katana" # TODO: Get this properly? new_katana_engine = engine.KatanaEngine(context.tank, context, name, env) new_katana_engine.add_katana_menu()
def execute(self, operation, file_path, context, parent_action, file_version, read_only, **kwargs): """ Main hook entry point :param operation: String Scene operation to perform :param file_path: String File path to use if the operation requires it (e.g. open) :param context: Context The context the file operation is being performed in. :param parent_action: This is the action that this scene operation is being executed for. This can be one of: - open_file - new_file - save_file_as - version_up :param file_version: The version/revision of the file to be opened. If this is 'None' then the latest version should be opened. :param read_only: Specifies if the file should be opened read-only or not :returns: Depends on operation: 'current_path' - Return the current scene file path as a String 'reset' - True if scene was reset to an empty state, otherwise False all others - None """ if operation == "current_path": # return the current scene path return file_path elif operation == "open": KatanaFile.Load(file_path) elif operation == "save": if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) KatanaFile.Save(file_path) elif operation == "save_as": if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) KatanaFile.Save(file_path) elif operation == "reset": while KatanaFile.IsFileDirty(): # Changes have been made to the scene res = QtGui.QMessageBox.question( None, "Save your scene?", "Your scene has unsaved changes. Save before proceeding?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel) if res == QtGui.QMessageBox.Cancel: return False elif res == QtGui.QMessageBox.No: break else: if not os.path.exists(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) KatanaFile.Save( file_path) # TODO: warning: this may not work... return True
def execute(self, task, work_template, comment, thumbnail_path, sg_task, progress_cb, **kwargs): """ Main hook entry point :param task: Primary task to be published. This is a dictionary containing the following keys: { item: Dictionary This is the item returned by the scan hook { name: String description: String type: String other_params: Dictionary } output: Dictionary This is the output as defined in the configuration - the primary output will always be named 'primary' { name: String publish_template: template tank_type: String } } :param work_template: template This is the template defined in the config that represents the current work file :param comment: String The comment provided for the publish :param thumbnail: Path string The default thumbnail provided for the publish :param sg_task: Dictionary (shotgun entity description) The shotgun task to use for the publish :param progress_cb: Function A progress callback to log progress during pre-publish. Call: progress_cb(percentage, msg) to report progress to the UI :returns: Path String Hook should return the path of the primary publish so that it can be passed as a dependency to all secondary publishes :raises: Hook should raise a TankError if publish of the primary task fails """ # TODO: This may not be the best choice of function, as it returns an Asset ID. # When using the default Asset manager (file path) it'll work, though. scene_path = FarmAPI.GetKatanaFileName() # Find dependendies (TODO) dependencies = [] # This should be a list of file paths, I think # use templates to convert to publish path: output = task["output"] fields = work_template.get_fields(scene_path) fields["TankType"] = output["tank_type"] publish_template = output["publish_template"] publish_path = publish_template.apply_fields(fields) if os.path.exists(publish_path): raise TankError("The published file named '%s' already exists!" % publish_path) # save the scene: progress_cb(10.0, "Saving the scene") self.parent.log_debug("Saving the scene...") KatanaFile.Save(scene_path) # copy the file: progress_cb(50.0, "Copying the file") try: publish_folder = os.path.dirname(publish_path) self.parent.ensure_folder_exists(publish_folder) self.parent.log_debug("Copying %s --> %s..." % (scene_path, publish_path)) self.parent.copy_file(scene_path, publish_path, task) except Exception, e: raise TankError("Failed to copy file from %s to %s - %s" % (scene_path, publish_path, e))