def save(): filename = nuke.scriptName() nkDir, nkFile = os.path.split(filename) name, ext = os.path.splitext(nkFile) fileSaved = False components = name.split('_v') shotName = components[0] if len(components)<=1: version = 0 else: version = int(components[1]) while not fileSaved: # CONSTRUCT FILE NAME nkName = '%s_v%02d' % ( shotName, version ) # JOIN DIRECTORY AND NAME TO FORM FULL FILE PATH nkPath = os.path.join( nkDir, '%s.nk' % nkName ) if os.path.isfile(nkPath): version += 1 continue updateWriteNodeVersions(version) # SAVE NUKE SCRIPT nuke.scriptSaveAs(nkPath) fileSaved = True return nkPath
def publishScript(entityRef, context=None, versionUp=False, tagScript=True): item = items.NukeScriptItem() try: item.path = nuke.scriptName() except RuntimeError: item.path = None specification = item.toSpecification() session = FnAssetAPI.SessionManager.currentSession() manager = session.currentManager() # First we have to see what the management policy of the manager is policy = manager.managementPolicy(specification, context) if policy == FnAssetAPI.constants.kIgnored: raise RuntimeError( "The current asset management system doesn't handle Nuke Scripts (%s)" % policy) managesPath = policy & FnAssetAPI.constants.kWillManagePath # We only need to save a new version if we're not using a path-managing asset # system. if versionUp and not managesPath: nukescripts.script_version_up() item.path = nuke.scriptName() if not context: context = session.createContext() entity = None with context.scopedOverride(): context.access = context.kWrite context.locale = FnAssetAPI.specifications.DocumentLocale() if versionUp: context.locale.action = FnAssetAPI.constants.kDocumentAction_SaveNewVersion else: context.locale.action = FnAssetAPI.constants.kDocumentAction_Save with session.scopedActionGroup(context): entity = session.getEntity(entityRef, context, mustExist=False) # Switch on if its a tracking asset manager, or one that determines paths, if managesPath: entity = _writeScriptAsset(item, entity, context) else: entity = _publishScript(item, entity, context) if entity and tagScript: # We use the temp store as not to mess with the document state utils.storeTemporaryRootNodeData('entityReference', entity.reference) return entity.reference if entity else ''
def getVersion(): nukeFile = nuke.scriptName() try: version = int(ftrack_utils2.version_get(nukeFile, 'v')[1]) except ValueError: version = 0 return version
def next_mainversion(self, path): """ This function is use to Up mainVersion file :param path: path of current file :return: None """ vernum = self.vernum_check.findall(path) new_version_num = vernum[-1][:4] new_path = path.replace(vernum[-1], new_version_num) nuke.scriptSaveAs(new_path) # set write export to publish cur_filename = nuke.scriptName() publish_export_dir = os.path.dirname( cur_filename)[:-4] + 'publish' + '/' + vernum[-1][:4] if not os.path.exists(publish_export_dir): os.makedirs(publish_export_dir) file_name = os.path.basename(cur_filename).replace('.nk', '.mov') for node in nuke.allNodes(filter='Write'): if node['name'].getValue() == 'Write_exr': node['name'].setValue('Publish') node['file'].setValue(publish_export_dir + '/' + file_name) node['file_type'].setValue('mov') return else: nuke.message( 'Not find Write node named Write_exr,please set the Write node by yourself~' )
def save(): filename = nuke.scriptName() nkDir, nkFile = os.path.split(filename) name, ext = os.path.splitext(nkFile) fileSaved = False components = name.split('_v') shotName = components[0] if len(components) <= 1: version = 0 else: version = int(components[1]) while not fileSaved: # CONSTRUCT FILE NAME nkName = '%s_v%02d' % (shotName, version) # JOIN DIRECTORY AND NAME TO FORM FULL FILE PATH nkPath = os.path.join(nkDir, '%s.nk' % nkName) if os.path.isfile(nkPath): version += 1 continue updateWriteNodeVersions(version) # SAVE NUKE SCRIPT nuke.scriptSaveAs(nkPath) fileSaved = True return nkPath
def get_current_nk_filename(): nk_file = None try: nk_file = nuke.scriptName() except RuntimeError as e: nuke.message(e.message) return nk_file
def openScriptFolder(): wf = nuke.scriptName() dir = os.path.dirname(wf) wb.open(dir) return
def save_versioned(): try: filename = nuke.scriptName() except: filename = nuke.getFilename('Save As script', '*.nk') SaveVersion_Publish(filename, save_nuke)
def readJson(): filename = nuke.scriptName() tmpDir = os.path.split(filename)[0] jsonFile = os.path.join(tmpDir, 'shot_info.json') if not os.path.exists(jsonFile): return None jd = open(jsonFile).read() data = json.loads(jd) return data
def getTask(): nukeFile = nuke.scriptName() if 'FTRACK_TASKID' in os.environ: taskid = os.environ['FTRACK_TASKID'] else: taskid = None task = ftrack_utils2.getTask(_session, taskid, nukeFile) return task
def render_node(node): '''launch render''' out_path = node['file'].value() out_scriptcopy = node['tx_scriptcopy'].value() startFrame = int(nuke.Root()['first_frame'].value()) endFrame = int(nuke.Root()['last_frame'].value()) def _soloWrite(sel_node, all_enabled_write, mode='solo'): if mode == 'solo': for s in all_enabled_write: if s != sel_node.name(): print('node disabled---' + s) nuke.toNode(s)['disable'].setValue(True) elif mode == 'reverse': for s in all_enabled_write: nuke.toNode(s)['disable'].setValue(False) print('node enabled---' + s) askMessage = "Render Node: %s\nFile: %s\nFramerage: %s-%s\n" % ( node.name(), os.path.basename( node['file'].value()), startFrame, endFrame) c = nuke.ask(askMessage) if c: if not os.path.exists(os.path.dirname(out_path)): p = os.path.dirname(out_path) os.makedirs(p) print("out path created --- %s" % p) if not os.path.exists(os.path.dirname(out_scriptcopy)): s = os.path.dirname(out_scriptcopy) os.makedirs(s) print("out scriptcopy created --- %s" % s) all_enabled_write = [ n.name() for n in nuke.allNodes('Write') if n['disable'].value() == False ] _soloWrite(node, all_enabled_write, mode='solo') nuke.scriptSave() thisScript_path = nuke.scriptName() shutil.copy2(thisScript_path, out_scriptcopy) # nuke.render(node, startFrame, endFrame) exe = joinPath(nuke.EXE_PATH).replace('/', '\\') cmd_str = """start cmd /k "{exe}" -t -m 22 -xi {script} {start}-{end}""".format( exe=exe, node=node.name(), script=thisScript_path, start=startFrame, end=endFrame) subprocess.Popen(cmd_str, shell=True) _soloWrite(node, all_enabled_write, mode='reverse') else: print("user cancelled")
def get_current_script_name(): """ This function is use to get current nuke fileName :return: str of current nuke script name if unsave will return 'unsaveFile' """ try: return nuke.scriptName() except RuntimeError: return 'unsaveFile'
def versionSwith(): flag = nuke.ask('Are you sure you want to switch the Nuke type?') if flag: nuke.scriptSave() nukeScript = nuke.scriptName() nukeExe = sys.executable if nuke.env['nukex'] == True: nukeProcess = subprocess.Popen([nukeExe, nukeScript]) else: nukeProcess = subprocess.Popen([nukeExe, "--nukex", nukeScript]) nuke.executeInMainThread(nuke.scriptExit)
def setJsonOutputPath(): filename = nuke.scriptName() tmpDir = os.path.split(filename)[0] jsonFile = os.path.join(tmpDir, 'shot_info.json') if not os.path.exists(jsonFile): return '' jd = open(jsonFile).read() data = json.loads(jd) outFilename = data['outfile'].split('.')[0] outputFile = os.path.join(data['outdir'], outFilename + '.mov') return outputFile
def defaultWrite(): if nuke.NUKE_VERSION_MAJOR >= 7: writepath = '' try: writepath, _ = ospath.splitext(nuke.scriptName()) except RuntimeError: pass else: writepath = nuke.Root().name() write = nuke.createNode('Write') write['file'].setValue(writepath)
def getJsonFilePath(): filename = nuke.scriptName() tmpDir = os.path.split(filename)[0] jsonFile = os.path.join(tmpDir, 'shot_info.json') if not os.path.exists(jsonFile): return '' jd = open(jsonFile).read() data = json.loads(jd) fext = data['outfile'].split('.')[-1] outFile = findOutFile(data['outdir'], '.'+fext) outFilePath = os.path.join(data['outdir'], outFile) return outFilePath
def uploadToFtrack(): node = None nukeFile = nuke.scriptName() for write in nuke.allNodes('Write'): if write.name() == 'Write_mov': node = write break if node and node.knob('uploadToFtrack').value() and not \ nukeFile.endswith('.autosave'): print "Submitting to Dailies" outputFile = writeNodeManager.getOutputFile() if 'FTRACK_TASKID' in os.environ: taskid = os.environ['FTRACK_TASKID'] else: taskid = None task = ftrack_utils2.getTask(_session, taskid, nukeFile) node.knob('uploadToFtrack').setValue(False) if task: taskMeta = {'filename': nukeFile} fps = int(task['project']['custom_attributes']['fps']) ftrack_utils2.addMetadata(_session, task, taskMeta) ftrack_utils2.copyToApprovals(outputFile, task['project']) outfilemp4, outfilewebm, thumbnail, metadata = ftrack_utils2.prepMediaFiles( outputFile) print "Starting conversion..." result = ftrack_utils2.convertFiles(outputFile, outfilemp4, outfilewebm, thumbnail) if result: print "File conversion complete. Starting upload." asset = ftrack_utils2.getAsset(_session, task, 'ReviewAsset') status = ftrack_utils2.getStatus(_session, 'Pending Internal Review') ff = int(nuke.tcl('frames first')) lf = int(nuke.tcl('frames last')) try: ftrack_utils2.createAndPublishVersion( _session, task, asset, status, 'Upload for Internal Review', thumbnail, outputFile, outfilemp4, outfilewebm, metadata, ff, lf, fps) print 'cleaning up temporary files...' ftrack_utils2.deleteFiles(outfilemp4, outfilewebm, thumbnail) print 'Upload Complete!' except Exception: print "Error while uploading movie" ftrack_utils2.syncToJHB(outputFile) else: nuke.message( "Error in submitting to ftrack. The project details might be incorrect." )
def process(self, context): """Inject the current working file""" import nuke try: current_file = nuke.scriptName() except RuntimeError: # no filename available, have you saved? current_file = "Untitled" context.data["currentMaking"] = os.path.normpath(current_file) context.data["label"] = os.path.basename(current_file)
def getJsonFilePath(): filename = nuke.scriptName() tmpDir = os.path.split(filename)[0] jsonFile = os.path.join(tmpDir, 'shot_info.json') if not os.path.exists(jsonFile): return '' jd = open(jsonFile).read() data = json.loads(jd) fext = data['outfile'].split('.')[-1] outFile = findOutFile(data['outdir'], '.' + fext) outFilePath = os.path.join(data['outdir'], outFile) return outFilePath
def _eventHandler(self, event): """ Event handler for context switching events in Nuke Studio. :param event: The Nuke Studio event that was triggered. """ # Testing if we actually changed context or if the event got fired without # the user switching to the node graph. Early exit if it's still the # same context. if self._is_in_nuke == event.focusInNuke: return # Set the current context to be remembered for the next context # change. self._is_in_nuke = event.focusInNuke if self.is_in_nuke: # We switched from the project timeline to a Nuke node graph. try: script_path = nuke.scriptName() except Exception: script_path = None if script_path: # Switched to nuke with a script open. We have a path and could try # to figure out the sgtk context from that. new_context = self.get_new_context(script_path) if new_context is not None and new_context != self.engine.context: self.change_context(new_context) else: # There is no script open in the node graph. Because of that, we # will stay in the current context since we're essentially just in # a non-special state of Nuke Studio where we're on the empty node # graph tab. return else: # This is a switch back to the project-level timeline, # so change to that context based on that project file's # path. project_path = self._get_current_project() if project_path: new_context = self.get_new_context(project_path) if new_context: self.change_context(new_context) return # If all else fails here, then we just go back to the init # context that we have cached. Since we know we're not in # the Nuke node graph, then we should be fine to go ahead # with what we had at launch. self.change_context(self._init_context)
def isTimelineWrite(self): if not nuke.env['studio']: return False if len(self._nodeSelection) > 1 or len(self._nodeSelection) < 1: return False write = self._nodeSelection[0] if write == nuke.root(): ## must be a render of all 'write' nodes, this is tricky as there may be other executable nodes apart from write nodes ## lets assume the write nodes are write, writegeo, particlecache, and diskcache # there is a bug here however as there may be groups they are executable which will be skipped right now writeNodes = nuke.allNodes('Write') writeNodes.extend(nuke.allNodes('WriteGeo')) writeNodes.extend(nuke.allNodes('ParticleCache')) writeNodes.extend(nuke.allNodes('DiskCache')) if len(writeNodes) > 1: return False if len(writeNodes) > 0: write = writeNodes[0] timelineWriteNode = None try: from foundry.frameserver.nuke.workerapplication import GetWriteNode timelineWriteNode = GetWriteNode() except: pass if not timelineWriteNode: return False if timelineWriteNode.name() != write.name(): return False ## double check that this script is actually in a timeline try: from hiero.ui import isInAnyProject return isInAnyProject(nuke.scriptName()) except: pass return False
def getFramesProxy(position): filename = nuke.scriptName() shotDir = filename.split('scene')[0] proxyDir = os.path.join(shotDir, 'img/plates/proxy') frameList = [] if os.path.exists(proxyDir): frameList = findFrameByExt(proxyDir, '.jpeg') if len(frameList) > 0: frameList.sort() if position == 'first': return frameList[0] elif position == 'last': return frameList[-1] else: return 1
def getProxyPath(): outfile = outfilePath = '' filename = nuke.scriptName() shotDir = filename.split('scene')[0] plateDir = os.path.join(shotDir, 'img/plates/') proxyDir = os.path.join(shotDir, 'img/plates/proxy') if os.path.exists(proxyDir): outfile = findOutFile(proxyDir, '.jpeg') #Try and find a movie if no jpeg found if outfile == '': outfile = findMovieFile(plateDir) if outfile is not '': outfilePath = os.path.join(plateDir, outfile) else: outfilePath = os.path.join(proxyDir, outfile) return outfilePath
def absToRel(): try: selectedNodes = nuke.selectedNodes('Read') selectedNodes.append(nuke.selectedNodes('Write')) selectedNodes.append(nuke.selectedNodes('ReadGeo')) for n in selectedNodes: if n: relString = '[file dirname [value root.name]]' oldName = n['file'].value() if not (relString in oldName): scriptName = nuke.scriptName() scriptPath = os.path.dirname(scriptName) newName = relString + oldName[len(scriptPath):] n['file'].setValue(newName) except ValueError: print ValueError
def open_main(): try: node = nuke.selectedNode() if node: if node["file"]: dir = os.path.dirname(node["file"].value()) dir = dir.replace(' ', '') print dir if ']]' in dir: dir = dir.replace('[filedirname[valueroot.name]]', os.path.dirname(nuke.scriptName())) if os.path.exists(dir): open_file(dir) else: print "Directory does not exist" except ValueError: print "No node Selected"
def absToRel(): try: selectedNodes = nuke.selectedNodes('Read') selectedNodes.append(nuke.selectedNodes('Write')) selectedNodes.append(nuke.selectedNodes('ReadGeo')) for n in selectedNodes: if n: relString = '[file dirname [value root.name]]' oldName = n['file'].value() if not(relString in oldName): scriptName = nuke.scriptName() scriptPath = os.path.dirname(scriptName) newName = relString + oldName[len(scriptPath):] n['file'].setValue(newName) except ValueError: print ValueError
def warn_mtime(show_ok=False, since=None): """Show footage that mtime newer than script mtime. """ LOGGER.debug('Check warn_mtime') try: script_name = nuke.scriptName() except RuntimeError: if show_ok: nuke.message(utf8('文件未保存')) return script_mtime = os.path.getmtime(e(script_name)) since = since or script_mtime @run_with_clock('检查素材修改日期') def _get_mtime_info(): ret = {} for n in nuke.allNodes('Read', nuke.Root()): try: mtime = time.mktime( time.strptime(n.metadata('input/mtime'), '%Y-%m-%d %H:%M:%S')) except TypeError: continue if mtime > since: ret[nuke.filename(n)] = mtime ftime = time.strftime('%m-%d %H:%M:%S', time.localtime(mtime)) throtted_warning('{}: [new footage]{}'.format( u(n.name()), ftime)) return ret newer_footages = _get_mtime_info() if not (show_ok or newer_footages): return env = Environment(loader=FileSystemLoader(core.TEMPLATES_DIR)) template = env.get_template('mtime.html') data = [(k, pendulum.from_timestamp(v).diff_for_humans()) for k, v in newer_footages.items()] msg = template.render( script_name=script_name, script_mtime=pendulum.from_timestamp(script_mtime).diff_for_humans(), data=data) nuke.message(utf8(msg))
def getJsonFrames(position): filename = nuke.scriptName() tmpDir = os.path.split(filename)[0] jsonFile = os.path.join(tmpDir, 'shot_info.json') if not os.path.exists(jsonFile): return 1 jd = open(jsonFile).read() data = json.loads(jd) fext = data['outfile'].split('.')[-1] frameList = findFrameByExt(data['outdir'], '.'+fext) if len(frameList) > 0: frameList.sort() if position == 'first': return frameList[0] elif position == 'last': return frameList[-1] else: return 1
def getJsonFrames(position): filename = nuke.scriptName() tmpDir = os.path.split(filename)[0] jsonFile = os.path.join(tmpDir, 'shot_info.json') if not os.path.exists(jsonFile): return 1 jd = open(jsonFile).read() data = json.loads(jd) fext = data['outfile'].split('.')[-1] frameList = findFrameByExt(data['outdir'], '.' + fext) if len(frameList) > 0: frameList.sort() if position == 'first': return frameList[0] elif position == 'last': return frameList[-1] else: return 1
def SaveandClose(): ignoreUnsavedChanges = False filename = None root = nuke.Root() if not ignoreUnsavedChanges and root is not None and root.modified( ) and len(root.nodes()) > 0: runScriptSave = False if filename is None: scriptName = '' try: scriptName = nuke.scriptName() except RuntimeError: scriptName = 'untitled' try: runScriptSave = nuke.askWithCancel("Save changes to " + scriptName + " before closing?") except nuke.CancelledError: pass else: runScriptSave = True if runScriptSave: try: nuke.scriptSave(filename) except RuntimeError: pass nuke.scriptClear() AutoProjectSettings()
def main(): baked = '_baked' (base, ext) = os.path.splitext(nuke.scriptName()) if base.endswith(baked): newfile = base + ext else: newfile = base + baked + ext nukescripts.misc.clear_selection_recursive() for n in nuke.allNodes(): if n.Class() in ('Precomp', 'Group', 'Gizmo'): n.expand() nukescripts.misc.clear_selection_recursive() # for n in nuke.allNodes(): # if n.Class() == 'Write': # n['file'].setValue(n['file'].evaluate().strip()) nuke.scriptSaveAs(filename = newfile, overwrite = 1)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.setLayout(QtGui.QVBoxLayout()) renderBox = QtGui.QGroupBox('Render Set') renderBoxLayout = QtGui.QGridLayout() renderBox.setLayout(renderBoxLayout) self.layout().addWidget(renderBox) renderBoxLayout.addWidget(QtGui.QLabel('Filename:'), 0, 0) self.fileTextBox = QtGui.QLineEdit() self.fileTextBox.setReadOnly(True) try: filename = nuke.scriptName() except RuntimeError: filename = '' self.fileTextBox.setText(filename) browseButton = QtGui.QToolButton() browseButton.setText('...') browseButton.clicked.connect(self.openFileBrowser) renderBoxLayout.addWidget(self.fileTextBox, 0, 1) renderBoxLayout.addWidget(browseButton, 0, 2) renderBoxLayout.addWidget(QtGui.QLabel('Frame Range:'), 1, 0) self.frameBox = QtGui.QLineEdit() renderBoxLayout.addWidget(self.frameBox, 1, 1) renderBoxLayout.addWidget(QtGui.QLabel('Frame Step:'), 2, 0) self.frameStepBox = QtGui.QLineEdit() renderBoxLayout.addWidget(self.frameStepBox, 2, 1) renderBoxLayout.addWidget(QtGui.QLabel('Write Node:'), 3, 0) self.writeNodeBox = QtGui.QComboBox() self.populateWriteNodes() renderBoxLayout.addWidget(self.writeNodeBox, 3, 1) self.jobWidget = HQueueWidget('Nuke') self.layout().addWidget(self.jobWidget) self.jobWidget.splitmodeDrop.setCurrentIndex(0) self.jobWidget.splitmodeDrop.setEnabled(False) self.jobWidget.poolDrop.setCurrentIndex(2) self.jobWidget.progLineEdit.setEnabled(False) hlayout = QtGui.QHBoxLayout() submitButton = QtGui.QPushButton('Submit') submitButton.clicked.connect(self.submitRender) hlayout.addWidget(submitButton) hlayout.addItem(QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)) self.layout().addLayout(hlayout) self.layout().addItem(QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding))
def KuWrite(): '''Adding inputs for auto generate output path''' RENDER_TYPE = ['comp', 'precomp', 'lookdev'] node = nuke.createNode('Write') node.setName('KuWrite') node.knob('file').setEnabled(False) k_pipeline = nuke.Text_Knob('kupipeline', 'kuWrite', 'kuWrite') # Ku Pipeline Identifier k_tab = nuke.Tab_Knob('tb_KuWrite', 'KuWrite') k_projDir = nuke.File_Knob('fp_proj', 'proj dir') k_scene = nuke.String_Knob( 'tx_scene', 'scene', os.path.basename(nuke.scriptName()).split('_v')[0]) k_type = nuke.Enumeration_Knob('mu_type', 'type', RENDER_TYPE) k_precomp = nuke.String_Knob('tx_precomp', '_', 'NewPass') k_ver = nuke.Int_Knob('nm_ver', 'version', 1) k_div = nuke.Text_Knob('divider', '') k_set = nuke.PyScript_Knob('bt_set', '<b>Set Write</b>', 'mod_KuWrite.set_settings(nuke.thisNode())') k_render = nuke.PyScript_Knob('bt_render', '<b>Render</b>', 'mod_KuWrite.render_node(nuke.thisNode())') path_proj = os.path.dirname(os.path.dirname(nuke.script_directory())) k_projDir.setValue(path_proj) k_precomp.clearFlag(nuke.STARTLINE) k_precomp.setVisible(False) k_ver.setValue(1) k_render.clearFlag(nuke.STARTLINE) k_pipeline.setVisible(False) for k in [ k_tab, k_pipeline, k_projDir, k_scene, k_type, k_precomp, k_ver, k_div, k_set, k_render ]: node.addKnob(k) set_settings(node)
def scriptSaveAndClear(filename=None, ignoreUnsavedChanges=False): """ scriptSaveAndClear(filename=None, ignoreUnsavedChanges=False) -> None Calls nuke.scriptSave and nuke.scriptClear @param filename: Save to this file name without changing the script name in the project. @param ignoreUnsavedChanges: Optional. If set to True scripSave will be called, ignoring any unsaved changes @return: True when sucessful. False if the user cancels the operation. In this case nuke.scripClear will not be called """ root = nuke.Root() if not ignoreUnsavedChanges and root is not None and root.modified( ) and len(root.nodes()) > 0: runScriptSave = False if filename is None: scriptName = '' try: scriptName = nuke.scriptName() except RuntimeError: scriptName = 'untitled' try: runScriptSave = nuke.askWithCancel("Save changes to " + scriptName + " before closing?") except nuke.CancelledError: return False else: runScriptSave = True if runScriptSave: try: nuke.scriptSave(filename) except RuntimeError: return False nuke.scriptClear() return True
def tempWrite(): maxnum = 999999 randnum = str(random.randint(1, maxnum)).zfill(len(str(maxnum))) # set cache directory try: scriptdir, _ = ospath.split(nuke.scriptName()) cachedir = ospath.join(scriptdir, 'garbage_cache', randnum) except RuntimeError: cachedir = ospath.join(ospath.expanduser('~/garbage_cache'), randnum) # create the directory try: os.makedirs(cachedir) except OSError: if not ospath.isdir(cachedir): raise write = nuke.createNode('Write') write.setName('temp_write1') write['file'].setValue('{0}.####.tga'.format(ospath.join(cachedir, randnum))) # Join again(!) for the image seq's name. write['channels'].setValue('rgba')
def customSave(mode='save'): if mode == 'save': nuke.scriptSave("") elif mode == 'saveAs': nuke.scriptSaveAs("") elif mode == "saveNewVersion": write_list = [ write for write in nuke.allNodes('Write') if script_name( nuke.filename(write)) == script_name(nuke.scriptName()) ] nukescripts.script_and_write_nodes_version_up() if write_list: selectedNodes = nuke.selectedNodes()[:] nukescripts.clear_selection_recursive() for write in write_list: write.setSelected(True) nukescripts.version_up() write.setSelected(False) for node in selectedNodes: node.setSelected(True) nuke.scriptSave("")
def setOutputPath(type): filename = nuke.scriptName() filepath, file = os.path.split(filename) fname, fext = os.path.splitext(file) version = fname.split('_')[-1] shotDir = filename.split('scene')[0] parentDir = os.path.dirname(filename) if os.path.split(parentDir)[-1] == 'rotoscoping': compDir = os.path.join(shotDir, 'img/roto/%s' % version) else: compDir = os.path.join(shotDir, 'img/comps/%s' % version) outDir = os.path.join(compDir, type) if not os.path.exists(outDir): os.makedirs(outDir) thisNode = nuke.thisNode() fileType = thisNode.knob('file_type').value() if type == 'img': outFile = os.path.join(outDir, '%s.####.%s' % (fname, fileType)) elif type == 'mov': outFile = os.path.join(outDir, '%s.%s' % (fname, fileType)) elif type == 'qc': outFile = os.path.join(outDir, '%s_qc.%s' % (fname, fileType)) return outFile
def getRootDir(): nukeFile = nuke.scriptName() return nukeFile.split('compscript')[0]
def make_collect_folder(): split = os.path.splitext(nuke.scriptName()) dst_path = os.path.join(nuke.script_directory(), split[0] + "_Collected") return make_folder(dst_path)