Duplicate Read Destroyer

Removes superfluous Read nodes sharing duplicate knob values (optionally filtered by name regex). Replaces them with shaded PostageStamp nodes with hidden inputs.

Updated: 24 August 2011

Author: nathan.rusch

Compatible Nuke versions: 5.1 or later

Compatibility: Linux, Mac, Windows

Duplicate Read Destroyer

Module containing classes for facilitating the removal of duplicate Read nodes based on a user-specified set of knobs to check. From every set of duplicates, the node highest vertically in the DAG is preserved, while the other duplicates are replaced with shaded PostageStamp nodes referencing the remaining copy, with hidden inputs.

Recently rewritten as a class-based system. The worker class is designed to deal primarily with Read nodes, but it contains a static method that can be used to de-duplicate any list of nodes (of any class) by any list of knob names.

Using the DupReadDestroyer class Basic usage

This is the main class, designed to ease in the removal of duplicate Read nodes. The simplest use case is as follows:

1
2
3
import dupReadDestroy
 
dupReadDestroy.DupReadDestroyer().destroy()

This will prompt the user for a set of criteria to use, including:
1) whether to operate on all Read nodes or the currently selected Reads,
2) whether to further filter the resulting node list by testing the node names against a user-specified regular expression, and
3) which knobs to consider when deciding which nodes are duplicates of each other.

DupReadDestroyGUI

Note: Only nodes whose values for all specified knobs match each other are considered duplicates. Extended usage

The worker class will accept keyword arguments for whether to use selected nodes (False by default) and what context to pick the nodes from (nuke.root() by default), as well as an arbitrary set of keyword arguments corresponding to the knob names you wish to use and the regex pattern to filter by:

1
2
3
4
import dupReadDestroy
 
d = dupReadDestroy.DupReadDestroyer(__regex='^HeroRead_\d+$', file=True, colorspace=True)
d.destroy()

This makes it easy to cross-call the de-duplication class from other scripts without having to deal with user interaction. This invocation is also required if Nuke is running in non-GUI mode; an exception will be raised if an instance is constructed without any keyword arguments in a terminal session.

Bypassing class instantiation

If you don't want to deal with class instances, things can be simplified even further using the DupReadDestroyer class' static 'processNodes' method. This simply takes a list of nodes and a list of knob names and de-duplicates the nodes accordingly. In theory, this can be used on any node class, though the cases in which that could be useful are most likely few and far between.

1
2
3
import dupReadDestroy
 
dupReadDestroy.DupReadDestroyer.processNodes(nuke.allNodes('Read'), ['file', 'colorspace'])

Sign in or register to download or rate.