def __init__(self): """ Adding knobs to UI panel. """ nukescripts.PythonPanel.__init__(self, "Smart Floating Notepad", "com.parimalvfx.SmartFloatingNotepadPanel") self.notepadOne = nuke.Multiline_Eval_String_Knob("first_notepad", "") self.notepadOne.setTooltip("Take your notes here...") self.notepadTwo = nuke.Multiline_Eval_String_Knob("second_notepad", "") self.notepadTwo.setTooltip("Compare notes with first notepad") self.notepadTwo.clearFlag(nuke.STARTLINE) self.notepadTwo.setVisible(False) self.options = nuke.Boolean_Knob("options", "Options", True) self.options.setTooltip("Toggle notepad options") self.options.setFlag(nuke.STARTLINE) self.compare = nuke.PyScript_Knob("compare", "Compare Notes") self.compare.setTooltip("Toggle second notepad") self.compare.setFlag(nuke.STARTLINE) self.bookmark = nuke.PyScript_Knob("bookmark", "Bookmark") self.bookmark.setTooltip("Bookmark first notepad's notes.") self.bookmarkList = nuke.Enumeration_Knob("bookmark_list", "", []) self.bookmarkList.setTooltip("Open bookmarked notes in second notepad.") self.bookmarkList.clearFlag(nuke.STARTLINE) self .clearBookmark = nuke.PyScript_Knob("clear_bookmark", "Clear Bookmark") self.addKnob(self.notepadOne) self.addKnob(self.notepadTwo) self.addKnob(self.options) self.addKnob(self.compare) self.addKnob(self.bookmark) self.addKnob(self.bookmarkList) self.addKnob(self.clearBookmark)
def __init__(self): nukescripts.PythonPanel.__init__(self, "error report", "error report") if nuke.errors_lenErrors == 0: col = "green" else: col = "red" countErrors = '<span style="color:{col}">{countErr}</span>'.format( col=col, countErr=nuke.errors_lenErrors) #create elements self.errorCount = nuke.Text_Knob('', 'errors found: ', '%s' % countErrors) self.div = nuke.Text_Knob("", "", "") self.errorCount.setFlag(nuke.STARTLINE) self.outputPath = nuke.File_Knob('output to: ', '') self.write = nuke.PyScript_Knob('write', 'write') self.update = nuke.PyScript_Knob('update', 'update') self.outputPath = nuke.File_Knob('', 'outputPath') #add elements self.addKnob(self.errorCount) self.addKnob(self.outputPath) self.addKnob(self.write) self.addKnob(self.update) self.addKnob(self.div) #error node knobs for errorNode in nuke.errors_nodes: self.en = nuke.PyScript_Knob(errorNode.name(), errorNode.name()) self.addKnob(self.en) nuke.errors_footageBtn.append(self.en)
def RestoreHiddenInputs(): all_hidden = [ n.name() for n in nuke.allNodes() if n['hide_input'].value() == True and n.Class() is not 'Viewer' ] node_hidden = nuke.nodes.NoOp(name='HiddenInputs', hide_input=True, note_font_size=48, note_font='bold', note_font_color=4294967295, tile_color=4278190335) nuke.nodes.BackdropNode(tile_color=4278190335, xpos=int(node_hidden.xpos() - 160), ypos=int(node_hidden.ypos() - 60), bdwidth=int(node_hidden.screenWidth() + 320), bdheight=int(node_hidden.screenHeight() + 120)) cmd_s = "import mod_RestoreHiddenInputs as rhi\nrhi.switch(nuke.thisNode())" cmd_u = "import mod_RestoreHiddenInputs as rhi\nrhi.upd(nuke.thisNode())" k_tab = nuke.Tab_Knob('tb_user', 'RestoreHiddenInputs') k_switch = nuke.PyScript_Knob('bt_switch', 'Hide/Show', cmd_s) k_upd = nuke.PyScript_Knob('bt_upd', 'Update Nodes', cmd_u) k_store = nuke.String_Knob('tx_store', 'Nodes:', ';'.join(all_hidden)) k_upd.clearFlag(nuke.STARTLINE) node_hidden.addKnob(k_tab) node_hidden.addKnob(k_switch) node_hidden.addKnob(k_upd) node_hidden.addKnob(k_store)
def __init__(self): nukescripts.PythonPanel.__init__(self, 'C1 Login') # self.server = smtplib.SMTP('smtp.gmail.com', 587) self.status = 'offline' # self.server.starttls() self.email = None self.workingDir = None self.scriptDir = { 'root': os.path.join(os.path.join(os.path.realpath(__file__), os.pardir), os.pardir), 'c1_tools': os.path.join(os.path.realpath(__file__), os.pardir) } #_define knobs self.inp_email = nuke.String_Knob('email', 'C1 Initials: ') self.inp_workingDir = nuke.String_Knob('workingDir', 'Local Working Directory: ') self.btn_workingDir = nuke.PyScript_Knob("Set Working Dir") self.loginButton = nuke.PyScript_Knob("Login") self.cancelButton = nuke.PyScript_Knob("Cancel") #_add knobs self.addKnob(self.inp_workingDir) self.addKnob(self.btn_workingDir) self.addKnob(self.inp_email) self.addKnob(self.loginButton) self.addKnob(self.cancelButton) return
def add_driver(knobtype): """Add a set driver knobs @knobtype: (str) Nuke Knob Type """ try: dr_no = int(max([find_digit(k) for k in nuke.thisNode().knobs() if k.startswith('dr')]) + 1) except Exception as e: nuke.warning(e) dr_no = 0 label = nuke.getInput('Label this Driver') if label: k_this_name = 'dr%02d_%s' % (dr_no, label) k_this = eval("nuke.{}('')".format(knobtype)) k_this.setName(k_this_name) k_this.setLabel(label) k_this.setFlag(nuke.STARTLINE) k_set_driven = nuke.PyScript_Knob('dr%02ddriven' % dr_no, STR_SETDRIVEN) k_set_driven.setCommand(STR_CMD_SETUP.format("set_driven('%s')" % k_this_name)) k_set_driven.setTooltip(k_this_name) k_set_driven.clearFlag(nuke.STARTLINE) k_list_driven = nuke.PyScript_Knob('dr%02dlist' % dr_no, STR_LISTDRIVEN) k_list_driven.clearFlag(nuke.STARTLINE) k_list_driven.setCommand(STR_CMD_SETUP.format("show_list_driven('%s')" % k_this_name)) k_list_driven.setTooltip(k_this_name) n = nuke.thisNode() n.addKnob(k_this) n.addKnob(k_set_driven) n.addKnob(k_list_driven)
def __init__(self): """ Adding knobs to UI panel. """ nukescripts.PythonPanel.__init__(self, "Shuffle EXR Passes", "com.parimalvfx.ShufflePassesPanel") self.node = nuke.selectedNode() self.nodeLayers = find_node_layers(self.node) self.layerKnobs = [] for layer in self.nodeLayers: self.layer = nuke.Boolean_Knob(layer, layer, True) self.layer.setFlag(nuke.STARTLINE) self.addKnob(self.layer) self.layerKnobs.append(self.layer) if layer == "rgba": self.layer.setValue(False) self.div1 = nuke.Text_Knob("div1", " ", "") self.all = nuke.PyScript_Knob("select_all", " Select All ") self.invert = nuke.PyScript_Knob("invert_selection", " Invert Selection ") self.clear = nuke.PyScript_Knob("clear_selection", " Clear Selection ") self.div2 = nuke.Text_Knob("div2", " ", "") height = 125 + len(self.layerKnobs) * 20 width = 330 if height > 700: width = 350 height = 700 self.setMinimumSize(width, height) self.setMaximumSize(500, 900) for each in (self.div1, self.all, self.invert, self.clear, self.div2): self.addKnob(each)
def setDotNode(d, node_sel_cam): d['label'].setValue("\n%s" % (node_sel_cam)) d['note_font'].setValue('bold') d['note_font_size'].setValue(24) d['note_font_color'].setValue(color_white) d['tile_color'].setValue(color_red) d['hide_input'].setValue(True) d.setInput(0, nuke.toNode(node_sel_cam)) # Add Show Panel Knob cmd_ppanel = "n=nuke.thisNode()\ntry:\n\tn.input(0).showControlPanel(forceFloat=n.knob('isFloat').value())\nexcept:\n\tpass" cmd_orig = "origNode = nuke.thisNode().input(0);\ origXpos = origNode.xpos();\ origYpos = origNode.ypos();\ nuke.zoom(2, [origXpos,origYpos]);\ nuke.thisNode()['selected'].setValue(False);\ origNode['selected'].setValue(True);\ nuke.show(origNode)" t_tab = nuke.Tab_Knob('t_user', "DotCamConnect") k_showPanel = nuke.PyScript_Knob('ppanel', "Show Input Property Panel", cmd_ppanel) k_float = nuke.Boolean_Knob('isFloat', "Floating Panel", True) k_showCam = nuke.PyScript_Knob('orig', "Show Camera Node", cmd_orig) k_float.clearFlag(nuke.STARTLINE) k_float.setFlag(nuke.STARTLINE) d.addKnob(t_tab) d.addKnob(k_showPanel) d.addKnob(k_float) d.addKnob(k_showCam) print "%s -> %s" % (d.name(), node_sel_cam)
def shuffleRed(): import nuke import nukescripts try: a = nuke.selectedNode() name = a['name'].value() if a.Class() == "Shuffle": name = a['name'].value() r = a['red'].value() g = a['green'].value() b = a['blue'].value() aa = a['alpha'].value() lab = a['label'].value() if a['in'].value( ) == "rgba" and r == "red" and g == "green" and b == "blue" and aa == "alpha": a['red'].setValue(1) a['green'].setValue(1) a['blue'].setValue(1) a['alpha'].setValue(1) a['label'].setValue("") a['tile_color'].setValue(2466250752L) else: nukescripts.create_read() elif "ID" in name: x = a['xpos'].value() y = a['ypos'].value() print "hallo" channel = a['Red'].value() s = nuke.nodes.Shuffle(name=channel) s.setXYpos(int(x), int(y + 100)) s.setInput(0, a) ################## matte = 1 s['tile_color'].setValue(2466250752L) s['red'].setValue(matte) s['green'].setValue(matte) s['blue'].setValue(matte) s['alpha'].setValue(matte) s['hide_input'].setValue(1) s['note_font_size'].setValue(12) s['help'].setValue(name) code = "a = nuke.thisNode()\na['hide_input'].setValue(0)\ndep = a.dependencies(nuke.INPUTS)[0]\na['hide_input'].setValue(1)\nnuke.show(dep)\n" m = nuke.PyScript_Knob("showsourse", "show source", code) s.addKnob(m) code = "a = nuke.thisNode()\na['hide_input'].setValue(0)\ndep = a.dependencies(nuke.INPUTS)[0]\na['hide_input'].setValue(1)\nnuke.show(dep)\nxC = dep.xpos() + dep.screenWidth()/2\nyC = dep.ypos() + dep.screenHeight()/2\nnuke.zoom( 3, [ xC, yC ])\n" m = nuke.PyScript_Knob("jumptosource", "jump to source", code) s.addKnob(m) code = "a = nuke.selectedNode()\nname=a['help'].value()\nname = nuke.toNode(name)\na.setInput(0, name)" m = nuke.PyScript_Knob("reconnect", "reconnect", code) s.addKnob(m) t = nuke.Text_Knob("chan", str(a['Achannels'].value()) + " red channel") s.addKnob(t) else: nukescripts.create_read() except: nukescripts.create_read()
def __init__(self, data): nukescripts.PythonPanel.__init__(self, 'Submit Shot') self.gladiator = data.gladiator self.dialogueText = data.dialogueText self.validated = data.validated self.user = c1_user # filename fragments self.filepath = data.filepath self.filename = data.filename self.showCode = data.showCode self.shotName = data.shotName self.fileversion = data.fileversion # folders self.versionFolder = data.versionFolder self.shotFolder = data.shotFolder self.showFolder = data.showFolder # knobs self.emailBool = nuke.Boolean_Knob('emailBool', 'Send Email to VFX') # self.addKnob(self.emailBool) self.emailBool.setValue(False) self.emailMsg = nuke.Multiline_Eval_String_Knob( 'Type your shot notes here(if enabled).', '') # self.addKnob(self.emailMsg) self.emailMsg.setEnabled(False) self.sep = nuke.Text_Knob('', '') # self.addKnob(self.sep) self.cancelButton = nuke.PyScript_Knob("Cancel") self.addKnob(self.dialogueText) self.button1 = nuke.PyScript_Knob( "submit", self.shotName + '_v' + str(self.versionFolder.ver.remote + 1).zfill(3)) self.button2 = nuke.PyScript_Knob( "submit", self.shotName + '_v' + str(self.fileversion).zfill(3))
def __init__(self): nukescripts.PythonPanel.__init__(self, 'Snapshotr', 'uk.co.thefoundry.ssPanel') if self.DEV > 0: print "\n* Debug mode ON" print "* rootDir inside ssPanel __init__ = " + self.rootDir print "* snapsDir inside ssPanel __init__ = " + self.snapsDir self.btn_snap_fullres = nuke.PyScript_Knob('Full') self.btn_snap_instant = nuke.PyScript_Knob('Instant') self.btn_open_webview = nuke.PyScript_Knob('Open') self.commentField = nuke.String_Knob('Comment:') self.divider = nuke.Text_Knob('') self.markNode = nuke.Boolean_Knob('Mark node ') self.timerValue = nuke.Int_Knob('Autosnap: ') self.addKnob(self.commentField) self.addKnob(self.btn_snap_instant) self.addKnob(self.btn_snap_fullres) self.addKnob(self.btn_open_webview) self.addKnob(self.timerValue) self.addKnob(self.divider) self.addKnob(self.markNode) self.timerValue.setValue(60) # 60 minutes by default scriptPath = nuke.toNode('root').knob('name').value() scriptName = scriptPath.split("/")[-1] if cmn.check_script(name=scriptName) is None: nuke.message( "Please save your script in the following format:\nshot.task.artist.v00.00.nk" ) raise BaseException def snapAutosave(): """ Create auto snapshot, start timer to trigger this (every 60min by default) """ try: c_var = cmn.init_common_vars(snapsDir=self.snapsDir) print "\n~ autosaving snapshot..." cmn.create_snapshot_dirs(rootDir=self.rootDir, snapsDir=self.snapsDir, snapPath=c_var["snapPath"], markNode=self.markNode) cmn.create_snapshot_script( scriptPath=c_var["scriptPath"], snapScriptName=c_var["snapScriptName"], upversion=False) cmn.create_snapshot_comment( snapCommentFile=c_var["snapCommentFile"], commentText="#autosnap") cmn.create_snapshot_screenshot( DEV=self.DEV, snapImageFile=c_var["snapImageFile"]) finally: timer = int(self.timerValue.value()) * 60000 QtCore.QTimer.singleShot(timer, snapAutosave) snapAutosave()
def __init__(self): super(WatermarkControlPanel, self).__init__('Watermark Control') self.setMinimumSize(600, 260) self.sourceKnob = nuke.File_Knob('file', 'Open:') self.formatKnob = nuke.Format_Knob('format', 'Format:') self.outputKnob = nuke.File_Knob('file', 'Save:') self.addKnob(self.sourceKnob) self.addKnob(self.formatKnob) self.addKnob(self.outputKnob) self.formatKnob.setValue('HD_720') self.addSourceKnob = nuke.PyScript_Knob('add', 'Add') self.addKnob(self.addSourceKnob) self.watermarkType = nuke.Enumeration_Knob('type', 'Type:', ['Text', 'Image']) self.watermarkText = nuke.String_Knob('text', 'Text:') self.watermarkImage = nuke.File_Knob('image', 'Image:') self.watermarkNum = nuke.Enumeration_Knob( 'num', 'Number:', ['1 ', '2 ', '3 ', '4 ', '6 ', '9 ']) self.watermarkCreate = nuke.PyScript_Knob('create', 'Create') self.watermarkRotate = nuke.Double_Knob('rotate', 'Rotate:') self.watermarkScale = nuke.Double_Knob('scale', 'Scale:') self.watermarkOpacity = nuke.Double_Knob('opacity', 'Opacity:') self.watermarkRotate.setRange(-180, 180) self.watermarkOpacity.setDefaultValue([1, 1]) self.watermarkScale.setRange(0.3, 1.5) self.watermarkScale.setDefaultValue([1, 1]) self.addKnob(self.watermarkType) self.addKnob(self.watermarkText) self.addKnob(self.watermarkImage) self.addKnob(self.watermarkNum) self.addKnob(self.watermarkCreate) self.addKnob(self.watermarkRotate) self.addKnob(self.watermarkScale) self.addKnob(self.watermarkOpacity) self.controller = WatermarkController(self)
def createVersionKnobs(): ''' Add as callback to add user knobs in Read nodes. In menu.py or init.py: nuke.addOnUserCreate( assetManager.createVersionKnobs, nodeClass='Read' ) ''' # CREATE USER KNOBS node = nuke.thisNode() tabKnob = nuke.Tab_Knob('DB', 'DB') typeKnob = nuke.Enumeration_Knob('versionType', 'type', ['plates', 'cg', 'roto']) updateKnob = nuke.PyScript_Knob('update', 'update') updateKnob.setValue('assetManager.updateVersionKnob()') versionKnob = nuke.Enumeration_Knob( '_version', 'version', [] ) # DO NOT USE "VERSION" AS THE KNOB NAME AS THE READ NODE ALREADY HAS A "VERSION" KNOB loadKnob = nuke.PyScript_Knob('load', 'load') # ASSIGN PYTHON SCRIPT AS ONE LARGE STRING loadScript = '''#THIS ASSUMES NO WHITE SPACES IN FILE PATH node = nuke.thisNode() path, range = node['_version'].value().split() first, last = range.split('-') node['file'].setValue( path ) node['first'].setValue( int(first) ) node['last'].setValue( int(last) )''' loadKnob.setValue(loadScript) # ADD NEW KNOBS TO NODE for k in (tabKnob, typeKnob, updateKnob, versionKnob, loadKnob): node.addKnob(k) # UPDATE THE VERSION KNOB SO IT SHOWS WHAT'S ON DISK / IN THE DATABASE updateVersionKnob()
def __init__(self): nukescripts.PythonPanel.__init__(self, 'Create ToolSet', 'uk.co.thefoundry.CreateToolset') # CREATE KNOBS # Loop through and find all user folders self.userFolders = [] for d in nuke.pluginPath(): if os.path.isdir(d): if ".nuke" in d: dircontents = os.listdir(d) if "ToolSets" in dircontents: fullPath = os.path.join(d, "ToolSets") self.buildFolderList(fullPath, '') self.menuItemChoice = nuke.CascadingEnumeration_Knob( 'menuItemChoice', 'ToolSets menu', ['root'] + self.userFolders) self.menuItemChoice.setTooltip( "The menu location that the ToolSet will appear in. Specify 'root' to place the ToolSet in the main ToolSets menu." ) self.menuPath = nuke.String_Knob('itemName', 'Menu item:') self.menuPath.setFlag(0x00001000) self.menuPath.setTooltip( "ToolSet name. Use the '/' character to create a new submenu for this ToolSet, eg to create a ToolSet named 'Basic3D' and place it in a new submenu '3D', type '3D/Basic3D'. Once created the 3D menu will appear in the ToolSet menu." ) self.okButton = nuke.PyScript_Knob('create', 'Create') #self.okButton.setToolTip("Create a ToolSet from the currently selected nodes with the given name") self.okButton.setFlag(0x00001000) self.cancelButton = nuke.PyScript_Knob('cancel', 'Cancel') # ADD KNOBS self.addKnob(self.menuItemChoice) self.addKnob(self.menuPath) self.addKnob(self.okButton) self.addKnob(self.cancelButton)
def plusWrite(): This = nuke.thisNode() tab = nuke.Tab_Knob('plus', 'plus') line1 = nuke.Text_Knob("PlusControl", "Plus Control") OPNbutton = nuke.PyScript_Knob("OPN", "Open Directory") OPNbutton.setFlag(nuke.STARTLINE) rfwbutton = nuke.PyScript_Knob("rfw", "Read from write") rfwbutton.setFlag(nuke.STARTLINE) linkCheck = nuke.Boolean_Knob("lnk", "Link") linkCheck.clearFlag(nuke.STARTLINE) This.addKnob(tab) This.addKnob(line1) This.addKnob(OPNbutton) This.addKnob(rfwbutton) This.addKnob(linkCheck) This['OPN'].setCommand('plusOpen()') def lnkv(): if This['lnk'].value() == False: This['rfw'].setCommand('PlusRFW()') else: This['rfw'].setCommand('PlusRFWLink()') nuke.addKnobChanged(lnkv, nodeClass="Write")
def __init__(self): super(DailiesSettingPanel, self).__init__('Dailies Setting') self.file_knob = nuke.File_Knob('source', 'image') self.source_list = nuke.Multiline_Eval_String_Knob( 'source_list', 'sources') self.source_list.setEnabled(False) self.remove_first = nuke.Int_Knob('remove_first', 'remove first line:') self.remove_last = nuke.Int_Knob('remove_last', 'remove last line:') self.remove_first.setValue(1) self.remove_last.setValue(1) self.remove_last.clearFlag(nuke.STARTLINE) self.remove_button = nuke.PyScript_Knob('remove', 'remove') self.message = nuke.Text_Knob('message', '', ' ') self.create_button = nuke.PyScript_Knob('create', 'create node tree') self.render_button = nuke.PyScript_Knob('render', 'render dailies') self.create_button.setFlag(nuke.STARTLINE) self.addKnob(self.file_knob) self.addKnob(self.source_list) self.addKnob(self.remove_first) self.addKnob(self.remove_last) self.addKnob(self.remove_button) self.addKnob(self.create_button) self.addKnob(self.render_button) self.addKnob(self.message) self.sources = {} self.render_infos = {} self.control_funcs = {} self.bypass_callback = False
def addCTGradeControl(): node = nuke.thisNode() tab = nuke.Tab_Knob('GradeControl') node.addKnob(tab) ref = nuke.Int_Knob('reference_frame', 'Reference Fame') frame = nuke.PyScript_Knob( 'set_frame', 'Set Current Frame', 'nuke.thisNode()["reference_frame"].setValue(nuke.frame())') node['label'].setValue('Ref [value reference_frame]') grade = nuke.PyScript_Knob( 'create_grade', 'Create Grade Node', ''' node = nuke.thisNode() node_name = nuke.thisNode()['name'].value() grade = nuke.createNode('Grade') grade['whitepoint'].setSingleValue(False) grade['white'].setSingleValue(False) grade['whitepoint'].setExpression('{0}.intensitydata.r({0}.reference_frame)'.format(node_name), channel=0) grade['whitepoint'].setExpression('{0}.intensitydata.g({0}.reference_frame)'.format(node_name), channel=1) grade['whitepoint'].setExpression('{0}.intensitydata.b({0}.reference_frame)'.format(node_name), channel=2) grade['whitepoint'].setExpression('{0}.intensitydata.a({0}.reference_frame)'.format(node_name), channel=3) grade['white'].setExpression('{0}.intensitydata.r'.format(node_name), channel=0) grade['white'].setExpression('{0}.intensitydata.g'.format(node_name), channel=1) grade['white'].setExpression('{0}.intensitydata.b'.format(node_name), channel=2) grade['white'].setExpression('{0}.intensitydata.a'.format(node_name), channel=3) ''') grade.setFlag(0x1000) node.addKnob(ref) node.addKnob(frame) node.addKnob(grade) node['reference_frame'].setValue(nuke.frame())
def __init__(self, node): nukescripts.PythonPanel.__init__(self, 'Lock Knobs') #CREATE KNOBS self.AllKnobs = nuke.PyScript_Knob('AllKnobs', 'All Knobs') self.Clear = nuke.PyScript_Knob('Clear', 'Clear') self.Knobslist = nuke.Multiline_Eval_String_Knob('Knobs', 'Knobs') self.Operation = nuke.Enumeration_Knob('Operation', 'Operation', ['Hide', 'Show', 'Lock', 'Unlock']) #ADD KNOBS for k in ( self.AllKnobs, self.Clear, self.Knobslist, self.Operation): self.addKnob(k)
def master_disable(): """ Link disable knob of all selected nodes to a newly created NoOp node's disable knob. With further options in NoOp node for disable control. :return: None :rtype: None """ selected = nuke.selectedNodes() if len(selected) > 0: master = nuke.nodes.NoOp() master_name = master["name"].value() before = """selected = nuke.selectedNode() if selected.Class() == "Write": code = "nuke.toNode('%s')['disable'].setValue(False)" selected["beforeRender"].setValue(code) else: nuke.message("Please select a Write node.") """ % master_name after = """selected = nuke.selectedNode() if selected.Class() == "Write": code = "nuke.toNode('%s')['disable'].setValue(True)" selected["afterRender"].setValue(code) else: nuke.message("Please select a Write node.") """ % master_name tab = nuke.Tab_Knob("MasterDisable") disable = nuke.Boolean_Knob("disable", "disable", True) disable.setTooltip("Control disable of all connected nodes.") divider = nuke.Text_Knob("div", " ", "") set_before = nuke.PyScript_Knob("set_before", "Set Write Before Render", before) set_before.setTooltip( "Set 'Before Render' of selected Write node to enable this Master Disable before render." ) set_after = nuke.PyScript_Knob("set_after", "Set Write After Render", after) set_after.setTooltip( "Set 'After Render' of selected Write node to disable this Master Disable after render." ) for each in (tab, disable, divider, set_before, set_after): master.addKnob(each) master["hide_input"].setValue(True) master["label"].setValue("Master Disable - [value disable]") expression = "parent.%s.disable" % master_name for node in selected: node["disable"].setExpression(expression) master.showControlPanel() else: nuke.message("No nodes selected")
def __init__(self, fullFilePath, rename): self.rename = rename self.fullFilePath = fullFilePath if rename == False: self.namePanel = 'Create ToolSet' self.nameOkButton = 'Create' else: self.namePanel = 'Rename ToolSet' self.nameOkButton = 'Rename' nukescripts.PythonPanel.__init__(self, self.namePanel, 'uk.co.thefoundry.Toolset') # CREATE KNOBS self.userFolders = [] fullPath = SHARED_TOOLSET_PATH self.buildFolderList(fullPath, '') self.menuItemChoice = nuke.CascadingEnumeration_Knob( 'menuItemChoice', 'SharedToolSets menu', ['root'] + self.userFolders) self.menuItemChoice.setTooltip( "The menu location that the ToolSet will appear in. Specify 'root' to place the SharedToolSets in the main SharedToolSets menu." ) self.menuPath = nuke.String_Knob('itemName', 'Menu item:') self.menuPath.setFlag(0x00001000) self.menuPath.setTooltip( "ToolSet name. Use the '/' character to create a new submenu for this ToolSet, eg to create a ToolSet named 'Basic3D' and place it in a new submenu '3D', type '3D/Basic3D'. Once created the 3D menu will appear in the ToolSet menu." ) self.okButton = nuke.PyScript_Knob(self.nameOkButton.lower(), self.nameOkButton) #self.okButton.setToolTip("Create a ToolSet from the currently selected nodes with the given name") self.okButton.setFlag(0x00001000) self.cancelButton = nuke.PyScript_Knob('cancel', 'Cancel') self.space = nuke.Text_Knob("space", "", "") self.infoText = nuke.Text_Knob( 'infoText', '<span style="color:orange">/ - create submenus,</span>', '<span style="color:orange">example: newMenu/myNewToolSet</span>') # ADD KNOBS self.addKnob(self.menuItemChoice) self.addKnob(self.menuPath) self.addKnob(self.okButton) self.addKnob(self.cancelButton) self.addKnob(self.space) self.addKnob(self.infoText) if rename == True: toolSetPath = fullFilePath.replace(SHARED_TOOLSET_PATH + "/", '') toolSetPath = toolSetPath.replace(".nk", '') self.menuPath.setValue(toolSetPath)
def addCustomKnobs(): node = nuke.thisNode() tab_test = nuke.Tab_Knob("test", "test") btn_createTestFolder = nuke.PyScript_Knob('create test folder', 'create test folder', '') btn_openInFinder = nuke.PyScript_Knob('open in explorer', 'open in explorer', '') btn_versionUp = nuke.PyScript_Knob('version up', 'version up', '') node.addKnob(tab_test) node.addKnob(btn_createTestFolder) node.addKnob(btn_openInFinder) node.addKnob(btn_versionUp)
def create_jupyter_node(exec_cmd=''): noop = nuke.nodes.NoOp(name='Jupyter_Node') pybtn = nuke.PyScript_Knob('py_btn', 'Execute Code') pybtn.setFlag(nuke.STARTLINE) pytreebtn = nuke.PyScript_Knob('py_tree_btn', 'Execute Tree', exec_cmd) pyknob = nuke.PyCustom_Knob('py_edit', '', 'PyKnobEdit(node=nuke.thisNode())') for knob in pyknob, pybtn, pytreebtn: noop.addKnob(knob) userknob = noop.knob('User') userknob.setLabel('Python')
def shuffleGreen(): try: a = nuke.selectedNode() name = a['name'].value() if a.Class() == "Shuffle": name = a['name'].value() #a['tile_color'].setValue(1063467008L) r = a['red'].value() g = a['green'].value() b = a['blue'].value() aa = a['alpha'].value() if a['in'].value() == "rgba" and r == "red" and g == "green" and b == "blue" and aa == "alpha": a['red'].setValue(2) a['green'].setValue(2) a['blue'].setValue(2) a['alpha'].setValue(2) a['label'].setValue("(Green)") else: nuke.createNode("Grade") elif "ID" in name: x =a['xpos'].value() y = a['ypos'].value() print "hallo" channel = a['Green'].value() s = nuke.nodes.Shuffle() s.setXYpos(int(x),int(y+100)) s.setInput(0,a) matte = 2 s['tile_color'].setValue(1063467008L) s['red'].setValue(matte) s['green'].setValue(matte) s['blue'].setValue(matte) s['alpha'].setValue(matte) s['hide_input'].setValue(1) s['note_font_size'].setValue(20) s['autolabel'].setValue("nuke.thisNode()['label'].value()") s['label'].setValue(channel) s['help'].setValue(name) code = "a = nuke.thisNode()\na['hide_input'].setValue(0)\ndep = a.dependencies(nuke.INPUTS)[0]\na['hide_input'].setValue(1)\nnuke.show(dep)\n" m = nuke.PyScript_Knob("showsourse","show source",code) s.addKnob(m) code = "a = nuke.thisNode()\na['hide_input'].setValue(0)\ndep = a.dependencies(nuke.INPUTS)[0]\na['hide_input'].setValue(1)\nnuke.show(dep)\nxC = dep.xpos() + dep.screenWidth()/2\nyC = dep.ypos() + dep.screenHeight()/2\nnuke.zoom( 3, [ xC, yC ])\n" m = nuke.PyScript_Knob("jumptosource","jump to source",code) s.addKnob(m) code = "a = nuke.selectedNode()\nname=a['help'].value()\nname = nuke.toNode(name)\na.setInput(0, name)" m = nuke.PyScript_Knob("reconnect","reconnect",code) s.addKnob(m) else: nuke.createNode("Grade") except: nuke.createNode("Grade")
def __init__(self): PythonPanel.__init__(self, 'C1 Preferences') # C1 Preferences self.email = None self.localDir = None self.projectDir = None # custom regex definitions for validation engine self.regex = {} self.projectStructure = {'root': {}} self.scriptDir = { 'root': os.path.join(os.path.join(os.path.realpath(__file__), os.pardir), os.pardir), 'c1_tools': os.path.join(os.path.realpath(__file__), os.pardir) } # define knobs self.inp_email = nuke.String_Knob('email', 'C1 Initials: ') self.inp_localDir = nuke.String_Knob('localDir', 'Local Working Directory: ') self.btn_localDir = nuke.PyScript_Knob("Set Working Dir") self.loginButton = nuke.PyScript_Knob("Login") self.cancelButton = nuke.PyScript_Knob("Cancel") # Project Map Tab self.projectMapTab = nuke.Tab_Knob("Project Map") self.setProjectButton = nuke.File_Knob('projectDir', 'Project Location') self.inp_projectLocation = nuke.String_Knob( 'projectDir', '<b><font size="3" color="red">Remote Project Directory</font></b>' ) self.inp_projectName = nuke.String_Knob('projectName', 'Project Name') self.inp_projectNum = nuke.Int_Knob('projectNum') # self.inp_projectNum.clearFlag( nuke.STARTLINE ) self.inp_projectCode = nuke.String_Knob('projectCode', 'Project Code') self.inp_projectCode.clearFlag(nuke.STARTLINE) # add knobs self.addKnob(self.inp_localDir) self.addKnob(self.btn_localDir) self.addKnob(self.inp_email) self.addKnob(self.loginButton) self.addKnob(self.cancelButton) # Project Map Tab self.addKnob(self.projectMapTab) self.addKnob(self.setProjectButton) self.addKnob(self.inp_projectName) self.addKnob(self.inp_projectNum) self.addKnob(self.inp_projectCode) # retrieve previous login from login.txt self.retrieveLogin() return
def __init__(self, historyFile='~/.nuke/srhistory.xml', maxSteps=10): ''' Search and Replace panel args: historyFile - file to manage recent search&replace actions maxSteps - amount of steps to keep in history file ''' nukescripts.PythonPanel.__init__(self, 'Search and Replace', 'com.ohufx.SearchReplace') # VARS self.historyFile = os.path.expandvars(os.path.expanduser(historyFile)) self.maxSteps = maxSteps self.delimiter = ' |>>| ' # CREATE KNOBS self.nodesChoice = nuke.Enumeration_Knob('nodes', 'Source Nodes', ['all', 'selected']) self.nodesChoice.setTooltip( 'Chose to perform action on all nodes with file knobs or only selected ones' ) self.history = nuke.Enumeration_Knob('history', 'Recent Searches', self.loadHistory()) self.history.setTooltip( 'Use the history to quicky access previous search&replace actions.\n By default the history file is stored as "~/.nuke/srhistory.xml" but this can be changed via the "historyFile" argument when creating the panel object. It is also possible to change the size of the history via the "maxSteps" argument to the panel object. Default is 10' ) self.case = nuke.Boolean_Knob('case', 'case sensitive') self.case.setFlag(nuke.STARTLINE) self.case.setValue(True) self.case.setTooltip( 'Set whether or not the search should be case sensitive') self.searchStr = nuke.String_Knob('searchStr', 'Search for:') self.searchStr.setTooltip('The text to search for') self.update = nuke.PyScript_Knob('update', 'Update') self.update.setTooltip( 'update the search result and preview. This is automaticaly performed and usually should only be required when the node selection has canged' ) self.replaceStr = nuke.String_Knob('replaceStr', 'Replace with:') self.replaceStr.setTooltip('Text to replace the found text with') self.replace = nuke.PyScript_Knob('replace', 'Replace') self.replace.setTooltip( 'Perform replace action. The preview will update afterwards and the action is added to the history' ) self.info = nuke.Multiline_Eval_String_Knob('info', 'Found') self.info.setEnabled(False) self.info.setTooltip( 'See the search results and a preview of the replace action before it is performed' ) # ADD KNOBS for k in (self.nodesChoice, self.history, self.case, self.searchStr, self.update, self.replaceStr, self.replace, self.info): self.addKnob(k) self.matches = None
def cmd_add(n): ''' command to call when Add button is pressed 1. find new version 2. save nuke preset 2. ask for descrition 3. create NodeVersion knobs 4. Change Cur Version knob ''' # n = nuke.thisNode() new_ver = findNV(n)['new'] # Preseting preset_name = "%s.%s.v%s" % (n.Class(), n.name(), new_ver) nuke.saveUserPreset(n, preset_name) print preset_name # Short description tip = nuke.getInput('Give a Short Version Description', '%s' % preset_name) # Knobs k_rm = nuke.PyScript_Knob( 'nv_rm_v%s' % new_ver, '<b>−', "import nuke;import dft_NodeVersion as nv;nv.cmd_remove(nuke.thisNode(), nuke.thisKnob())" ) k_load = nuke.PyScript_Knob( 'nv_load_v%s' % new_ver, '<b>load v%s' % new_ver, "import nuke;import dft_NodeVersion as nv;nv.cmd_load(nuke.thisNode(), nuke.thisKnob())" ) k_tip = nuke.Text_Knob('nv_tip_v%s' % new_ver, ': %s' % tip, "\s") #FLAG k_load.clearFlag(nuke.STARTLINE) k_tip.clearFlag(nuke.STARTLINE) # Add knobs n.addKnob(k_rm) n.addKnob(k_load) n.addKnob(k_tip) # Change current version try: n.knob('tx_preset').setValue('<b>%s.v%s' % (n.name(), new_ver.zfill(2))) except: pass #Console print "%s added NodeVersion: v%s" % (n.name(), str(new_ver).zfill(2))
def initialiseNode(node, max_num=4): node.knob(node.name()).setLabel('Appearance') knob_names = [x for x in list(node.knobs().keys()) if x.startswith('pt')] knob_names.sort(key=lambda x: int(x[2:])) # Add new Tab for points start_knob = node.knobs()['Start'] node.removeKnob(start_knob) node.addKnob(nuke.Tab_Knob('Points')) text = "Insert adds a point between its adjacent and previous point\nDelete removes the adjacent point\nAdd adds a point at the end" node.addKnob(nuke.Text_Knob('info', '', text)) node.addKnob(nuke.Text_Knob('', '')) node.addKnob(start_knob) # Remove and store all pt knobs knobs = [] for name in knob_names: knob = node.knobs()[name] knobs.append(knob) node.removeKnob(knob) # Add each back along with their delete and insert buttons for knob in knobs: num = knob.name()[2:] delete = nuke.PyScript_Knob('delete' + num, 'Delete', "Lines_Callbacks.delete_pt()") insert = nuke.PyScript_Knob('insert' + num, 'Insert', "Lines_Callbacks.insert_pt()") # Hide knobs greater than the max value if int(num) >= max_num: knob.setVisible(False) delete.setVisible(False) insert.setVisible(False) node.addKnob(knob) node.addKnob(delete) node.addKnob(insert) # Add the Add knob add_knob = nuke.PyScript_Knob('add_pt', 'Add', "Lines_Callbacks.add_pt()") add_knob.setFlag(nuke.STARTLINE) node.addKnob(add_knob) node.knob('Max PTS').setValue(max_num) node.knobs()['Max PTS'].setVisible(False) node.knobs()['Max Limit'].setVisible(False)
def __init__(self): nukescripts.PythonPanel.__init__(self, "Add ToolSet") self.choosePathKnob = nuke.Enumeration_Knob("addTo", "Add To", [""]) self.choosePathKnob.setValues([""]) self.nameKnob = nuke.String_Knob("Name") self.axisKnob = nuke.Axis_Knob("") self.okButton = nuke.PyScript_Knob("Ok") self.cancelButton = nuke.PyScript_Knob("Cancel") for knob in [ self.choosePathKnob, self.nameKnob, self.axisKnob, self.okButton, self.cancelButton ]: self.addKnob(knob)
def plusCamera(): This = nuke.thisNode() tab = nuke.Tab_Knob('plus', 'plus') check = This.knob('plus') if check is not None: pass else: button = nuke.PyScript_Knob("BKUP", "Bake") button2 = nuke.PyScript_Knob("stereoRig", "Stereo Rig") button2.setFlag(nuke.STARTLINE) for k in (tab, button, button2): This.addKnob(k) This['BKUP'].setCommand('BakeUnderParent()') This['stereoRig'].setCommand('stereoRig()')
def __init__(self): ### Init the panel with a name nukescripts.PythonPanel.__init__(self, "hQueue Nuke render submission panel") ### Gets the absolute file path for the currently open Nuke script, if nothing open then defaults to install directory self.absoluteFilePath = os.path.abspath(nuke.value("root.name")) ### Setup a text box for the server address to be input into self.serverAddress = nuke.String_Knob('serverAddress', 'Server Address: ') self.addKnob(self.serverAddress) ### Setup a button to test the server address which will reveal the Connection Successful text self.addressTest = nuke.PyScript_Knob("addressTest", "Test the server address", "") self.addKnob(self.addressTest) ### Create addressSuccessFlag flag that is hidden until the server is successfully pinged self.addressSuccessFlag = nuke.Text_Knob('addressSuccessFlag', '', '<span style="color:green">Connection Successful</span>') self.addressSuccessFlag.setFlag(nuke.STARTLINE) self.addressSuccessFlag.setVisible(False) self.addKnob(self.addressSuccessFlag) ### Get the filepath from self.absoluteFilePath and put it into a text box self.filePath = nuke.String_Knob('filePath', 'File Path: ', self.absoluteFilePath) self.addKnob(self.filePath) ### Create a button that will test the file path for an nuke script self.filePathCheck = nuke.PyScript_Knob("filePathCheck", "Test the File Path", "") self.addKnob(self.filePathCheck) ### Create pathSuccessFlag flag that is hidden until the file path is verified self.pathSuccessFlag = nuke.Text_Knob('pathSuccessFlag', '', '<span style="color:green">Connection Successful</span>') self.pathSuccessFlag.setFlag(nuke.STARTLINE) self.pathSuccessFlag.setVisible(False) self.addKnob(self.pathSuccessFlag) ### Setup the get client list button, which will use hqrop functions self.clientGet = nuke.PyScript_Knob("clientGet", "Get client list", "") self.addKnob(self.clientGet) ### Setup the get client groups button, which will use hqrop functions self.clientGroupGet = nuke.PyScript_Knob("clientGroupGet", "Get client groups", "") self.addKnob(self.clientGroupGet) ### Setup a save client selection button, this hides the client list and itself self.clientSelect = nuke.PyScript_Knob("clientSelect", "Save client selection", "") self.clientSelect.setVisible(False) self.addKnob(self.clientSelect) ### Setup a multiline client list that appears when clientGet is run self.clientList = nuke.Multiline_Eval_String_Knob('clientList', 'Client List: ') self.clientList.setFlag(nuke.STARTLINE) self.clientList.setVisible(False) self.addKnob(self.clientList) ### Setup a frame range with the default frame range of the scene self.fRange = nuke.String_Knob('fRange', 'Track Range', '%s-%s' % (nuke.root().firstFrame(), nuke.root().lastFrame())) self.addKnob(self.fRange) ### Set the minimum size of the python panel self.setMinimumSize(500, 600)
def _addPreKnobs(self): self._flipbookEnum = nuke.Enumeration_Knob( "flipbook", "Flipbook", flipbooking.gFlipbookFactory.getNames()) self._state.setKnob(self._flipbookEnum, "FrameCycler") self.addKnob(self._flipbookEnum) self._viewerForSettings = nuke.Enumeration_Knob( "viewer_settings", "Take settings from", ["-"] + self._viewers.keys()) if not self._takeNodeSettings: self._viewerForSettings.setValue("-") self.addKnob(self._viewerForSettings) self._defaultValues = nuke.PyScript_Knob("default", "Defaults") self.addKnob(self._defaultValues) # Region of Interest knobs self._useRoi = nuke.Boolean_Knob("use_roi", "Enable ROI") self._useRoi.setFlag(nuke.STARTLINE) self._state.setKnob(self._useRoi, False) self.addKnob(self._useRoi) self._roi = nuke.BBox_Knob("roi", "Region of Interest") self._state.setKnob(self._roi, (0, 0, 0, 0)) self.addKnob(self._roi) self._roi.setVisible(self._useRoi.value()) # Channel knobs self._channels = nuke.Channel_Knob("channels_knob", "Channels") if self._node.Class() == "Write": self._channels.setValue(self._node.knob("channels").value()) else: self._state.setKnob(self._channels, "rgba") self._channels.setFlag(nuke.STARTLINE | nuke.NO_CHECKMARKS) self.addKnob(self._channels)