def udim_group(nodes): # collaspe all udim tree nodes in a group for n in nodes: n["selected"].setValue ( True ) group_node = nuke.collapseToGroup(False) group_node.autoplace() return group_node
def forEach(): forbidden = ['RotoPaint', 'Roto'] for n in nuke.selectedNodes(): feMsg = 'Nodes from type ' + n.Class( ) + ' are not supported yet. Please remove them from the selection before creating the ForEach node.' if n.Class() in forbidden: nuke.message(feMsg) return False feGroup = nuke.collapseToGroup() feGroup.setName("forEach") for n in feGroup.nodes(): n.setSelected(False) nuke.allNodes("Input", feGroup)[0].setSelected(True) feTab = feGroup.addKnob(nuke.Tab_Knob("forEach")) feGroup.addKnob(nuke.Int_Knob("n_inputs", "number of inputs")) feGroup.addKnob(nuke.Boolean_Knob("manual", "manual loop")) feGroup.addKnob(nuke.Int_Knob("init", "from:")) feGroup.addKnob(nuke.Int_Knob("end", "to:")) feGroup['n_inputs'].setValue(1) feGroup['n_inputs'].setTooltip( "determines the number of inputs (arrows) the node has got.") feGroup["manual"].setTooltip( "If in manual mode forEach will run from init to end.") feGroup["init"].setTooltip( "The init value of the loop. In pseudocode, this would correspond to for(i=init; i<=end; i++)" ) feGroup["end"].setTooltip( "The end value of the loop. In pseudocode, this would correspond to for(i=init; i<=end; i++)" ) feGroup["end"].setValue(10) feGroup["manual"].setFlag(nuke.STARTLINE) feGroup["init"].clearFlag(nuke.STARTLINE) feGroup["init"].setEnabled(False) feGroup["end"].clearFlag(nuke.STARTLINE) feGroup["end"].setEnabled(False) feGroup.knob("knobChanged").setValue( "with nuke.thisNode():\n knob = nuke.thisKnob();\n if(knob.name() == 'n_inputs'):\n n_inps = len(nuke.allNodes('Input'));\n n_knob = int(float(knob.value()))-1;\n\n if n_knob != n_inps:\n for i in range(n_inps-1, n_knob, cmp(n_knob, n_inps)):\n if(n_inps < n_knob):\n nuke.nodes.Input();\n elif n_knob > -1:\n nuke.delete(nuke.allNodes('Input')[0]);\n elif(knob.name() == 'manual'):\n nuke.thisNode()['init'].setEnabled(knob.value());\n nuke.thisNode()['end'].setEnabled(knob.value());" ) feGroup.addKnob(nuke.PyScript_Knob("run_btn", "explode loop")) feGroup['run_btn'].setTooltip( "transforms the forEach group into clones created by the loop.") feGroup['run_btn'].setCommand( "from types import *\n\ndef is_numeric(n):\n try: \n float(n);\n return True;\n except TypeError:\n return False;\n\nfeGroup = nuke.thisNode();\nfePadding = feGroup.knob('padd').getValue();\nfeCY = int(feGroup.ypos() + feGroup.screenHeight()/2);\nfeCX = int(feGroup.xpos() + feGroup.screenWidth()/2);\nfeW = 0; feH = 0;\nfe_horiz = (feGroup.knob('layout').value() == 'horizontal');\n\nfe_manual = feGroup['manual'].value();\n\nfeInputs_num = feGroup.inputs() if not fe_manual else (int(feGroup['end'].value()) - int(feGroup['init'].value()));\nfeInputs = feGroup.dependencies();\nfeInputs.sort(lambda a,b: cmp(a.xpos() if fe_horiz else a.ypos(), b.xpos() if fe_horiz else b.ypos()));\n\nif fe_manual: feInputs += [fakeInp for fakeInp in xrange(feInputs_num - len(feInputs))];\n\n#expand group:\nfeGroup = feGroup.expand();\n\n#create a clone for every input\nfor i, feInput in enumerate(feInputs):\n if i>0: nuke.cloneSelected();\n\n feGroup = nuke.selectedNodes();\n\n feEach = nuke.nodes.NoOp();\n feEach.setName('each');\n \n feI = nuke.String_Knob('i', 'instance #');\n feEach.addKnob(feI);\n feI.setValue(str(i));\n feI.setTooltip('Use [python {forEach_i()}] inside an expression of a node created by the forEach node to access the iterator of the for loop (i). For this to work you need to keep the each-nodes.');\n feI.setEnabled(False);\n \n # find first node:\n for feC in feGroup:\n if feC.isSelected():\n feClone = feC;\n else:\n break;\n \n if feClone.maxInputs > 0: feClone.setInput(0, feEach);\n\n if not fe_manual or not is_numeric(feInput): feEach.setInput(0, feInput);\n if fe_horiz: \n feEach.setYpos(feCY);\n else:\n feEach.setXpos(feCX);\n\n feEach.setSelected(True);\n feGroup = nuke.selectedNodes();\n \n for j,node in enumerate(feGroup): #walk thru all nodes within & position\n if fe_horiz:\n feW = max(feW, node.screenWidth() + fePadding);\n else:\n feH = max(feH, node.screenHeight() + fePadding);\n\n if fe_horiz: \n node.setXpos(int(feCX - feW * (feInputs_num/2) + feW * i));\n else: \n node.setYpos(int(feCY - feH * (feInputs_num/2) + feH * i));\n feEach.setYpos(feClone.ypos()-feClone.screenHeight()-feEach.screenHeight()-40);\n feEach.setSelected(False);\n\n#clean up\nnuke.selectAll();\nnuke.invertSelection();\n\n#i-function\ndef forEach_i():\n n = nuke.thisNode();\n if n.name() != 'Root':\n while (n.Class() != 'NoOp' or not n.name().startswith('each')) and len(n.dependencies()) > 0:\n n = n.dependencies()[0];\n return int(n['i'].value()) if n.knob('i') != None else -1;\n else:\n return -1;" ) feGroup['run_btn'].setFlag(nuke.STARTLINE) feGroup.addKnob(nuke.Tab_Knob("display", "display options")) feGroup.addKnob( nuke.Enumeration_Knob("layout", "preferred layout", ["horizontal", "vertical"])) feGroup.addKnob(nuke.Double_Knob("padd", "padding")) feGroup['padd'].setTooltip("determines the space between branches.") feGroup['padd'].setValue(300) return True
def check_Fx(self): #查找所有的节点 self.allSelectNode = nuke.selectedNodes() for slNode in self.allSelectNode: _bbox = [slNode.screenWidth(), slNode.screenHeight()] myDot = nuke.nodes.Dot() myDot.setInput(0, slNode) myDot.setXYpos(slNode.xpos() + _bbox[1]/2, slNode.ypos()+ _bbox[1]/2*3) myShuffle = nuke.nodes.Shuffle() myShuffle.setInput(0, myDot) myShuffle['red'].setValue(6) myShuffle['green'].setValue(6) myShuffle['blue'].setValue(6) myShuffle['alpha'].setValue(6) myShuffle.setXYpos(slNode.xpos() + _bbox[1]/2*3, slNode.ypos()+ _bbox[1]/2*3) myGrade = nuke.nodes.Grade() myGrade['white'].setValue(0.3) myGrade.setInput(0, myShuffle) myGrade.setXYpos(slNode.xpos(), slNode.ypos()+ _bbox[1]*2) myMerge = nuke.nodes.Merge() myMerge.setInput(1, myDot) myMerge.setInput(0, myGrade) myMerge.setXYpos(slNode.xpos() - _bbox[1]/2*3, slNode.ypos()+ _bbox[1]/2*3) self.setSelecteNone() myDot.setSelected(True) myShuffle.setSelected(True) myGrade.setSelected(True) myMerge.setSelected(True) nuke.collapseToGroup() #OCT_Check_fx().check_Fx()
def makeGroup(self): if len(self.lista) >= 2: for shuffleknob in self.sGroup: shuffleknob['selected'].setValue(True) node = nuke.collapseToGroup(show=False) node.autoplace() gName = node.name() nuke.toNode(gName)["name"].setValue("Exr Merge %s" %self.nIncrement) self.nIncrement += 1 #node.lock_connections(True) else: pass
def makeGroup(): if len(lista) >= 2: global node, nIncrement for shuffleknob in sGroup: shuffleknob['selected'].setValue(True) node = nuke.collapseToGroup(show=False) node.autoplace() gName = node.name() #print gName nuke.toNode(gName)["name"].setValue("Exr Merge %s" %nIncrement) nIncrement += 1 #node.lock_connections(True) #print node else: pass
def makeGroup(): if len(lista) >= 2: global node, nIncrement for shuffleknob in sGroup: shuffleknob['selected'].setValue(True) node = nuke.collapseToGroup(show=False) node.autoplace() gName = node.name() #print gName nuke.toNode(gName)["name"].setValue("Exr Merge %s" % nIncrement) nIncrement += 1 #node.lock_connections(True) #print node else: pass
def buildMainGraph(self, readsDic): # Create beauty read beautyRead = readsDic['BEAUTY'] # Create lighting group t.unselect_all() lightingGroup = nuke.collapseToGroup() lightingGroup.setName('LIGHTING GROUP') # Connects nodes lightingGroup.setInput(0, beautyRead) lightingGroup.setSelected(True) nukescripts.connect_selected_to_viewer(0) return lightingGroup
def initializeNode(): deselectAll() # Add shuffle to ensure there's only 1 input shuffle = nuke.createNode("Shuffle") shuffle["name"].setValue("Temp") merge = nuke.createNode("Merge2") merge.setInput(0, shuffle) merge["operation"].setValue("in") knob = nuke.Text_Knob("type", "type", "main") merge.addKnob(knob) merge.setSelected(True) shuffle.setSelected(True) group = nuke.collapseToGroup() customKnob = nuke.PyCustom_Knob( "ShuffleTable", "", "shuffleMgr.ShuffleMgrWindow(nuke.thisNode())") group.addKnob(customKnob)
def makeGroup(self): if len(self.lista) >= 2: nuke.selectAll() nuke.invertSelection() for shuffleknob in self.sGroup: shuffleknob['selected'].setValue(True) #for shuffleknob in self.readNodes: #shuffleknob['selected'].setValue(True) node = nuke.collapseToGroup(show=False) node['xpos'].setValue(self.mainBeautyLayer.xpos()) node['ypos'].setValue(self.mainBeautyLayer.ypos() + 100) #node.autoplace() #gName = node.name() #nuke.tprint((self.mainBeautyLayer)) #nuke.toNode(gName)["name"].setValue("Exr Merge %s" %'hello') #self.nIncrement += 1 #node.lock_connections(True) else: pass
def forEach(): forbidden = ['RotoPaint','Roto']; for n in nuke.selectedNodes(): feMsg = 'Nodes from type ' + n.Class() + ' are not supported yet. Please remove them from the selection before creating the ForEach node.'; if n.Class() in forbidden: nuke.message(feMsg); return False; feGroup = nuke.collapseToGroup(); feGroup.setName("forEach"); for n in feGroup.nodes(): n.setSelected(False); nuke.allNodes("Input", feGroup)[0].setSelected(True); feTab = feGroup.addKnob(nuke.Tab_Knob("forEach")); feGroup.addKnob(nuke.Int_Knob("n_inputs", "number of inputs")); feGroup.addKnob(nuke.Boolean_Knob("manual", "manual loop")); feGroup.addKnob(nuke.Int_Knob("init", "from:")); feGroup.addKnob(nuke.Int_Knob("end", "to:")); feGroup['n_inputs'].setValue(1); feGroup['n_inputs'].setTooltip("determines the number of inputs (arrows) the node has got."); feGroup["manual"].setTooltip("If in manual mode forEach will run from init to end."); feGroup["init"].setTooltip("The init value of the loop. In pseudocode, this would correspond to for(i=init; i<=end; i++)"); feGroup["end"].setTooltip("The end value of the loop. In pseudocode, this would correspond to for(i=init; i<=end; i++)"); feGroup["end"].setValue(10); feGroup["manual"].setFlag(nuke.STARTLINE); feGroup["init"].clearFlag(nuke.STARTLINE); feGroup["init"].setEnabled(False); feGroup["end"].clearFlag(nuke.STARTLINE); feGroup["end"].setEnabled(False); feGroup.knob("knobChanged").setValue("with nuke.thisNode():\n knob = nuke.thisKnob();\n if(knob.name() == 'n_inputs'):\n n_inps = len(nuke.allNodes('Input'));\n n_knob = int(float(knob.value()))-1;\n\n if n_knob != n_inps:\n for i in range(n_inps-1, n_knob, cmp(n_knob, n_inps)):\n if(n_inps < n_knob):\n nuke.nodes.Input();\n elif n_knob > -1:\n nuke.delete(nuke.allNodes('Input')[0]);\n elif(knob.name() == 'manual'):\n nuke.thisNode()['init'].setEnabled(knob.value());\n nuke.thisNode()['end'].setEnabled(knob.value());"); feGroup.addKnob(nuke.PyScript_Knob("run_btn", "explode loop")); feGroup['run_btn'].setTooltip("transforms the forEach group into clones created by the loop."); feGroup['run_btn'].setCommand("from types import *\n\ndef is_numeric(n):\n try: \n float(n);\n return True;\n except TypeError:\n return False;\n\nfeGroup = nuke.thisNode();\nfePadding = feGroup.knob('padd').getValue();\nfeCY = int(feGroup.ypos() + feGroup.screenHeight()/2);\nfeCX = int(feGroup.xpos() + feGroup.screenWidth()/2);\nfeW = 0; feH = 0;\nfe_horiz = (feGroup.knob('layout').value() == 'horizontal');\n\nfe_manual = feGroup['manual'].value();\n\nfeInputs_num = feGroup.inputs() if not fe_manual else (int(feGroup['end'].value()) - int(feGroup['init'].value()));\nfeInputs = feGroup.dependencies();\nfeInputs.sort(lambda a,b: cmp(a.xpos() if fe_horiz else a.ypos(), b.xpos() if fe_horiz else b.ypos()));\n\nif fe_manual: feInputs += [fakeInp for fakeInp in xrange(feInputs_num - len(feInputs))];\n\n#expand group:\nfeGroup = feGroup.expand();\n\n#create a clone for every input\nfor i, feInput in enumerate(feInputs):\n if i>0: nuke.cloneSelected();\n\n feGroup = nuke.selectedNodes();\n\n feEach = nuke.nodes.NoOp();\n feEach.setName('each');\n \n feI = nuke.String_Knob('i', 'instance #');\n feEach.addKnob(feI);\n feI.setValue(str(i));\n feI.setTooltip('Use [python {forEach_i()}] inside an expression of a node created by the forEach node to access the iterator of the for loop (i). For this to work you need to keep the each-nodes.');\n feI.setEnabled(False);\n \n # find first node:\n for feC in feGroup:\n if feC.isSelected():\n feClone = feC;\n else:\n break;\n \n if feClone.maxInputs > 0: feClone.setInput(0, feEach);\n\n if not fe_manual or not is_numeric(feInput): feEach.setInput(0, feInput);\n if fe_horiz: \n feEach.setYpos(feCY);\n else:\n feEach.setXpos(feCX);\n\n feEach.setSelected(True);\n feGroup = nuke.selectedNodes();\n \n for j,node in enumerate(feGroup): #walk thru all nodes within & position\n if fe_horiz:\n feW = max(feW, node.screenWidth() + fePadding);\n else:\n feH = max(feH, node.screenHeight() + fePadding);\n\n if fe_horiz: \n node.setXpos(int(feCX - feW * (feInputs_num/2) + feW * i));\n else: \n node.setYpos(int(feCY - feH * (feInputs_num/2) + feH * i));\n feEach.setYpos(feClone.ypos()-feClone.screenHeight()-feEach.screenHeight()-40);\n feEach.setSelected(False);\n\n#clean up\nnuke.selectAll();\nnuke.invertSelection();\n\n#i-function\ndef forEach_i():\n n = nuke.thisNode();\n if n.name() != 'Root':\n while (n.Class() != 'NoOp' or not n.name().startswith('each')) and len(n.dependencies()) > 0:\n n = n.dependencies()[0];\n return int(n['i'].value()) if n.knob('i') != None else -1;\n else:\n return -1;"); feGroup['run_btn'].setFlag(nuke.STARTLINE); feGroup.addKnob(nuke.Tab_Knob("display", "display options")); feGroup.addKnob(nuke.Enumeration_Knob("layout", "preferred layout", ["horizontal", "vertical"])); feGroup.addKnob(nuke.Double_Knob("padd", "padding")); feGroup['padd'].setTooltip("determines the space between branches."); feGroup['padd'].setValue(300); return True;
def main(): nSel = nuke.selectedNodes() nuke.selectAll() nuke.invertSelection() for n in nSel: n.setSelected(True) #get other passes from selected Read filename = n['file'].value().split('/')[-1] task = nuke.ProgressTask("getRenders") task.setMessage('processing %s' % filename) grp = nuke.collapseToGroup(n) myGroup = nuke.toNode(grp.name()) n = nuke.allNodes('Read', group=myGroup)[0] n['name'].setValue("HeroRead") f = n['file'].value() dir = os.path.dirname(f) seqData = findRendersFromDirectory(dir) uniquePaths, uniqueNames, commonPath, commonName = seqData #return message of number of sequences found #nuke.message(str(len(uniqueNames)) +' sequences found:'+"\n"+"\n".join(uniqueNames)) nodes = [] sh = '' priorShuffle = '' with grp: for p, each in enumerate(uniqueNames): if not each == "": #create read node, set expressions r = nuke.nodes.Read() r['file'].setValue(commonPath + uniquePaths[p]) r['first'].setExpression("HeroRead.first") r['last'].setExpression("HeroRead.last") r['on_error'].setExpression("HeroRead.on_error") r['name'].setValue(each) #get number of channels within node, built out shuffleCopy for each node #chanDict=getChannelsAsDictionary(r) #for ch in chanDict.keys(): #create shuffleCopy and setup sh = nuke.nodes.Copy() sh.setInput(1, r) if not priorShuffle: sh.setInput(0, n) if priorShuffle: sh.setInput(0, priorShuffle) sh['from0'].setValue("none") sh['to0'].setValue("none") sh['channels'].setValue("all") #sh['label'].setValue('[value out2]') #add to array priorShuffle = sh nodes.append(r) task.setProgress(int(float(p) / len(uniqueNames) * 100)) #create combined asset mattes sh = buildAssetMattes(sh) nuke.toNode('Output1').setInput(0, sh) nuke.toNode('Output1').setXYpos(sh.xpos(), sh.ypos() + 80) createReadGroup(n, grp) del (task) grp['postage_stamp'].setValue(1) grp.knobs()['User'].setLabel("MultiChannelRead") file = grp['file'].value() fName = file.split('/')[-1].split('.')[0] regex = re.compile("v[0-9]{2,9}") vers = regex.findall(file)[0] grp['label'].setValue(fName + '\n' + vers) #using 'scripts' in call because 'scripts' is currently called during import of all script files #pyButton = nuke.PyScript_Knob('updateVersion', "updateToLatest", "scripts.arnoldGatherBty.updateLatest()") #pyButton.setFlag(nuke.STARTLINE) #grp.addKnob(pyButton) nuke.selectAll() nuke.invertSelection()
def buildGrp(n, rebuild): filename = n['file'].value().split('/')[-1] if rebuild: thisNode = n n = nuke.nodes.Read() n['file'].setValue(thisNode['file'].value()) n['first'].setValue(thisNode['first'].value()) n['last'].setValue(thisNode['last'].value()) nuke.selectAll() nuke.invertSelection() n.setSelected(True) #get other passes from selected Read filename = n['file'].value().split('/')[-1] task = nuke.ProgressTask("getRenders") task.setMessage('processing %s' % filename) f = n['file'].value() dir = os.path.dirname(f) seqData = findRendersFromDirectory(dir) if seqData: n.setSelected(True) grp = nuke.collapseToGroup(n) myGroup = nuke.toNode(grp.name()) n = nuke.allNodes('Read', group=myGroup)[0] n['name'].setValue("HeroRead") n['knobChanged'].setValue( "kn=[\"before\",\"cacheLocal\",\"premultiplied\",\"format\",\"after\",\"on_error\",\"last\",\"colorspace\",\"first\"]\nn=nuke.thisNode()\nk=nuke.thisKnob()\nif k.name() in kn:\n for node in nuke.allNodes():\n if k.name() in node.knobs(): node[k.name()].setValue(n[k.name()].value())" ) uniquePaths, uniqueNames, commonPath, commonName, version = seqData #ignore cryptoMatte in lightingRenders if not 'uBasic' in filename: uBasicRemove = [] for uN in uniqueNames: print uN if uN.startswith('u'): print 'remove' uBasicRemove.append(uN) for uR in uBasicRemove: uniqueNames.remove(uR) print uniqueNames #return message of number of sequences found #nuke.message(str(len(uniqueNames)) +' sequences found:'+"\n"+"\n".join(uniqueNames)) nodes = [] sh = '' priorShuffle = '' cryptoMaterialExists = 0 with grp: for p, each in enumerate(uniqueNames): if not each == "": #create read node, set expressions r = nuke.nodes.Read() r['file'].setValue(commonPath + uniquePaths[p].replace( '.####', version + '.####')) #add version back into uniquePath #r['file'].setValue(commonPath+uniquePaths[p]) #r['first'].setExpression("HeroRead.first") #r['last'].setExpression("HeroRead.last") r['first'].setValue(n['first'].value()) r['last'].setValue(n['last'].value()) r['on_error'].setValue(n['on_error'].value()) r['name'].setValue(each) ref = nuke.nodes.Reformat() ref.setInput(0, r) if 'Crypto' in each: #store cryptoAsset for metadata fetching if 'CryptoAsset' in each: cryptoMaterialExists = r chanDict = getChannelsAsDictionary(r) for ch in chanDict.keys(): #create shuffleCopy and setup sh = nuke.nodes.ShuffleCopy() sh.setInput(1, ref) if not priorShuffle: sh.setInput(0, n) if priorShuffle: sh.setInput(0, priorShuffle) sh['in'].setValue(ch) sh['in2'].setValue('rgba') nuke.tcl('add_layer { ' + ch + ' ' + ch + '.red ' + ch + '.green ' + ch + '.blue ' + ch + '.alpha}') sh['out'].setValue('none') sh['out2'].setValue(ch) #sh['red'].setValue('red') #sh['green'].setValue('green') #sh['blue'].setValue('blue') #sh['alpha'].setValue('alpha') sh['black'].setValue('red') sh['white'].setValue('green') sh['red2'].setValue('blue') sh['green2'].setValue('alpha') sh['label'].setValue('[value out2]') #add to array priorShuffle = sh nodes.append(r) else: #create shuffleCopy and setup sh = nuke.nodes.ShuffleCopy() sh.setInput(1, ref) if not priorShuffle: ref = nuke.nodes.Reformat() ref.setInput(0, n) sh.setInput(0, ref) heroRef = ref if priorShuffle: sh.setInput(0, priorShuffle) sh['in'].setValue('rgba') sh['in2'].setValue('rgba') nuke.tcl('add_layer { ' + each + ' ' + each + '.red ' + each + '.green ' + each + '.blue ' + each + '.alpha}') sh['out'].setValue('none') sh['out2'].setValue(each) #sh['red'].setValue('red') #sh['green'].setValue('green') #sh['blue'].setValue('blue') #sh['alpha'].setValue('alpha') sh['black'].setValue('red') sh['white'].setValue('green') sh['red2'].setValue('blue') if 'rgba.alpha' in r.channels(): sh['green2'].setValue('alpha') else: sh['green2'].setValue('alpha2') sh['label'].setValue('[value out2]') #add to array priorShuffle = sh nodes.append(r) task.setProgress(int(float(p) / len(uniqueNames) * 100)) #avoid consolidate if not lighting pass reads if 'direct_specular.red' in sh.channels(): c = consolidateChannels( sh, ['direct_specular', 'direct_specular_2'], 'spec') sh = consolidateChannels(c, [ 'indirect_specular', 'indirect_specular2', 'indirect_specular_2' ], 'indirect_spec') #create combined asset mattes sh = buildAssetMattes(sh) #build hair Mattes sh = buildHairMattes(sh) sh2 = sh #add startRGBA channel sh = nuke.nodes.Shuffle() sh['in'].setValue('rgba') nuke.tcl('add_layer { ' + 'startRGBA' + ' ' + 'startRGBA' + '.red ' + 'startRGBA' + '.green ' + 'startRGBA' + '.blue ' + 'startRGBA' + '.alpha}') sh['out'].setValue('startRGBA') sh.setInput(0, sh2) if 'spec.red' in sh.channels(): sh = buildRemainderChannel(sh) copyBB = nuke.nodes.CopyBBox() copyBB.setInput(0, sh) copyBB.setInput(1, heroRef) if cryptoMaterialExists: metaNode = nuke.nodes.CopyMetaData() metaNode.setInput(0, copyBB) metaNode.setInput(1, cryptoMaterialExists) copyBB = metaNode nuke.toNode('Output1').setInput(0, copyBB) nuke.toNode('Output1').setXYpos(copyBB.xpos(), copyBB.ypos() + 80) createReadGroup(n, grp) del (task) grp['postage_stamp'].setValue(1) grp.knobs()['User'].setLabel("MultiChannelRead") file = grp['file'].value() fName = file.split('/')[-1].split('.')[0] regex = re.compile("v[0-9]{2,9}") vers = regex.findall(file)[0] grp['label'].setValue( '[lindex [split [lindex [split [value file] /] end] .] 0] ') if rebuild: grp.setXYpos(thisNode.xpos(), thisNode.ypos()) #reconnect to old group connections connections = getConnections(thisNode) for c in connections.keys(): nuke.toNode(c).setInput(connections[c], grp) nuke.delete(thisNode) #using 'scripts' in call because 'scripts' is currently called during import of all script files #pyButtonLatest = nuke.PyScript_Knob('updateVersion', "updateToLatest", "mlScripts.GatherAovs_Arnold.updateLatest()") #pyButtonLatest.setFlag(nuke.STARTLINE) #pyButtonUp = nuke.PyScript_Knob('verionUp', "versionUp", "import mlPipeline\nfrom mlPipeline import ml_pipelineTools\nreload(mlPipeline.ml_pipelineTools)\nmlPipeline.ml_pipelineTools.versionUp()") #pyButtonDown = nuke.PyScript_Knob('verionDown', "versionDown", "import mlPipeline\nfrom mlPipeline import ml_pipelineTools\nreload(mlPipeline.ml_pipelineTools)\nmlPipeline.ml_pipelineTools.versionDown()") #grp.addKnob(pyButtonLatest) #grp['on_error'].setValue(3) grp['knobChanged'].setValue( "kn=[\"postage_stamp\",\"disable\"]\nn=nuke.thisNode()\nk=nuke.thisKnob()\nif k.name() in kn:\n for node in nuke.allNodes():\n if node.Class()==\"Read\": node[k.name()].setValue(n[k.name()].value())" ) #grp.addKnob(pyButtonUp) #grp.addKnob(pyButtonDown) nuke.selectAll() nuke.invertSelection()
def main(): #get other passes from selected Read n = nuke.selectedNode() grp = nuke.collapseToGroup(n) myGroup = nuke.toNode(grp.name()) n = nuke.allNodes('Read', group=myGroup)[0] n['name'].setValue("HeroRead") f = n['file'].value() dir = os.path.dirname(f) seqData = findRendersFromDirectory(dir) uniquePaths, uniqueNames, commonPath, commonName = seqData #return message of number of sequences found nuke.message( str(len(uniqueNames)) + ' sequences found:' + "\n" + "\n".join(uniqueNames)) nodes = [] priorShuffle = '' with grp: for p, each in enumerate(uniqueNames): if not each == "": #create read node, set expressions r = nuke.nodes.Read() r['file'].setValue(commonPath + uniquePaths[p]) r['first'].setExpression("HeroRead.first") r['last'].setExpression("HeroRead.last") r['name'].setValue(each) #create shuffleCopy and setup sh = nuke.nodes.ShuffleCopy() sh.setInput(1, r) if not priorShuffle: sh.setInput(0, n) if priorShuffle: sh.setInput(0, priorShuffle) sh['in'].setValue('rgba') sh['in2'].setValue('none') nuke.tcl('add_layer { ' + each + ' ' + each + '.red ' + each + '.green ' + each + '.blue ' + each + '.alpha}') sh['out'].setValue('none') sh['out2'].setValue(each) #sh['red'].setValue('red') #sh['green'].setValue('green') #sh['blue'].setValue('blue') #sh['alpha'].setValue('alpha') sh['black'].setValue('red') sh['white'].setValue('green') sh['red2'].setValue('blue') sh['green2'].setValue('alpha') sh['label'].setValue('[value out2]') #add to array priorShuffle = sh nodes.append(r) nuke.toNode('Output1').setInput(0, sh) createReadGroup(n, grp) grp['postage_stamp'].setValue(1) grp.knobs()['User'].setLabel("MultiChannelRead") grp['label'].setValue( "[lrange [split [value file] / ] [expr [llength [split [value file] / ]]-3] [expr [llength [split [value file] / ]]-3] ]" ) pyButton = nuke.PyScript_Knob( 'updateVersion', "updatePassesToBeautyVersion", "gatherPassesFromMasterBeauty.updatedPassesVersion()") pyButton.setFlag(nuke.STARTLINE) grp.addKnob(pyButton)
n = nuke.createNode('Blur') n.knob('size').setValue(120) n.knob('label').setValue('My Label') # deleting a node n = nuke.selectedNode() nuke.delete(n) nuke.delete(nuke.toNode('Blur1')) nukescripts.node_delete() # delete selected node # this line will create a complete group # with inout and output nuke.collapseToGroup() # this line create an empty group group = nuke.createNode('Group') # this line will create an input nuke.createNode('Input') # create a full group group = nuke.createNode('Group') group.begin() nuke.createNode('Input') nuke.createNode('Output') group.end() group = nuke.createNode('Group') group.begin()
def rebuildGroup(thisNode): n=nuke.nodes.Read() n['file'].setValue(thisNode['file'].value()) n['first'].setValue(thisNode['first'].value()) n['last'].setValue(thisNode['last'].value()) nuke.selectAll() nuke.invertSelection() n.setSelected(True) #get other passes from selected Read filename=n['file'].value().split('/')[-1] task = nuke.ProgressTask("getRenders") task.setMessage( 'processing %s' % filename ) grp=nuke.collapseToGroup(n) myGroup=nuke.toNode(grp.name()) n= nuke.allNodes('Read',group=myGroup)[0] n['name'].setValue("HeroRead") f=n['file'].value() dir=os.path.dirname(f) seqData=findRendersFromDirectory(dir) uniquePaths,uniqueNames,commonPath,commonName=seqData #return message of number of sequences found #nuke.message(str(len(uniqueNames)) +' sequences found:'+"\n"+"\n".join(uniqueNames)) nodes=[] sh='' priorShuffle='' with grp: for p,each in enumerate(uniqueNames): if not each=="": #create read node, set expressions r=nuke.nodes.Read() r['file'].setValue(commonPath+uniquePaths[p]) r['first'].setExpression("HeroRead.first") r['last'].setExpression("HeroRead.last") r['on_error'].setExpression("HeroRead.on_error") r['name'].setValue(each) if 'Crypto' in each: print each #store cryptoAsset for metadata fetching if 'CryptoAsset' in each: cryptoMaterialExists=r chanDict=getChannelsAsDictionary(r) for ch in chanDict.keys(): #create shuffleCopy and setup sh=nuke.nodes.ShuffleCopy() sh.setInput(1,ref) if not priorShuffle: sh.setInput(0,n) if priorShuffle: sh.setInput(0,priorShuffle) sh['in'].setValue(ch) sh['in2'].setValue('rgba') nuke.tcl('add_layer { '+ch+' '+ch+'.red '+ch+'.green '+ch+'.blue '+ch+'.alpha}') sh['out'].setValue('none') sh['out2'].setValue(ch) #sh['red'].setValue('red') #sh['green'].setValue('green') #sh['blue'].setValue('blue') #sh['alpha'].setValue('alpha') sh['black'].setValue('red') sh['white'].setValue('green') sh['red2'].setValue('blue') sh['green2'].setValue('alpha') sh['label'].setValue('[value out2]') #add to array priorShuffle=sh nodes.append(r) else: #create shuffleCopy and setup sh=nuke.nodes.ShuffleCopy() sh.setInput(1,ref) if not priorShuffle: ref=nuke.nodes.Reformat() ref.setInput(0,n) sh.setInput(0,ref) heroRef=ref if priorShuffle: sh.setInput(0,priorShuffle) sh['in'].setValue('rgba') sh['in2'].setValue('rgba') nuke.tcl('add_layer { '+each+' '+each+'.red '+each+'.green '+each+'.blue '+each+'.alpha}') sh['out'].setValue('none') sh['out2'].setValue(each) #sh['red'].setValue('red') #sh['green'].setValue('green') #sh['blue'].setValue('blue') #sh['alpha'].setValue('alpha') sh['black'].setValue('red') sh['white'].setValue('green') sh['red2'].setValue('blue') if 'rgba.alpha' in r.channels(): sh['green2'].setValue('alpha') else: sh['green2'].setValue('alpha2') sh['label'].setValue('[value out2]') #add to array priorShuffle=sh nodes.append(r) task.setProgress( int( float(p) / len(uniqueNames) *100) ) #avoid consolidate if not lighting pass reads if 'direct_specular.red' in sh.channels(): c=consolidateChannels(sh,['direct_specular','direct_specular_2'],'spec') sh=consolidateChannels(c,['indirect_specular','indirect_specular2','indirect_specular_2'],'indirect_spec') #create combined asset mattes sh=buildAssetMattes(sh) sh2=sh #add startRGBA channel sh=nuke.nodes.Shuffle() sh['in'].setValue('rgba') nuke.tcl('add_layer { '+'startRGBA'+' '+'startRGBA'+'.red '+'startRGBA'+'.green '+'startRGBA'+'.blue '+'startRGBA'+'.alpha}') sh['out'].setValue('startRGBA') sh.setInput(0,sh2) nuke.toNode('Output1').setInput(0,sh) nuke.toNode('Output1').setXYpos(sh.xpos(),sh.ypos()+80) createReadGroup(n,grp) del(task) grp['postage_stamp'].setValue(1) grp.knobs()['User'].setLabel("MultiChannelRead") file=grp['file'].value() fName=file.split('/')[-1].split('.')[0] regex = re.compile("v[0-9]{2,9}") vers=regex.findall(file)[0] grp['label'].setValue(fName+'\n'+vers) grp.setXYpos(thisNode.xpos(),thisNode.ypos()) #reconnect to old group connections connections=getConnections(thisNode) for c in connections.keys(): nuke.toNode(c).setInput(connections[c],grp) nuke.delete(thisNode) #using 'scripts' in call because 'scripts' is currently called during import of all script files pyButtonLatest = nuke.PyScript_Knob('updateVersion', "updateToLatest", "mlScripts.arnoldGatherBty.updateLatest()") pyButtonLatest.setFlag(nuke.STARTLINE) pyButtonUp = nuke.PyScript_Knob('verionUp', "versionUp", "mlScripts.arnoldGatherBty.versionUp()") pyButtonDown = nuke.PyScript_Knob('verionDown', "versionDown", "mlScripts.arnoldGatherBty.versionDown()") grp.addKnob(pyButtonLatest) grp.addKnob(pyButtonUp) grp.addKnob(pyButtonDown) nuke.selectAll() nuke.invertSelection()