It’s common enough that I find myself trying to fix a render issue and not knowing whether I’ve been given a mask or separate pass that would help. When this happens I find myself trudging back up through the tree looking for my read to check it’s layer contact sheet and see what I’ve got to work with. Apparently I wasn’t the only one bothered by this as someone asked me to make a script to make it easier. So, this is a very simple function that will allow you to quickly cycle through all LayerContactSheets in the tree.
Download from here.
To install, simply drop the file in your plugin path, and add the following lines to your menu.py
import cycleContactSheet # Adds the create exr cam script to the toolbar and adds a shortcut nuke.menu( 'Nuke' ).addCommand( 'MatteHue/Cycle LayerContactSheets', 'cycleContactSheet.cycleContactSheet()', "0")
You can change the menu name from MatteHue to whatever name you’d prefer. The hotkey I used is simply the number 0, as it’s unlikely you’ll be using 10 different views simultaneously, and it’s quick and easy to remember.
There really isn’t much to say on this one so it’ll be quick.
options = nuke.allNodes('LayerContactSheet') if not options: return viewer = nuke.activeViewer().node() idx = 0
You can quickly get all nodes of one class type by using the class name as a filter when using nuke.allNodes. This returns a list of the nodes, ordered from the most recent to have been changed, to the oldest. This includes any basic interaction, even selection. As such, if you do go and select a LayerContactSheet while cycling, you’ll likely reorder them, but there isn’t much point in doing that once you have the script!
If there aren’t any LayerContactSheets in the scene, it will simply exit out. Most importantly, we need to get the node for the currently active Viewer. The idx variable is going to be the index for the LayerContactSheet from our options list. By default, we’ll want the first item so we leave it at 0.
try: node = viewer.input(9) except ValueError: node = None
We’ll try grab whatever node is in the 10th input for the current viewer. If there isn’t one already there, we’ll simply grab None without breaking anything.
if node: idx = options.index(node) idx = (idx + 1)%len(options)
If there is a node in the input, we’ll assume it’s one of our LayerContactSheets. If you do regularly use the 10th input, then you may want to add a check (simply make sure the node is the right class) to make sure it doesn’t do anything silly here, but as that’s far beyond the limit we’ve needed I’ve not included it. Now, we simply get it’s position in the list of options and increase it by 1, wrapping back to 0 if we exceed the length of the list.
viewer.setInput(9, options[idx]) nuke.activeViewer().activateInput(9)
Finally, we set the 10th input for our current viewer to the chosen node, and make sure it’s active in the viewport. Setting the input alone won’t switch view unless you were already looking at the 10th input, hence the last line which switches it over. Et voila, simple. Now you can tap away at 0 to quickly see what layers are in your render and then jump back to your regular views without any effort.