SHARE
TWEET

[nuke] get all reads in a nuke script and put them in a pane

throb Nov 26th, 2011 192 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import nuke
  2. def showReads ():
  3.     """
  4.    This panel gives you the number of reads that are either selected or in the entire script.
  5.    Additionally, it tells you the path of either selected nodes or all read nodes.
  6.    """
  7.     reads = []
  8.     readfiles = []
  9.     nodes = nuke.selectedNodes('Read')
  10.     if len(nodes) < 1:
  11.         nodes = nuke.allNodes('Read')
  12.    
  13.     for node in nodes:
  14.         if nuke.filename(node) not in readfiles:
  15.             reads.append ({'file':nuke.filename(node),'start':node['first'].value(),'end':node['last'].value()})
  16.             readfiles.append (nuke.filename(node))
  17.            
  18.    
  19.     read = ''
  20.     output = ''
  21.     x = 0
  22.     for read in reads:
  23.         x = x + 1
  24.         output = '%s%s %d-%d\n' % (output, read['file'], int(read['start']), int(read['end']))
  25.    
  26.     p = nuke.Panel('Read Paths', setWidth=650)
  27.    
  28.     p.addSingleLineInput('Script Name:',  nuke.root()['name'].value())
  29.     p.addMultilineTextInput ('Paths:',output)
  30.     p.addSingleLineInput ('Total Selected:', x)
  31.  
  32.     p.setWidth(1000)
  33.     p.show()
  34.  
RAW Paste Data
Top