MultiChannelSplit_v03 v3.0
This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: Simon Jokuschies
MultiChannelSplit shuffles and autocroppes each layer individually. Shuffle out all layers or just individual layers. Option to prepare for outout - create and set up write nodes and create render directories automatically
Requirements:
8.0, 7.1, 7.0, 6.3 or later
Linux, Mac, Windows
8.0, 7.1, 7.0, 6.3 or later
Linux, Mac, Windows
26 Nov 2014
1839
MultiChannelSplit shuffles and autocroppes each layer individually. Shuffle out all layers or just individual layers. Option to prepare for outout - create and set up write nodes and create render directories automatically.
Just select the node from which you like to shuffle out and press alt+m or go to scripts->MultiChannelSplit
Demo video: https://www.youtube.com/watch?v=-Zl0uI0nxn8
Further information: http://www.leafpictures.de/MultiChannelSplit
Instal: Download MultiChannelSplit and put it in your nuke home directory. In your init.py write:
nuke.pluginAddPath('MultiChannelSplit')
Please login in order to download these files.
Comments
import nuke
import MultiChannelSplit
nuke.menu("Nuke").addCommand('Scripts/MultiChannelSplit', 'MultiChannelSp lit.MultiChanne lSplit()', 'alt+m')
1. open the MultiChannelSplit.py
2. replace print to print() in line51, line54
As follows,
print("created dir at %s" % path)
print("could not created dir at %s" % path)
3.Save
Done
could you share please ?
#################################################################
# MultiChannelSpl it
#
# @author simon jokuschies
# @email infoleafpictures.de
# @version 3.0
#
# description:
# the script splits a multichannel exr into single layers
# and autocrops them automatically.
#
# instalation
#
# put whole MultiChannelSpl it folder in nuke home directory
# in your init.py write this lines (without #) :
#
# nuke.pluginAddPath("MultiChannelSpl it")
#
#################################################################
#no need to change anything from here. Edit only if you exactly know what you're doing.
import nuke
import nukescripts
import os,sys
def getUniqueChanne lLayerList(read Node):
'''
return all channel layer that are included in the selected read node
return: string-array
'''
#function that returns unique channel layers
rawChannelList = readNode.channe ls()
channelLayerLis t = []
for channel in rawChannelList:
channelLayer = channel.split(" .")
channelLayerLis t.append(channelLayer[0])
channelLayerLis t = list(set(channelLayerLis t))
channelLayerLis t.sort()
return channelLayerLis t
def createFolders(p ath):
'''
create folder if not exist
return true if suceeded, false otherwise
'''
if not os.path.isdir(p ath):
try:
os.makedirs(pat h)
print("created dir at %s" % path)
return True
except:
print("could not created dir at %s" % path)
return False
class MultiChannelSpl itPanel(nukescripts.PythonPanel):
'''
MultiChannelSpl itPanel
'''
def __init__( self ):
'''
init values
'''
global uniqueLayers
global layerCheckboxes
global panelHeight
panelHeight = 160
nukescripts.Pyt honPanel.__init __(self, "MultichannelSp lit", "MultiChannelSpl it")
self.setMinimum Size(450,panelH eight)
self.autoCrop = nuke.Boolean_Kn ob("autoCrop"," autocrop",0.0)
self.autoCrop.s etFlag(nuke.STA RTLINE)
self.prepareFor Output = nuke.Boolean_Kn ob("prepareForO utput","prepare for output",0.0)
self.prepareFor Output.setFlag(nuke.STARTLINE)
self.outputPath = nuke.File_Knob( 'outputPath', 'output path')
self.outputPath .setVisible(Fal se)
self.div=nuke.T ext_Knob("","", "")
self.which=nuke .Enumeration_Kn ob("which","",[ "all AOVs","individu al AOVs"])
self.addKnob(se lf.autoCrop)
self.addKnob(self.prepareFor Output)
self.addKnob(se lf.outputPath)
self.addKnob(se lf.div)
self.addKnob(se lf.which)
#layer checkboxes
uniqueLayers = getUniqueChanne lLayerList(nuke .selectedNode() )
layerCheckboxes = []
self.allLayer = nuke.Script_Kno b("allLayer", "select all")
self.allLayer.s etVisible(False )
self.noLayer = nuke.Script_Kno b("noLayer", "deselect all")
self.noLayer.se tVisible(False)
self.div2=nuke. Text_Knob("","a vailable AOVs","")
self.div2.setVi sible(False)
self.addKnob(se lf.div2)
self.addKnob(se lf.allLayer)
self.addKnob(se lf.noLayer)
for layer in uniqueLayers:
self.layer = nuke.Boolean_Kn ob(layer,layer, 0)
self.layer.setF lag(nuke.STARTL INE)
self.layer.setV isible(False)
self.addKnob(se lf.layer)
layerCheckboxes .append(self.la yer)
self.div3=nuke. Text_Knob("","" ,"")
self.addKnob(se lf.div3)
def show( self ):
'''
action performed when pressed ok
'''
if nukescripts.Pyt honPanel.showMo dalDialog(self) :
def multiChannelSpl it():
'''
main function
split the selected read node in separate channel layers
if set create separate folders and write nodes
'''
sel = nuke.selectedNo de()
shuffles=[]
renderTo=""
autocropNodeRGB _exists=False
cropNode=None
dot=None
if sel != None:
#main procedure
#create shuffle, shuffle channel in, curvetool crop, create cropnode and paste that information in, delete crop node
o=0;
if self.autoCrop.g etValue()==1.0:
curveNode = nuke.nodes.Curv eTool(name="Aut ocrop_Master", inputs = [sel], operation="Auto Crop")
curveNode["chan nels"].setValue ("rgba")
curveNode.knob( "ROI").setValue ([0,0,sel.width (),sel.height() ])
nuke.execute(cu rveNode, sel.knob("first ").value(), sel.knob("last" ).value())
layersToProcess =[]
if self.which.getV alue()== 0.0:
layersToProcess = uniqueLayers
else:
for layer in layerCheckboxes :
if layer.getValue( )==True:
layersToProcess .append(layer.n ame())
if len(layersToPro cess)>0:
dot = nuke.createNode ("Dot", inpanel=False)
for channelLayer in layersToProcess :
shuffleNode = nuke.nodes.Shuf fle(name="Shuff le_"+channelLay er)
shuffles.append (shuffleNode.na me())
shuffleNode.kno b("in").setValu e(channelLayer)
shuffleNode["hi de_input"].setV alue(True)
shuffleNode.set Input(0,sel)
shuffleNode["xp os"].setValue(s el["xpos"].getV alue()+(o*100))
shuffleNode["yp os"].setValue(s el["ypos"].getV alue()+150)
shuffleNode.set Input(0,dot)
shuffleNode["po stage_stamp"].s etValue(True)
#auto crop if selected
if self.autoCrop.g etValue()==1.0:
if autocropNodeRGB _exists==False:
cropNode = nuke.nodes.Crop (name=channelLa yer, inputs = [shuffleNode])
cropNode.knob(" hide_input").se tValue(True)
cropNode.knob(" box").copyAnima tions(curveNode .knob("autocrop data").animatio ns())
nuke.delete(cur veNode)
cropNode.knob(" postage_stamp") .setValue(True)
cropNode.setXpo s(int(shuffleNo de["xpos"].getV alue()))
cropNode.setYpo s(int(shuffleNo de["ypos"].getV alue()+80))
shuffleNode["hi de_input"].setV alue(False)
cropNode["hide_ input"].setValu e(True)
nukescripts.cle ar_selection_re cursive()
cropNode["selec ted"].setValue( True)
nuke.nodeCopy(" %clipboard%")
autocropNodeRGB _exists=True
shuffleNode["po stage_stamp"].s etValue(False)
cropNode["posta ge_stamp"].setV alue(True)
else:
cropCopy = nuke.nodePaste( "%clipboard%")
cropCopy["name" ].setValue(chan nelLayer)
cropCopy.setInp ut(0,shuffleNod e)
cropCopy.setXpo s(int(shuffleNo de["xpos"].getV alue()))
cropCopy.setYpo s(int(shuffleNo de["ypos"].getV alue()+80))
#create folders for all layer and create write node for every shuffle
if self.outputPath .getValue()!="" :
renderTo = self.outputPath .getValue()
#createFolder
createFolders(r enderTo+"/"+cha nnelLayer)
#create write node
write = nuke.nodes.Writ e()
write.knob("fil e_type").setVal ue("exr")
write.knob("fil e").setValue(re nderTo+channelL ayer+"/"+channe lLayer+"_%04d.e xr")
write.knob("com pression").setV alue("Zip (16 scanlines)")
write.knob("cha nnels").setValu e("rgba")
if self.autoCrop.g etValue()==True :
write.setInput( 0,cropNode)
else:
write.setInput( 0,shuffleNode)
o+=1
if len(layersToPro cess)>0:
nuke.delete(dot )
#hide all created shuffle inputs
for shuffleNode in shuffles:
if self.autoCrop.g etValue()==1.0:
temp = nuke.toNode(shu ffleNode)
temp.knob("hide _input").setVal ue(True)
temp.knob("post age_stamp").set Value(True)
else:
pass
multiChannelSpl it()
def knobChanged( self, knob ):
'''
panel knob changed actions
'''
if knob.name() == "prepareForOutp ut":
if self.prepareFor Output.getValue() == 1.0:
self.outputPath .setVisible(Tru e)
self.setMinimum Size(450,panelH eight+50)
else:
self.outputPath .setVisible(Fal se)
self.setMaximum Size(450,panelH eight)
if knob.name() == "allLayer":
for layer in layerCheckboxes :
layer.setValue( 1.0)
if knob.name() == "noLayer":
for layer in layerCheckboxes :
layer.setValue( 0.0)
if knob.name() == "which":
if self.which.getV alue()==1.0:
self.setMinimum Size(450,panelH eight + (len(layerCheck boxes) * 25))
self.allLayer.s etVisible(True)
self.noLayer.se tVisible(True)
self.div2.setVi sible(True)
for layer in layerCheckboxes :
layer.setVisibl e(True)
else:
self.setMaximum Size(450,panelH eight)
self.setMinimum Size(450,panelH eight)
self.allLayer.s etVisible(False )
self.noLayer.se tVisible(False)
self.div2.setVi sible(False)
for layer in layerCheckboxes :
layer.setVisibl e(False)
def MultiChannelSpl it():
'''
execute main
'''
MultiChannelSpl itPanel().show()
import nuke
import MultiChannelSplit
nuke.menu("Nuke").addCommand('Scripts/MultiChannelSplit', 'MultiChannelSp lit.MultiChanne lSplit()', 'alt+m')
c:\Users\YOUR USER\.nuke\MultiChannelSplit\
Structure of files need to be:
menu.py
MultichannelSplit.py
MultichannelSplit.pyc
and folder wih name "__pycache__" with files: MultiChannelSpl it.cpython-37.p yc and MultiChannelSpl it.cpython-39.p yc ...
As others have commented, you need to fix the MultiChannelSpl it.py per these instructions:
replace print to print() in line51, line54
As follows,
print("created dir at %s" % path)
print("could not created dir at %s" % path)
The meny.py is fine as-is.
Placing the entire MultiChannelSpl it folder in C:\Users\YOURNA ME\.nuke is where things weren't working for me.
I copied all 3 individual files from within the MultiChannelSpl it folder to my \.nuke directory and the lights turned on.
Give it a shot, you might get lucky.
RSS feed for comments to this post