def create_write_product_node(): node = nuke.createNode('Write', inpanel=True) node_name = 'WriteProduct' node_inst = 1 while nuke.exists(node_name + str(node_inst)): node_inst += 1 node_name += str(node_inst) node.knob('name').setValue(node_name) node.knob('beforeRender').setValue( 'dpa.nuke.utils.create_product_before_render()') node.knob('afterFrameRender').setValue( 'dpa.nuke.utils.set_permissions_after_frame()') products_tab = nuke.Tab_Knob("Product") node.addKnob(products_tab) node.addKnob(nuke.EvalString_Knob('product_desc', 'description', "")) node.addKnob( nuke.EvalString_Knob('product_name', 'name', get_default_product_name())) node.addKnob(nuke.EvalString_Knob('product_ver_note', 'description', "")) # hide the file knob node.knob('file_type').setValue('exr') node.knob('product_ver_note').setVisible(False)
def createJobSystemTab(node): #### create knobs tabKnob = nuke.Tab_Knob('JobSystem') jobKnob = nuke.EvalString_Knob('job') shotKnob = nuke.EvalString_Knob('shot') versionKnob = nuke.Int_Knob('version') takeKnob = nuke.Int_Knob('take') labelKnob = nuke.EvalString_Knob('usr_label', 'label') extKnob = nuke.EvalString_Knob('ext') buttonKnob = nuke.PyScript_Knob('Create Ouptut') #### set some defaults for the knobs jobKnob.setValue(os.environ.get('JOB')) shotKnob.setValue(os.environ.get('SHOT')) versionKnob.setValue(1) takeKnob.setValue(1) labelKnob.setValue('look') extKnob.setValue('exr') #### the python script to run when the user presses the 'Create dirs' button script = """ job = nuke.thisNode()['job'].value() shot = nuke.thisNode()['shot'].value() version = nuke.thisNode()['version'].value() take = nuke.thisNode()['take'].value() label = nuke.thisNode()['usr_label'].value() ext = nuke.thisNode()['ext'].value() user = os.environ.get('USER') #### build up the shot name shotName = '%s_v%02d_%s_%s' % (shot, int(version), user, label) #### grab base render directory from environment baseDir = os.environ.get('PIC') if baseDir == None: baseDir = '/tmp/MasterClass' fullPath = os.path.join(baseDir,shotName) try: os.makedirs(fullPath) nuke.message('Created dir %s' % fullPath) except OSError: nuke.message('WARNING: err creating dir %s' % dir) pass fileName = '%s.%s.%s' % (shotName, '%04d', ext) fname = os.path.join(baseDir,shotName,fileName) #### set the file knob to the new file name nuke.thisNode()['file'].setValue(fname) """ buttonKnob.setValue(script) #### add knobs to node for k in [tabKnob, jobKnob, shotKnob, versionKnob, takeKnob,labelKnob, buttonKnob, extKnob]: node.addKnob(k)
def addAssign(node): file = node['file'].getValue() assignTab = nuke.Tab_Knob('assign') fileKnob = nuke.Text_Knob('filePath', file) artistKnob = nuke.EvalString_Knob('artistName', 'Artist Name', '-') mandaysKnob = nuke.EvalString_Knob('mandays', 'Mandays', '1') node.addKnob(assignTab) node.addKnob(artistKnob) node.addKnob(mandaysKnob) return
def createAutowrite(): w = nuke.createNode('Write', inpanel=False) count = 1 while nuke.exists('AutoWrite' + str(count)): count += 1 w.knob('name').setValue('AutoWrite' + str(count)) w.knob('tile_color').setValue(8388607) t = nuke.Tab_Knob("Additional Parameters") w.addKnob(t) w.addKnob( nuke.Enumeration_Knob('outputType', 'Output Type', ['Comp', 'Precomp', 'LTComp', 'Matte'])) w.addKnob(nuke.EvalString_Knob('aov', 'Prefix', '')) w.addKnob(nuke.EvalString_Knob('descriptor', 'Suffix', '')) w['file_type'].setValue('exr')
def constrain(): """Get the selected nodes in the DAG""" selNodes = nuke.selectedNodes() """ Classes that will allow this script to run """ listNodes = [ 'Cube', 'Sphere', 'Axis2', 'Card2', 'Cylinder', 'ReadGeo2', 'Spotlight', 'Light2', 'DirectLight', 'Camera', 'Camera2', 'Card' ] cleanList = set(listNodes) """ Run for each selected node """ for i in selNodes: """ Get the Class for each node """ _class = i.Class() """ If Class is found on the list (listNodes) add the knobs, otherwise delete vars and do nothing """ if _class in cleanList: """ Sets Knobs """ lookTab = nuke.Tab_Knob("look", "Constrain") target = nuke.EvalString_Knob("look_at", "Look at") setlookObject = nuke.PyScript_Knob( "set", "Set", "selNodes = nuke.selectedNodes()\n\nif len(selNodes) == 1:\n\tthisNode = selNodes[-1]\n\tk = thisNode['look_at']\n\t\n\tif k.value() == \"\":\n\t\tlookAt = nuke.getInput(\'Type the target node name\')\n\t\tk.setValue(lookAt)\n\n\telse:\n\t\tlookAt = k.value()\n\t\tk.setValue(lookAt)\n\nelif len(selNodes) > 1:\n\tthisNode = selNodes[-1]\n\tlookAt = selNodes[-2]\n\tk = thisNode['look_at']\n\tk.setValue(lookAt.name())\n\t\nelse:\n\tpass\n\nlookObject = k.value()\n\nxX = \'degrees(atan2(\' + lookObject + \'.translate.y-translate.y,sqrt(pow(\' + lookObject + \'.translate.x-translate.x,2)+pow(\' + lookObject + \'.translate.z-translate.z,2))))\'\nyX = lookObject + \'.translate.z-this.translate.z >= 0 ? 180+degrees(atan2(\' + lookObject + \'.translate.x-translate.x,\' + lookObject + \'.translate.z-translate.z)):180+degrees(atan2(\' + lookObject + \'.translate.x-translate.x,\' + lookObject + \'.translate.z-translate.z))\'\n\nthisNode['rotate'].setExpression(xX, 0)\nthisNode['rotate'].setExpression(yX, 1)\n" ) """ Adds Knobs """ i.addKnob(lookTab) i.addKnob(target) i.addKnob(setlookObject) else: pass
def dropAutoWrite(): """ Creates an automatic Write node (an "AutoWrite") which uses the name and path of the Nuke script that it's in to create it's own output path. Changes made to the script's name (such as versioning up) wil be reflected in the output path auto-magically with no user intervention. """ # Create the Write node that will become an AutoWrite w= nuke.createNode('Write', inpanel=False) # Rename it to AutoWrite # (Also, deal with the number problem) count = 1 while nuke.exists('AutoWrite' + str(count)): count += 1 w.knob('name').setValue('AutoWrite' + str(count)) # Add the tab to hold the variables containing path fragments so we can have # a less messy file path. t = nuke.Tab_Knob("Path Fragments") w.addKnob(t) w.addKnob(nuke.EvalString_Knob('proj_root', 'Project Root', '[join [lrange [split [value root.name] / ] 0 4 ] / ]')) w.addKnob(nuke.EvalString_Knob('seq', 'Sequence', '[lrange [split [value root.name] / ] 5 5 ]')) w.addKnob(nuke.EvalString_Knob('shot', 'Shot Name', '[lrange [split [value root.name] / ] 6 6 ]')) w.addKnob(nuke.EvalString_Knob('script', 'Script Name', '[file rootname [file tail [value root.name] ] ]')) # Display the values of our path fragment knobs on the node in the DAG for # error-checking. # This can be turned off if it makes too much of a mess for your taste. feedback = """ Output Path: [value file] Project Root: [value proj_root] Sequence: [value seq] Shot Name: [value shot] Script Name: [value script] """ w.knob('label').setValue(feedback) # Re-assemble the path fragments into a proper output path output_path = "[value proj_root]/[value seq]/[value shot]/comps/[value script]/[value input.width]x[value input.height]/[value script].%04d.dpx" w.knob('file').fromScript(output_path)
def add_auto_path(self, w=None): if not w: w = nuke.thisNode() t = nuke.Tab_Knob("paths") w.addKnob(t) w.addKnob( nuke.EvalString_Knob('task_output', 'Task Output', '[python os.getenv("task output")]')) w.addKnob( nuke.EvalString_Knob( 'script', 'Script Name', '[file rootname [file tail [value root.name] ] ]')) w.addKnob( nuke.EvalString_Knob( 'output_exp', 'Output expression', "[value task_output]/[value name]/[value version]/[value script].####.exr" )) w.addKnob( nuke.EvalString_Knob( 'version_string', 'version', r'[python \"\".join(nukescripts.version_get(nuke.root().knob(\"name\").value(), \"v\"))]' )) w.addKnob(nuke.Text_Knob(' ')) updateKnob = nuke.PyScript_Knob('bake_path', 'Bake Path') w.addKnob(updateKnob) updateKnob.setValue('reload(ft_nuke); ft_nuke.Write().bake_path()') updateKnob = nuke.PyScript_Knob('live_path', 'Live Path') w.addKnob(updateKnob) updateKnob.setValue('reload(ft_nuke); ft_nuke.Write().live_path()') self.bake_path(w) w.knob('file_type').setValue('exr') w.knob('datatype').setValue('16') w.knob('compression').setValue('Zips')
def run(): file_open = nuke.Root().name() x = core.locate.find() job = x.job shot = x.shot user = x.user script = x.version w = nuke.createNode('Write', inpanel=True) count = 1 while nuke.exists('RAW_Write_' + str(count)): count += 1 w.knob('name').setValue('RAW_Write_' + str(count)) t = nuke.Tab_Knob("RAW Write") w.addKnob(t) feedback = """ [value dirName] """ w.addKnob( nuke.EvalString_Knob( 'fileName', 'fileName', '[string trimright [string trimright [file tail [value root.name]] .nk] _thread0]' )) w.addKnob( nuke.EvalString_Knob( 'dirName', 'dirName', os.path.join(core.jobsRoot, job, 'vfx', 'nuke', shot, 'plates', 'output').replace('\\', '/'))) w.addKnob( nuke.Enumeration_Knob( 'renderType', 'render_dir', ['slapcomp', 'cleanup', 'prerender', 'matte', 'final'])) output_path = "[value dirName]/[value renderType]/[value fileName]/[value fileName].%04d.dpx" w.knob('file').fromScript(output_path) # w.knob('colorspace').setValue('linear') w.knob('raw').setValue(1) w.knob('file_type').setValue('dpx') w.knob('datatype').setValue('10')
def _add_auto_name_knobs(node): auto_ext_konb = nuke.CascadingEnumeration_Knob( 'dayu_write_ext_list', 'format', ['.exr', '.dpx', '.tif', '.png', '.jpg', '.mov']) auto_ext_konb.setFlag(0x1000) node.addKnob(auto_ext_konb) user_sub_level_knob = nuke.EvalString_Knob('dayu_write_user_sub_level', 'Sub Level') user_sub_level_knob.setFlag(0x1000) node.addKnob(user_sub_level_knob) button_knob = nuke.PyScript_Knob('dayu_write_auto_name', 'Auto Rename') button_knob.setFlag(0x1000) node.addKnob(button_knob)
def __init__(self): nukescripts.PythonPanel.__init__(self, 'Knob Changer', 'com.0hufx.KnobChanger') self.nodeSel = nuke.Enumeration_Knob('nodeSel', 'Apply to', ['All Nodes', 'Selected Nodes']) self.addKnob(self.nodeSel) self.Update = nuke.PyScript_Knob('update', 'Update') self.addKnob(self.Update) self.nodesChange = nuke.Enumeration_Knob('nodesChange', 'Nodes', []) self.addKnob(self.nodesChange) self.NodeKnobs = nuke.Enumeration_Knob('nodeKnobs', 'Knob', []) self.addKnob(self.NodeKnobs) self.TypeKnob = nuke.EvalString_Knob('TypeKnob', '') self.addKnob(self.TypeKnob) self.TypeKnob.setEnabled(False) self.EnableTypeKnob = nuke.Boolean_Knob('EnableTypeKnob', 'Type Knob Name') self.addKnob(self.EnableTypeKnob) self.KnobValue = nuke.EvalString_Knob('Value', 'New Value') self.addKnob(self.KnobValue) self.Execute = nuke.PyScript_Knob('execute', 'Execute') self.addKnob(self.Execute)
def autoWrite(): currentNode = nuke.createNode('Write', inpanel=False) currentNode.knob("name").setValue("AutoWrite") selNode = nuke.root().name() if selNode != "Root": splitPath = selNode.split('/')[:-1] splitPath = ('/').join(splitPath) custom = nuke.Tab_Knob('Tab Fragments') currentNode.addKnob(custom) currentNode.addKnob( nuke.EvalString_Knob( 'script', 'Script Name', '[file rootname [file tail [value root.name] ] ]')) feedback = """ [value file] [value this.input.name] """ currentNode.knob('label').setValue(feedback) OutputFile = splitPath + ".%04d." + nuke.getInput("data Type") newFile = OutputFile.split('/')[-1:] newFile = newFile[0].split('.')[-1] currentNode['file'].setValue(OutputFile) currentNode['file_type'].setValue(newFile) s = nuke.ask("Shall i execute?") if s == True: nuke.execute(currentNode, start=1, end=int(nuke.getInput("Enter Last Frame"))) else: nuke.message("Please save the file")
def create_AutoWrite(): try: # this just test the file test = os.path.basename( nuke.root().name()).split('_v')[1].split('.nk')[0] #creates a unique write node name AutoWrite = nuke.createNode('Write', inpanel=True) count = 1 while nuke.exists('AutoWrite_' + str(count)): count += 1 AutoWrite.knob('name').setValue('AutoWrite_' + str(count)) AutoWrite.addKnob(nuke.Text_Knob('AutoWrite_test', '', "AutoWrite")) # Create AutoWrite Tab for settings AW_Settings = nuke.Tab_Knob('Auto Write Settings') AutoWrite.addKnob(AW_Settings) # Create AutoWrite UI AutoWrite.addKnob(nuke.File_Knob( 'AW_userCompPath', 'Render Dir : ', )) AutoWrite['AW_userCompPath'].setValue("SET YOUR RENDER FOLDER HERE") # Show Output AutoWrite.addKnob( nuke.EvalString_Knob('AW_show_output', 'OUTPUT: ', '')) AutoWrite['AW_show_output'].setEnabled(False) # Script name AutoWrite.addKnob( nuke.EvalString_Knob('AW_autoScriptName', 'Script name : ', '')) AutoWrite['AW_autoScriptName'].setEnabled(False) # Version number AutoWrite.addKnob( nuke.EvalString_Knob('AW_autoVersion', 'Version : ', '')) AutoWrite['AW_autoVersion'].setEnabled(False) # Additional Information AutoWrite.addKnob(nuke.EvalString_Knob('AW_userInfo', 'Info : ', '')) AutoWrite['AW_userInfo'].setValue("Info") # Auto Padding AutoWrite.addKnob(nuke.Int_Knob('AW_userPadding', 'Padding # :')) AutoWrite['AW_userPadding'].setValue(4) # Auto Naming AutoWrite.addKnob(nuke.Boolean_Knob('AW_autoName', 'Auto Name?')) AutoWrite['AW_autoName'].setEnabled(False) AutoWrite.addKnob(nuke.Text_Knob('auto_divider01', '', '')) # Formating Options AutoWrite.addKnob( nuke.EvalString_Knob('AW_userFormat', 'Format : ', '')) AutoWrite['AW_userFormat'].setValue( 'Path/Script/Version/Script_Info_Version') AutoWrite['AW_userFormat'].setFlag(nuke.ENDLINE) AutoWrite.addKnob(nuke.Text_Knob('auto_divider02', '', '')) AutoWrite_FormatOptions = [ "/", "_", "Path", "Script", "Version", "Info", "Date" ] for Options in AutoWrite_FormatOptions: AutoWrite.addKnob( nuke.PyScript_Knob( "Options_" + Options, Options, 'MOTools.updateformat_AutoWrite("' + Options + '")')) AutoWrite.addKnob(nuke.Text_Knob('auto_divider03', '', '')) # Add user info AutoWrite.addKnob( nuke.Text_Knob( 'data', '', infoScript + " | " + infoContact + " | " + __version__)) AutoWrite.addKnob( nuke.PyScript_Knob( "help", "?", 'nukescripts.start ("https://www.mikeoakley.com/wiki/motools-for-nuke/")' )) # Auto set file_type AutoWrite['file_type'].setValue('exr') return except IndexError: nuke.message( "ERROR: Version naming\nex: myfile_v001.nk\n Node will be deleted") nuke.delete(AutoWrite) return except: return
def add_ada_tab(nodes=None): """ Add an ada tab to a given list of nodes. The tab is the instructions for what Ada should do to this node. Args: nodes (list): List of nuke node objects (including root). """ if nodes is None: nodes = nuke.selectedNodes() elif not isinstance(nodes, list): nodes = [nodes] for node in nodes: if node.Class() == "Viewer" or has_ada_tab(node): continue ada_tab = nuke.Tab_Knob("ada", "Ada") bake_knobs_boolean = nuke.Boolean_Knob("bake_knobs", " ") bake_knobs_boolean.setValue(False) bake_knobs_boolean.setTooltip("bake knobs to bake") bake_knobs_boolean.setFlag(nuke.STARTLINE) knobs_to_bake_string = nuke.EvalString_Knob("knobs_to_bake", "knobs to bake ") knobs_to_bake_string.clearFlag(nuke.STARTLINE) knobs_to_bake_string.setTooltip( "comma-separated list of knobs to bake, or values " "to assign. eg: 'value=10, file=[pcrn input 1]'") set_knobs_boolean = nuke.Boolean_Knob("set_knobs", " ") set_knobs_boolean.setValue(False) set_knobs_boolean.setTooltip("set knobs to bake") set_knobs_boolean.setFlag(nuke.STARTLINE) knobs_to_set_string = nuke.EvalString_Knob("knobs_to_set", "knobs to set ") knobs_to_set_string.clearFlag(nuke.STARTLINE) knobs_to_set_string.setTooltip( "assign value. eg: 'value=10, file=[pcrn input 1]'") execute_buttons_boolean = nuke.Boolean_Knob("execute_knobs", " ") execute_buttons_boolean.setValue(False) execute_buttons_boolean.setTooltip("execute knobs/buttons") execute_buttons_boolean.setFlag(nuke.STARTLINE) execute_buttons_string = nuke.EvalString_Knob("knobs_to_execute", "knobs to execute ") execute_buttons_string.clearFlag(nuke.STARTLINE) execute_buttons_string.setTooltip( "comma-separated list of knobs (buttons) to execute()") exeucte_code_boolean = nuke.Boolean_Knob("execute_code", " ") exeucte_code_boolean.setValue(False) exeucte_code_boolean.setTooltip("run the code to exec") exeucte_code_boolean.setFlag(nuke.STARTLINE) execute_code_string = nuke.Multiline_Eval_String_Knob( "code_to_execute", "code to execute ") execute_code_string.setTooltip( "python code to exec()\nnuke.thisNode() " "is available to the code") execute_code_string.clearFlag(nuke.STARTLINE) queue_order_int = nuke.Int_Knob("queue_order", "queue order") queue_order_int.clearFlag(nuke.STARTLINE) queue_order_int.setTooltip( "Nodes are baked from the lowest order to the " "highest. Default value is 0") do_not_bake_boolean = nuke.Boolean_Knob( "do_not_bake", " do not bake this node ") do_not_bake_boolean.setValue(False) do_not_bake_boolean.setTooltip("do not bake this node") do_not_bake_boolean.setFlag(nuke.STARTLINE) knobs_to_serialise = nuke.Multiline_Eval_String_Knob( "knobs_to_serialise", "knobs to serialise") knobs_to_serialise.setTooltip( "these knobs will be saved with the template and " "then can be set externally") node.addKnob(ada_tab) node.addKnob(bake_knobs_boolean) node.addKnob(knobs_to_bake_string) node.addKnob(set_knobs_boolean) node.addKnob(knobs_to_set_string) node.addKnob(execute_buttons_boolean) node.addKnob(execute_buttons_string) node.addKnob(exeucte_code_boolean) node.addKnob(execute_code_string) node.addKnob(do_not_bake_boolean) node.addKnob(queue_order_int) node.addKnob(knobs_to_serialise) try: node.knob("autolabel").setValue( "__import__('ada.nuke.utils', fromlist=['autolabel']).autolabel()" ) except ImportError: pass # set knob changed on the newly created ada node kc = node.knob("knobChanged") cur_kc = kc.value() new_kc = "{}\n{}".format(cur_kc, ADA_KNOB_CHANGED) kc.setValue(new_kc) node.knob("icon").setValue("ada_raw.png")
def __init__(self, groupContext): nukescripts.PythonPanel.__init__(self, "Link to Tracker", "uk.co.thefoundry.LinkToTrackPanel") # Initialising return variable global _gTrackExpression _gTrackExpression = ["", ""] # Show a list of trackers in the project. self._trackers = [] with nuke.toNode(groupContext): for n in nuke.allNodes(): if n.linkableKnobs(nuke.KnobType.eXYKnob): self._trackers.append(n.name()) self._tracker = nuke.Enumeration_Knob("trackers", "tracker node", self._trackers) self._tracker.setTooltip("The Tracker node to link to.") self._tracker.setValue(_getLastState(self._tracker, self._trackers[0])) self.addKnob(self._tracker) # Choice of linking to the translate on the tracker or to track point positions. self._link_to = nuke.Enumeration_Knob( "link_to", "link to", ["position", "translate", "translate as offset"]) self._link_to.setValue(_getLastState(self._link_to, 'translate')) self._link_to.setTooltip( "Choose whether to link to the translation computed in the Tracker's Transform tab or to a specific track point position. If multiple track points are chosen they will be averaged." ) self.addKnob(self._link_to) self._link_to.setFlag(nuke.ENDLINE) # Creating all of the linkable knobs for all trackers in advance, then # going to hide / show them based on the visibility below. self._all_linkables = {} for tracker in self._trackers: n = nuke.toNode(tracker) self._all_linkables[tracker] = [] l = n.linkableKnobs(nuke.KnobType.eXYKnob) for i in range(len(l)): # Removing any translate links as they are serviced by the "link" enum above. if l[i].knob().name() == "translate": continue if len(l[i].displayName()) > 0: knobname = l[i].displayName() exprname = "tracks." + str(i - 1) else: knobname = l[i].knob().name() exprname = knobname point = nuke.Boolean_Knob(exprname, knobname) point.setTooltip( "Use this track point when linking to 'position'.") point.setVisible(False) self.addKnob(point) self._all_linkables[tracker].append(point) # Show the expression that's going to set in case user wants to tweak or # copy it before closing the dialog. self._expressionX = nuke.EvalString_Knob("expression.x") self._expressionX.setTooltip( "This is the expression that will be applied to the x position. You can edit it before closing the dialog but changing settings on this panel will rebuild it, losing your changes." ) self.addKnob(self._expressionX) self._expressionY = nuke.EvalString_Knob("expression.y") self._expressionY.setTooltip( "This is the expression that will be applied to the y position. You can edit it before closing the dialog but changing settings on this panel will rebuild it, losing your changes." ) self.addKnob(self._expressionY) # Set up knobs and linkable objects self._updateEverything()
def dropAutoWrite(): try: """ Creates an automatic Write node (an "AutoWrite") which uses the name and path of the Nuke script that it's in to create it's own output path. Changes made to the script's name (such as versioning up) wil be reflected in the output path auto-magically with no user intervention. """ # Create the Write node that will become an AutoWrite w = nuke.createNode('Write', inpanel=False) # Rename it to AutoWrite # (Also, deal with the number problem) count = 1 while nuke.exists('AutoWrite' + str(count)): count += 1 w.knob('name').setValue('AutoWrite' + str(count)) #Get version number #snagVersion = nukescripts.version_get( nuke.Root().name(), 'v' ).__getitem__(1) # Add the tab to hold the variables containing path fragments so we can have # a less messy file path. pathFragmentsTab = nuke.Tab_Knob("Path Fragments") pathFragmentsTab.setFlag(nuke.INVISIBLE) projRootKnob = nuke.EvalString_Knob( 'proj_root', 'Project Root', '[join [lrange [split [value root.name] / ] 0 3 ] / ]') projRootKnob.setFlag(nuke.INVISIBLE) shotKnob = nuke.EvalString_Knob( 'shot', 'Shot Name', '[lrange [split [value root.name] / ] 8 8 ]') shotKnob.setFlag(nuke.INVISIBLE) projectKnob = nuke.EvalString_Knob( 'project', 'Project', '[lrange [split [value root.name] / ] 4 4 ]') projectKnob.setFlag(nuke.INVISIBLE) scriptVersionKnob = nuke.EvalString_Knob( 'scriptVersion', 'Version', "v[python nukescripts.version_get( nuke.Root().name(), 'v' ).__getitem__(1)]" ) scriptVersionKnob.setFlag(nuke.INVISIBLE) scriptKnob = nuke.EvalString_Knob( 'script', 'Script Name', '[file rootname [file tail [value root.name] ] ]') scriptKnob.setFlag(nuke.INVISIBLE) w.addKnob(pathFragmentsTab) w.addKnob(projRootKnob) w.addKnob(shotKnob) w.addKnob(projectKnob) w.addKnob(scriptVersionKnob) w.addKnob(scriptKnob) # Display the values of our path fragment knobs on the node in the DAG for # error-checking. # This can be turned off if it makes too much of a mess for your taste. feedback = """ Output Path: [value file] """ #w.knob('label').setValue(feedback) proj_root = w.knob('proj_root').value() shot = w.knob('shot').value() project = w.knob('project').value() scriptVersion = w.knob('scriptVersion').value() script = w.knob('script').value() digit = '%04d' ext = w['file_type'].value() # Re-assemble the path fragments into a proper output path output_path = "%(proj_root)s/%(project)s/04_renders/%(shot)s/03_composite/%(script)s/%(script)s.%(digit)s.%(ext)s" % locals( ) w.knob('file').fromScript(output_path) # Set values for OUTPUT settings #w.knob('colorspace').setValue("sRGB") #w.knob('file_type').setValue("png") #w.knob('datatype').setValue("16 bit") #fill the 'before render' box with python code to create the directory if it doesn't exist w.knob('beforeRender').setValue( "import createWriteDir; createWriteDir.main()") except: pass