def bookmarkthis(desc=True, ask=True): '''Bookmarks a node for quick navigation''' try: sn = nuke.selectedNodes()[-1] except: nuke.message('Please select a node') sn = None if sn is not None: if sn['icon'].value() != 'bookmark.png' and desc == True: l = sn['label'].value() panel = nuke.Panel('Bookmark This', 300) panel.addSingleLineInput('add description', l) result = panel.show() d = panel.value('add description') if result: sn['icon'].setValue('bookmark.png') sn['label'].setValue(d) else: if ask: clear = nuke.ask('Clear Bookmark and Label?') if clear: sn['icon'].setValue('') sn['label'].setValue('') else: if desc: sn['icon'].setValue('') sn['label'].setValue('') else: sn['icon'].setValue('')
def bntSavePressed(self, a): panel = nuke.Panel("Name me!!!") panel.addSingleLineInput("Name:", "") if panel.show(): a = panel.value("Name:") nuke.nodeCopy(pathToTemplates + a) self.close()
def checkEfficiency(startNode=None): """ CheckEfficiency UI Arg: startNode : analyze all nuke nodes connected to this nodes """ try: if not startNode: startNode = nuke.selectedNode() except ValueError: msg = "No start node selected" nuke.message(msg) return formatWeight = nuke.Root().format().width() * nuke.Root().format().height() analyzeBBox = True bboxThreshold = 300 analyzeLayers = True layerThreshold = 6 panel = nuke.Panel('Efficiency Checker') panel.addBooleanCheckBox('Analyze Bounding Box', analyzeBBox) panel.addBooleanCheckBox('Analyze Layers', analyzeLayers) panel.addSingleLineInput('Bounding Box Threshold', bboxThreshold) panel.addSingleLineInput('Layer Threshold', layerThreshold) panel.addButton('Cancel') panel.addButton('Analyze') panel.addButton('Revert Node Colors') panel.addButton('Help') result = panel.show() nodes = nuke.selectConnectedNodes() nodes = nuke.selectedNodes() [node['selected'].setValue(False) for node in nodes] startNode['selected'].setValue(True) # Analyze if result == 1: analyzeBBox = panel.value('Analyze Bounding Box') bboxThreshold = float(panel.value('Bounding Box Threshold')) / 100 analyzeLayers = panel.value('Analyze Layers') layerThreshold = int(panel.value('Layer Threshold')) nodeInfos = _analyzeNodes(nodes, analyzeBBox, analyzeLayers) _setColors(nodeInfos, formatWeight, analyzeBBox, analyzeLayers, bboxThreshold, layerThreshold) # Revert elif result == 2: _revertColors(nodes) # Help (some sort of wiki link / or a popup with an image?) elif result == 3: print "To be completed.." # Cancel elif result == 0: return
def myGetCopypath(self): self.panelReslut = '' p = nuke.Panel('New Copy Path Tools') p.setWidth(200) p.addSingleLineInput('New Copy', '') p.addButton('Cancel') p.addButton('Apply') p.setWidth(350) self.panelReslut = p.show() if self.panelReslut: newCopyPath = p.value('New Copy') if newCopyPath and os.path.isdir(newCopyPath): if os.access(newCopyPath, os.W_OK): self.objectPath = os.path.join(newCopyPath, self.myFileSBName[0], self.myFileSBName[1], self.myFileSBName[2]) return True else: nuke.message( '\xe4\xbd\xa0\xe4\xb8\x8d\xe5\x85\xb7\xe6\x9c\x89\xe8\xaf\xa5\xe8\xb7\xaf\xe5\xbe\x84\xe7\x9a\x84\xe5\x86\x99\xe5\x85\xa5\xe6\x9d\x83\xe9\x99\x90\xef\xbc\x81' ) else: nuke.message( '\xe8\xbe\x93\xe5\x85\xa5\xe7\x9a\x84\xe7\x9b\xae\xe5\xbd\x95\xe4\xb8\x8d\xe5\xad\x98\xe5\x9c\xa8\xef\xbc\x81' ) return False
def setPreset(self): '''Called when preset button is pressed''' thisBtn=self.sender().text() thisPreset=PRESET_BTN[thisBtn] thisNode=self.node def setKnobValue(kvPaire, *strSub): '''set knob value @kvPaire: (<knob>, <value>) @*strSub: string to replace if any, (replaceThis, withThis) ''' pKnob, pValue = kvPaire if len(strSub)>0 and len(strSub)==2: pValue=re.sub(strSub[0], strSub[1], pValue) else: pValue self.node[pKnob].setValue(pValue) if thisBtn=='Raw Lighting': p=nuke.Panel('Select the albeto pass') p.addEnumerationPulldown('aov', ' '.join(nuke.layers())) if p.show(): albeto=p.value('aov') for k in thisPreset: setKnobValue(k, '<albeto>', albeto) else: for k in thisPreset: setKnobValue(k) self.node['label'].setValue(thisBtn) self.close()
def show_convert_node_panel(guess=False): """ show window to convert node :param guess: Bool if set to True guess the right convert type and don't show convert type panel :return: None """ # get all "valid" nodes of selection, e.g. all nodes that are in nodes_valid_list sel = [n for n in nuke.selectedNodes() if n.Class() in nodes_valid_list] if len(sel) == 0: return p = nuke.Panel("convert") p.addEnumerationPulldown("convert to", " ".join(nodes_valid_list)) if guess: # guess process conversion for node in sel: ext = os.path.splitext(node["file"].getValue())[1].lower() if ext in guess_list.keys(): type_convert = guess_list[ext] convert_node(node, type_convert) else: return else: if p.show(): type_convert = p.value("convert to") # manual process conversion for node in sel: convert_node(node, type_convert)
def __init__(self): PANEL=nuke.Panel('Constellation Render Manager [NUKE]') PANEL.setWidth(350) #Select Write Node ALLNODElis=nuke.root().nodes() WRITElis=[] for chk in ALLNODElis: if str(chk.name()).find('Write')!=-1: WRITElis.append(chk.name()) if len(WRITElis)>1: PANEL.addEnumerationPulldown('Select Write',str('" " '+' '.join(WRITElis))) PANEL.addEnumerationPulldown( 'Threads', '1 2 4 8' ) PANEL.addSingleLineInput('Block Divider','10') PANEL.addSingleLineInput('Start Frame',nuke.root().firstFrame()) PANEL.addSingleLineInput('End Frame',nuke.root().lastFrame()) RET=PANEL.show() if RET==1: if len(WRITElis)>1: WRITEvar=PANEL.value('Select Write') else: try: WRITEvar=WRITElis[0] except: nuke.message('') self.SUBMITTERALGfn(WRITEvar,PANEL.value('Threads'),PANEL.value('Block Divider'), PANEL.value('Start Frame'), PANEL.value('End Frame')) return
def leo_tig_mask(): pan = nuke.Panel('Leo and Tig: add mask') textinput = 'example: other.mask_' pan.addMultilineTextInput('compose_mask', textinput) pan.show() maskvalue = pan.value('compose_mask') nuke.selectedNode().knob('mask').setValue(maskvalue)
def buildPanel(self): self.p = nuke.Panel('Dailies Submission') self.p.addSingleLineInput("Archive Name:", self.archiveName) self.p.show() self.finalName = self.p.value("Archive Name:") self.collectFootage()
def Pixo3DBuild(): import nuke import pixo3D import PixoConnect panel = nuke.Panel("Card to track") panel.addBooleanCheckBox('Autolabel', False) panel.addBooleanCheckBox('Create Tree', True) panel.addBooleanCheckBox('Connect', False) if panel.show(): n = nuke.selectedNodes() Labell = panel.value("Autolabel") Tree = panel.value("Create Tree") Connect = panel.value("Connect") if Labell is True: pixo3D.pixo3D() if Tree is True: nuke.nodePaste('H:/.nuke/GeneralSetups/VrayTemplate.nk') #t = nuke.selectedNodes() if Connect is True: for i in n: i.setSelected(True) #nuke.setSelected(t) PixoConnect.PixoConnect() for i in n: i.setSelected(False)
def _createPannel(): # panel panel = nuke.Panel('PickStuffs_v01') panel.addFilenameSearch('destination', '/tmp') panel.addSingleLineInput( 'frames', '{}-{}'.format(nuke.root().firstFrame(), nuke.root().lastFrame())) return panel, panel.show()
def goToPlus(): ''' Allows you to directly enter simple math signs to go to a frame without explicity requiring you to enter the current frame number before it. ''' cFrame = nuke.frame() p = nuke.Panel( 'Go to Frame Plus' ) p.addSingleLineInput( '', '' ) p.show() goTo = p.value( '' ) pat1 = re.compile( '\+|-|\*|\/' ) if goTo == '': return elif goTo[0].isdigit() == True and pat1.search( goTo ) == None: nuke.frame( int( goTo ) ) elif goTo[0].isdigit() == True and pat1.search( goTo ) != None: try: nuke.frame( eval( goTo ) ) except Exception, e: raise RuntimeError( e )
def AutoQT(): pan = nuke.Panel('AutoQT_by_ [email protected]') pan.addFilenameSearch('OUT PATH', 'output path here') pan.addEnumerationPulldown('Select Size', 'PAL HD 1K_Super_35(full-ap)') pan.show() Output_Path = pan.value('OUT PATH') QT_Size = pan.value('Select Size') sel = nuke.selectedNodes() for m in sel: fn = nuke.filename(m) fn = os.path.basename(fn) fn = os.path.splitext(fn)[0] firstFrame = m.knob('first').getValue() lastFrame = m.knob('last').getValue() print fn rf = nuke.createNode("Reformat") rf.setInput(0, m) rf['format'].setValue(QT_Size) rf['black_outside'].setValue('True') wr = nuke.createNode("Write") wr.setInput(0, rf) wr['file'].setValue(Output_Path + fn + ".mov") wr['file_type'].setValue('mov') wr['codec'].setValue('none') wr['use_limit'].setValue('True') wr['first'].setValue(firstFrame) wr['last'].setValue(lastFrame) return ()
def login(username='', project=''): """Login to frame.io and store the session in global variable""" global frameiosession if frameiosession != None: if project: frameiosession.setProject(project) return frameiosession p = nuke.Panel('frame.io Login') p.addSingleLineInput('Username', username) p.addPasswordInput('Password', '') result = p.show() if result: user = p.value('Username') pw = p.value('Password') frameiosession = frameio.UserSession(user, pw) if frameiosession.getEligibility() == 'user-non-google': if project: frameiosession.setProject(project) return frameiosession else: projects = ' '.join(frameiosession.projectdict().values()) p.addEnumerationPulldown('Project', projects) result = p.show() if result: frameiosession.setProject(p.value('Project')) return frameiosession elif frameiosession.getEligibility() == 'user-google': nuke.message('Google accounts are currently not supported.') elif frameiosession.getEligibility() == 'user-eligible': nuke.message('Account not found.') else: nuke.message('Login failed.') return None
def main(): cam = nuke.getFilename('select Maya File', '*.ma') #cam='E:/Desktop/trash/testAnim.ma' fileObject = open(cam, "r") contents = fileObject.read() fileObject.close() sceneData = {} currentObj = '' currentAttr = '' chunkStart = 0 chunk = '' for line in contents.split('\n'): if 'createNode' in line: cmd, typ, fl, name = line.split(" ")[:4] name = name.strip("\";") nameparts = name.split("_") if len(nameparts) > 1: obj = "_".join(nameparts[:-1]) attr = nameparts[-1] if attr in transformAttrs: currentObj = obj currentAttr = attr if "ktv[" in line and currentAttr: chunkStart = 1 if chunkStart: lineFiltered = line.strip("\t;") chunk += lineFiltered if chunkStart and ";" in line: if not currentObj in sceneData.keys(): sceneData[currentObj] = {} if not currentAttr in sceneData[currentObj].keys(): sceneData[currentObj][currentAttr] = [] keys = chunk.split("]\" ")[1] keys = keys.split(" ") for i, k in enumerate(keys): if i % 2 == 0: sceneData[currentObj][currentAttr].append(k + ":" + keys[i + 1]) chunk = '' chunkStart = 0 currentAttr = '' transforms = sceneData.keys() transforms.sort() p = nuke.Panel('import transforms', scrollable=True) p.addEnumerationPulldown('transform1', ' '.join(transforms)) p.addEnumerationPulldown('transform2', ' '.join(transforms)) p.addEnumerationPulldown('transform3', ' '.join(transforms)) p.addEnumerationPulldown('transform4', ' '.join(transforms)) p.addEnumerationPulldown('transform5', ' '.join(transforms)) ret = p.show() if ret: createTransform(p.value('transform1'), sceneData) createTransform(p.value('transform2'), sceneData) createTransform(p.value('transform3'), sceneData) createTransform(p.value('transform4'), sceneData) createTransform(p.value('transform5'), sceneData) '''
def SCrendLinux(): import nuke panel = nuke.Panel("Priority") panel.addEnumerationPulldown("priority:", "medium low high") if panel.show(): priority = panel.value("priority:") try: f = nuke.allNodes() for a in f: if a.Class() == "comp_layers_core" or a.Class() == "Write": sel = a['selected'].value() if sel == 1: a['disable'].setValue(0) else: a['disable'].setValue(1) n = nuke.selectedNodes() for n in n: x = n['xpos'].value() y = n['ypos'].value() b = nuke.allNodes("BackdropNode") for ba in b: xb = ba['xpos'].value() yb = ba['ypos'].value() if xb < x and yb < y and xb > x - 300 and yb > y - 400 and ba[ 'label'].value() == "Precomp": ba['tile_color'].setValue(52479) ScanlineCoreSubmitRendering(priority, True, True) except: nuke.scriptSave() ScanlineCoreSubmitRendering(priority, True, True)
def OpenRenderWindow(): p = nuke.Panel('Submit to renderfarm') p.addSingleLineInput('First Frame', nuke.root().firstFrame()) p.addSingleLineInput('Last Frame', nuke.root().lastFrame()) p.addEnumerationPulldown('Threads', '8 16 32') for rserver in RenderNodes: p.addBooleanCheckBox(rserver, 0) if p.show(): selectedRenderNodes = [] for rserver in RenderNodes: if (p.value(rserver)): selectedRenderNodes.append(rserver) RenderOnNodes(selectedRenderNodes, nuke.root().name(), p.value("First Frame"), p.value("Last Frame"), p.value("Threads"))
def animationOffset_Frame(): p = nuke.Panel('AnimationOffset_Frame') p.setWidth(200) p.addSingleLineInput('Offset frame', '') p.addButton('Cancel') p.addButton('Apply') result = p.show() if result: Offset_Frame = float(p.value('Offset frame')) all_selected_nodes = nuke.selectedNodes() count = len(all_selected_nodes) if count == 0: return for eachNode in all_selected_nodes: allKnobs = eachNode.knobs() for eachKnob in allKnobs.values(): if eachKnob.isAnimated(): try: allCurves = eachKnob.animations() except: continue else: for eachCurve in allCurves: allKeys = eachCurve.keys() for key in allKeys: currentTime = key.x currentValue = key.y key.x = currentTime + Offset_Frame key.y = currentValue
def _select_channel_view(self, path, sg_publish_data): channels = os.listdir(os.path.dirname(os.path.dirname(path))) print channels panel = nuke.Panel("select channel") for channel in channels: panel.addBooleanCheckBox(channel, True) ret = panel.show() select_channels = [] for channel in channels: if panel.value(channel): select_channels.append(channel) xpos, ypos = self._find_position() ex_x = xpos ex_y = ypos - 150 if "DeepID" in select_channels: select_channels.remove("DeepID") select_channels.append("DeepID") for channel in select_channels: if channel == "Extra": extra_path = os.path.dirname(path.replace("primary", channel)) for extra in os.listdir(extra_path): default_path = os.path.join(extra_path, extra, os.path.basename(path)) self._create_channel_read_node(default_path, extra, ex_x, ex_y, sg_publish_data) ex_x = ex_x + 100 else: self._create_channel_read_node(path, channel, xpos, ypos, sg_publish_data) xpos = xpos + 100
def AutoCrop(): node = nuke.selectedNode() first_frame = int(nuke.Root()['first_frame'].getValue()) last_frame = int(nuke.Root()['last_frame'].getValue()) if node.knob("desc"): label = node.knob("desc").value() else: label = node.knob("label").value() p = nuke.Panel("Execute on FrameRange") p.addSingleLineInput('Label', label) p.addSingleLineInput('Layer', "alpha") p.addSingleLineInput('First Frame', first_frame) p.addSingleLineInput('Last Frame', last_frame) p.addSingleLineInput('Increment', 1) if p.show(): l = p.value("Layer") ff = int(p.value("First Frame")) lf = int(p.value("Last Frame")) i = int(p.value("Increment")) nukescripts.autocrop(first=ff, last=lf, inc=i, layer=l) autocrop = node.dependent()[0] '''autocrop.setInput(0,None) autocrop.knob('xpos').setValue(node.xpos()+50) autocrop.knob('ypos').setValue(node.ypos()+35)''' autocrop.knob('label').setValue(l)
def showname(): '''Shows the current script path and, if the selected node is a Read or Write node, the filename from it.''' # get the nuke script path # we always need this nukescript = nuke.value("root.name") # look if there is a selected node # if not, output the script only p = nuke.Panel("Current Info", 500) try: n = nuke.selectedNode() if n.Class() == "Read" or n.Class() == "Write": a = nuke.value(n.name() + ".first", nuke.value("root.first_frame")) b = nuke.value(n.name() + ".last", nuke.value("root.last_frame")) curfile = n.knob("file").value() + " " + str(a) + "-" + str(b) p.addSingleLineInput("Filename", curfile) p.addSingleLineInput("Script", nukescript) p.show() else: p.addSingleLineInput("Script", nukescript) p.show() except: p.addSingleLineInput("Script", nukescript) p.show()
def localiseFileThreaded(readKnobList): '''Wrapper to duck punch default method''' sequenceCount = len(readKnobList) if sequenceCount > 1: p = nuke.Panel('Localiser (threaded)') knobName = 'concurrent copy tasks' p.addEnumerationPulldown( knobName, ' '.join([ str(i + 1) for i in xrange(min(nuke.THREADS, sequenceCount, 12)) ])) if p.show(): maxThreads = int(p.value(knobName)) else: return else: maxThreads = 1 fileDict = {} allFilesPaths = [] for knob in readKnobList: first = knob.node().firstFrame() last = knob.node().lastFrame() filePathList = getFrameList(knob, allFilesPaths) fileDict[knob.node().name()] = filePathList allFilesPaths.extend(filePathList) logger.debug('max threads from panel: %s' % maxThreads) localiseThread = LocaliseThreaded(fileDict, maxThreads) localiseThread.start()
def set_preset(self): '''Called when preset button is pressed''' thisBtn=self.sender().text() thisPreset=PRESET_BTN[thisBtn] thisNode=self.node if thisBtn=='Raw Lighting': p=nuke.Panel('Select the albeto pass') p.addEnumerationPulldown('aov', ' '.join(nuke.layers())) if p.show(): albeto=p.value('aov') for k in thisPreset: self.set_knobValue(k, '<albeto>', albeto) elif thisBtn == 'AOV Mask': p=AOVMaskBox() _mask = p.run(self.ls_layers) if _mask: self.node['expr3'].setValue('%s.%s' % (_mask[0], _mask[1])) self.node['tile_color'].setValue(COL[_mask[1]]) self.node['label'].setValue('matte::[value expr3]') else: for k in thisPreset: self.set_knobValue(k) # self.node['label'].setValue(thisBtn) self.close()
def load_src(): import pipe asset_obj = pipe.Projects().GetAssetByInfo(nuke.root().name()) if not asset_obj: return shot_obj = asset_obj.GetShot() if not shot_obj: raise Exception('Shot not found') src_path = shot_obj.GetSrcPath() sequences = condensing_is(src_path, 'src') if not sequences: nuke.message("There aren't files in folder SRC") filenameSearch = "Load" enumerationPulldownp = "None " + ' '.join(sequences.keys()) p = nuke.Panel("Presets selection") p.addEnumerationPulldown("SRC to load:", enumerationPulldownp) p.addButton("Cancel") p.addButton("Load") result = p.show() enumVal = p.value("SRC to load:") if enumVal == 'None': return #nuke.message(sequences[enumVal]) n = nuke.toNode(enumVal) if not n: n = nuke.createNode('Read', inpanel=False) n.setName(enumVal) n.knob('file').fromUserText(sequences[enumVal])
def checkSequece(self): self.fileName = nuke.root().knob("name").value() if not self.fileName: nuke.message( '\xe8\xaf\xb7\xe5\x85\x88\xe4\xbf\x9d\xe5\xad\x98nuke\xe6\x96\x87\xe4\xbb\xb6\xef\xbc\x81' ) return self.selectedNode = nuke.selectedNodes()[0] if self.selectedNode: p = nuke.Panel('reformatTextUI') p.addSingleLineInput('scale:', '0.5') p.addButton('Cancel') p.addButton('OK') p.setWidth(10) self.panleResult = p.show() if self.panleResult: option = p.value('scale:') if option: self.createNode(option, 1) myDir = os.path.dirname(self.fileName) myDir = os.path.join(myDir, r"check") myDir = myDir.replace('\\', '/') if not os.path.isdir(myDir): os.makedirs(myDir) WriteFile = myDir + "/check.%04d.png" self.nodeWrite['file'].setValue(WriteFile)
def NameMy(): panel = nuke.Panel("Bold") panel.addSingleLineInput("Name:", "") panel.show() name = panel.value("Name:") #check for unique name nl = [] for nn in nuke.allNodes(): nl.append(nn.name()) if name in nl: #not unique i = 1 namei = name + '_' + str(i) while namei in nl: namei = name + '_' + str(i) i = i + 1 name = namei else: namei = name #check for unique name done n = nuke.selectedNode() n['name'].setValue(namei) n['note_font'].setValue("Bold") n['note_font_size'].setValue(14) x = n.xpos() y = n.ypos() n.setXYpos(x, y - 15)
def FrameBaker(): import nuke def FrameB(Froze): n = nuke.selectedNode() label = n['label'].setValue(Froze) u = 'curve' + '(' + Froze + ')' trans = n['translate'] if trans.isAnimated(): n['translate'].setExpression(u) else: return rot = n['rotate'] if rot.isAnimated(): n['rotate'].setExpression(u) else: return foc = n['focal'] if foc.isAnimated(): n['focal'].setExpression(u) else: return n['tile_color'].setValue(65280L) n['gl_color'].setValue(65280L) frame = nuke.tcl('frame') panel = nuke.Panel('Frozen Frame') panel.addSingleLineInput("BakedFrame", frame) panel.show() Froze = panel.value('BakedFrame') print Froze FrameB(Froze)
def nextVersionPanel(): p = nuke.Panel('nextVersion - Select write nodes to increment version') p.setWidth(500) for node in nuke.allNodes("Write"): p.addBooleanCheckBox("%s" % node.name(), 1) return p
def goto_frame(): f = nuke.frame() p = nuke.Panel("Goto Frame") p.addSingleLineInput("Frame:", f) result = p.show() if result == 1: nuke.frame(int(nuke.expression(p.value("Frame:"))))
def createPrepFolders(): user = os.getenv('USER') job = os.getenv('JOB') shot = os.getenv('SHOT') panel = nuke.Panel('Create Prep folder structure - by Mohan pugaz') panel.addSingleLineInput('artist', user) if shot == None: panel.addFilenameSearch('path', '/jobs/' + job + '/') if shot: panel.addFilenameSearch( 'path', '/jobs/' + job + '/' + shot + '/nuke/comp/scene/') if not panel.show(): return artist = panel.value('artist') path = panel.value('path') os.mkdir(path + artist) os.mkdir(path + artist + '/' + 'mocha') os.mkdir(path + artist + '/' + 'shapes') shotname = os.getenv('SHOTNAME') if shot: nuke.scriptSaveAs( path + artist + '/' + 'F_%s_cleanUp_v001.nk' % shotname, -1) if shot == None: nuke.scriptSaveAs(path + artist + '/' + 'F_CleanUp_v001.nk', -1) return artist