try:
fromNode = nuke.selectedNode()
fromnode = nuke.selectedNode()
channels = fromnode.channels()
channels = list( set([channel.split('.')[0] for channel in channels]) )
channels.sort()
channelstring = ''
for channel in channels:
if channel != 'rgba':
channelstring += channel + ' '
panel = nuke.Panel('Choose AOV')
panel.addEnumerationPulldown('AOV', channelstring)
panel.show()
aov = panel.value('AOV')
if aov is not None:
dot = nuke.nodes.Dot()
dot.setInput(0, fromNode)
dot['xpos'].setValue(fromNode.xpos()+ fromNode.screenWidth()/2 - dot.screenWidth()/2)
dot['ypos'].setValue(fromNode.ypos()+300)
shuffle = nuke.nodes.Shuffle()
shuffle.setInput(0, dot)
shuffle['in'].setValue(aov)
shuffle['postage_stamp'].setValue(True)
shuffle['xpos'].setValue(dot.xpos() + 500)
shuffle['ypos'].setValue(dot.ypos()- 33)
seconddot = nuke.nodes.Dot()
seconddot.setInput(0, shuffle)
seconddot['xpos'].setValue(shuffle.xpos() + 34)
seconddot['ypos'].setValue(shuffle.ypos() + 100)
thirddot = nuke.nodes.Dot()
thirddot.setInput(0, seconddot)
thirddot['xpos'].setValue(shuffle.xpos() + 34)
thirddot['ypos'].setValue(shuffle.ypos() + 600)
fromMerge = nuke.nodes.Merge2()
fromMerge['operation'].setValue('from')
fromMerge.setInput(0, dot)
fromMerge.setInput(1, seconddot)
fromMerge['xpos'].setValue(dot.xpos()-34)
fromMerge['ypos'].setValue(seconddot.ypos()-4)
plusMerge = nuke.nodes.Merge2()
plusMerge['operation'].setValue('plus')
plusMerge.setInput(1, thirddot)
plusMerge.setInput(0, fromMerge)
plusMerge['xpos'].setValue(dot.xpos()-34)
plusMerge['ypos'].setValue(thirddot.ypos()-4)
backdrop = nuke.nodes.BackdropNode(bdwidth=700, bdheight=750)
backdrop['xpos'].setValue(dot.xpos()-60)
backdrop['ypos'].setValue(dot.ypos()-100)
backdrop['label'].setValue(aov)
backdrop['note_font_size'].setValue(35)
try:
outputNode = fromNode.dependent()
if outputNode[0].Class() == 'Viewer':
outputNode = outputNode[1]
else:
outputNode = outputNode[0]
for i in range(outputNode.maxInputs()):
if outputNode.input(i) == fromNode:
index = i
outputNode.setInput(index, plusMerge)
except:
pass
except:
pass