wtorek, 12 marca 2013

Update: How to Shuffle out passes from EXR in nuke FAST

Here is a simple script for Nuke that "Shuffle" out passes from your exr files.
Execute on selected "Read" node to get it work.
@Update
I've updated the script with a UI. Now it is available from the top menu.
###### gru_NK_Read2Shuffle.py ######
import nuke, os

def Read2Shuffle():
    sel = nuke.selectedNodes('Read')
    for file in sel:
        #gets the READ path 
       path = file.knob("file").getValue()
       print path
          
       ch = file.channels()
       # sets passes names
       pas = list( set([channel.split('.')[0] for channel in ch]) )
       pas.sort()
       print pas 
       #create Shuffle nodes
       for p in pas:
           shuffleNode = nuke.nodes.Shuffle(label = p, inputs=[file])
           shuffleNode['in'].setValue(p)
           shuffleNode['postage_stamp'].setValue(True)
           
###### init.py file ######
# nuke.pluginAddPath('./python')
           
###### menu.py #######
# import gru_NK_Read2Shuffle
# menubar = nuke.menu( 'Nuke' )
# gruMenu = menubar.addMenu( "gru" )
# gruMenu.addCommand( 'gru/exr_Read2Shuffle', 'gru_NK_Read2Shuffle.Read2Shuffle()')
Installation:
Posted code is divided to sections which you have to place in specific files.
All files have to be placed in ~/.nuke directory.
Script should work on Windows too.