nuke.Root

class nuke.Root

Bases: Group

Methods

Class

return:

Class of node.

addCallback

Specific callback type can be find in the documentation of the related type or function.

addKnob

Add knob k to this node or panel.

addView

Add view.

allKnobs

Get a list of all knobs in this node, including nameless knobs.

autoplace

Automatically place nodes, so they do not overlap.

bbox

Bounding box of the node.

begin

All python code that follows will be executed in the context of node.

canSetInput

Check whether the output of 'node' can be connected to input i.

channels

Class method.

clearCallbacks

clearCustomIcon

Clear the custom icon set for the node.

clones

return:

Number of clones.

connectInput

Connect the output of 'node' to the i'th input or the next available unconnected input.

connectSelectedNodes

Connect the selected nodes.

deepSample

Return pixel values from a deep image.

deepSampleCount

Return number of samples for a pixel on a deep image.

deleteView

Delete view.

dependencies

List all nodes referred to by this node. 'what' is an optional integer (see below). You can use the following constants or'ed together to select what types of dependencies are looked for: nuke.EXPRESSIONS = expressions nuke.LINKINPUTS = link knobs nuke.INPUTS = visible input pipes nuke.HIDDEN_INPUTS = hidden input pipes. The default is to look for all types of connections.

dependent

List all nodes that read information from this node. 'what' is an optional integer:

end

All python code that follows will no longer be executed in the context of node.

error

True if the node or any in its input tree have an error, or False otherwise.

executePythonCallback

self.executeCallback(string) -> Executes the callback, if exists related to the specified event.

expand

Moves all nodes from the group node into its parent group, maintaining node input and output connections, and deletes the group.

fileDependencies

param start:

first frame

firstFrame

First frame.

forceUpdateLocalization

return:

None

forceValidate

Force the node to validate itself, updating its hash.

format

Format of the node.

fps

Return the FPS rounded to an int.

frameRange

Frame range for this node.

fullName

Get the name of this node and any groups enclosing it in 'group.group.name' form.

getNumKnobs

self.numKnobs() -> The number of knobs.

getOCIOColorspaceFamily

Gets the name of the family to which the specified colorspace belongs, for the root node's current OCIO config.

getOCIOColorspaceFromViewTransform

Gets the name of the colorspace to which the specified display and view names are mapped for the root node's current OCIO config.

hasError

True if the node itself has an error, regardless of the state of the ops in its input tree, or False otherwise.

height

Height of the node.

help

return:

Help for the node.

hideControlPanel

return:

None

input

param i:

Input number.

inputs

return:

Number of the highest connected input + 1. If inputs 0, 1, and 3 are connected, this will return 4.

isCloneable

return:

True if the node allows cloning, False otherwise.

isLocalizationOutdated

return:

true if the Localization source file has changed

isLocalized

return:

bool

isSelected

Returns the current selection state of the node.

knob

param p:

A string or an integer.

knobs

Get a dictionary of (name, knob) pairs for all knobs in this node.

lastFrame

Last frame.

layers

Class method.

linkableKnobs

Returns a list of any knobs that may be linked to from the node as well as some meta information about the knob.

localizationProgress

return:

float, between 0.0 (not localized) and 1.0 (localized)

lock

locked

maxInputs

self.maximumInputs() -> Maximum number of inputs this node can have.

maxOutputs

self.maximumOutputs() -> Maximum number of outputs this node can have.

maximumInputs

return:

Maximum number of inputs this node can have.

maximumOutputs

return:

Maximum number of outputs this node can have.

mergeFrameRange

Merge frame range.

metadata

Return the metadata item for key on this node at current output context, or at optional time and view.

minInputs

self.minimumInputs() -> Minimum number of inputs this node can have.

minimumInputs

return:

Minimum number of inputs this node can have.

modified

Get or set the 'modified' flag in a script :return: True if modified, False otherwise.

name

return:

Name of node.

node

Locate a node by name.

nodes

List of nodes in group.

numKnobs

return:

The number of knobs.

numNodes

Number of nodes in group.

opHashes

Returns a list of hash values, one for each op in this node.

optionalInput

return:

Number of first optional input.

output

Return output node of group.

parent

performanceInfo

@category: performance category ( optional ).A performance category, must be either nuke.PROFILE_STORE, nuke.PROFILE_VALIDATE, nuke.PROFILE_REQUEST or nuke.PROFILE_ENGINE The default is nuke.PROFILE_ENGINE which gives the performance info of the render engine.

pixelAspect

Pixel Aspect ratio of the node.

proxy

return:

True if proxy is set, False otherwise.

readKnobs

Read the knobs from a string (TCL syntax).

realFps

The global frames per second setting.

redraw

Force a redraw of the node.

removeCallback

removeKnob

Remove knob k from this node or panel.

resetKnobsToDefault

Reset all the knobs to their default values.

rootNode

run

Execute in the context of node.

running

Class method.

sample

Return pixel values from an image.

screenHeight

Height of the node when displayed on screen in the DAG, at 1:1 zoom, in pixels.

screenWidth

Width of the node when displayed on screen in the DAG, at 1:1 zoom, in pixels.

selectOnly

Set this node to be the only selection, as if it had been clicked in the DAG.

selectedNode

Returns the node the user is most likely thinking about.

selectedNodes

Selected nodes.

setCustomIcon

Set a custom icon for the node.

setFrame

Set frame.

setInput

Connect input i to node if canSetInput() returns true.

setModified

Set the 'modified' flag in a script.

setName

Set name of the node and resolve name collisions if optional named argument 'uncollide' is True.

setProxy

Set proxy.

setSelected

Set the selection state of the node.

setTab

param tabIndex:

The tab to show (first is 0).

setView

Set view.

setXYpos

Set the (x, y) position of node in node graph.

setXpos

Set the x position of node in node graph.

setYpos

Set the y position of node in node graph.

showControlPanel

param forceFloat:

Optional python object. If it evaluates to True the control panel will always open as a floating panel. Default is False.

showInfo

Creates a dialog box showing the result of script s.

shown

return:

true if the properties panel is open. This can be used to skip updates that are not visible to the user.

splaySelectedNodes

Splay the selected nodes.

subgraphLocked

treeHasError

True if the node or any in its input tree have an error, or False otherwise.

unlock

upstreamFrameRange

Frame range for the i'th input of this node.

width

Width of the node.

writeKnobs

Return a tcl list.

xpos

return:

X position of node in node graph.

ypos

return:

Y position of node in node graph.

Class() Class of node.
Returns:

Class of node.

addCallback(string, Callable) Add a callback to a specific event

Specific callback type can be find in the documentation of the related type or function.

addKnob(k) None.

Add knob k to this node or panel. :param k: Knob. :return: None.

addView(name, color) None.

Add view. :param name: String - name of view. :param color: Optional. String in the format #RGB, #RRGGBB, #RRRGGGBBB, #RRRRGGGGBBBB or a name from the list of colors defined in the list of SVG color keyword names. :return: None.

allKnobs() list

Get a list of all knobs in this node, including nameless knobs.

For example:

>>> b = nuke.nodes.Blur()
>>> b.allKnobs()
Returns:

List of all knobs.

Note that this doesn’t follow the links for Link_Knobs

autoplace() None.

Automatically place nodes, so they do not overlap. :return: None.

bbox() List of x, y, w, h.

Bounding box of the node. :return: List of x, y, w, h.

begin() Group.

All python code that follows will be executed in the context of node. All names are evaluated relative to this object. Must be paired with end. :return: Group.

canSetInput(i, node) bool

Check whether the output of ‘node’ can be connected to input i. :param i: Input number. :param node: The node to be connected to input i. :return: True if node can be connected, False otherwise.

channels() Channel list.

Class method. :return: Channel list.

clearCallbacks() Remove all callbacks on the node.
clearCustomIcon() None.

Clear the custom icon set for the node. :return: None.

clones() Number of clones.
Returns:

Number of clones.

connectInput(i, node) bool

Connect the output of ‘node’ to the i’th input or the next available unconnected input. The requested input is tried first, but if it is already set then subsequent inputs are tried until an unconnected one is found, as when you drop a connection arrow onto a node in the GUI. :param i: Input number to try first. :param node: The node to connect to input i. :return: True if a connection is made, False otherwise.

connectSelectedNodes(backward, inputA) None.

Connect the selected nodes. :param backward. :param inputA. :return: None.

deepSample(c, x, y, n) Floating point value.

Return pixel values from a deep image. This requires the image to be calculated, so performance may be very bad if this is placed into an expression in a control panel. :param c: Channel name. :param x: Position to sample (X coordinate). :param y: Position to sample (Y coordinate). :param n: Sample index (between 0 and the number returned by deepSampleCount() for this pixel, or -1 for the frontmost). :return: Floating point value.

deepSampleCount(x, y) Integer value.

Return number of samples for a pixel on a deep image. This requires the image to be calculated, so performance may be very bad if this is placed into an expression in a control panel. :param x: Position to sample (X coordinate). :param y: Position to sample (Y coordinate). :return: Integer value.

deleteView(s) None.

Delete view. :param s: Name of view. :return: None.

dependencies(what) List of nodes.

List all nodes referred to by this node. ‘what’ is an optional integer (see below). You can use the following constants or’ed together to select what types of dependencies are looked for:

nuke.EXPRESSIONS = expressions nuke.LINKINPUTS = link knobs nuke.INPUTS = visible input pipes nuke.HIDDEN_INPUTS = hidden input pipes.

The default is to look for all types of connections.

Example: nuke.toNode(‘Blur1’).dependencies( nuke.INPUTS | nuke.EXPRESSIONS ) :param what: Or’ed constant of nuke.EXPRESSIONS, nuke.INPUTS and nuke.HIDDEN_INPUTS to select the types of dependencies. The default is to look for all types of connections. :return: List of nodes.

dependent(what, forceEvaluate) List of nodes.
List all nodes that read information from this node. ‘what’ is an optional integer:
You can use any combination of the following constants or’ed together to select what types of dependent nodes to look for:

nuke.EXPRESSIONS = expressions nuke.LINKINPUTS = link knobs nuke.INPUTS = visible input pipes nuke.HIDDEN_INPUTS = hidden input pipes.

The default is to look for all types of connections.

forceEvaluate is an optional boolean defaulting to True. When this parameter is true, it forces a re-evaluation of the entire tree. This can be expensive, but otherwise could give incorrect results if nodes are expression-linked.

Example: nuke.toNode(‘Blur1’).dependent( nuke.INPUTS | nuke.EXPRESSIONS ) :param what: Or’ed constant of nuke.EXPRESSIONS, nuke.INPUTS and nuke.HIDDEN_INPUTS to select the types of dependent nodes. The default is to look for all types of connections. :param forceEvaluate: Specifies whether a full tree evaluation will take place. Defaults to True. :return: List of nodes.

end() None.

All python code that follows will no longer be executed in the context of node. Must be paired with begin. :return: None.

error() bool

True if the node or any in its input tree have an error, or False otherwise.

Error state of the node and its input tree. Deprecated; use hasError or treeHasError instead. Note that this will always return false for viewers, which cannot generate their input trees. Instead, choose an input of the viewer (e.g. the active one), and call treeHasError() on that.

executePythonCallback()

self.executeCallback(string) -> Executes the callback, if exists related to the specified event.

expand() None.

Moves all nodes from the group node into its parent group, maintaining node input and output connections, and deletes the group. Returns the nodes that were moved, which will also be selected. :return: None.

fileDependencies(start, end) List of nodes and filenames.
Parameters:
  • start – first frame

  • end – last frame

Returns the list of input file dependencies for this node and all nodes upstream from this node for the given frame range. The file dependencies are calcuated by searching for Read ops or ops with a File knob. All views are considered and current proxy mode is used to decide on whether full format or proxy files are returned. Note that Write nodes files are also included but precomps, gizmos and external plugins are not. Any time shifting operation such as frameholds, timeblurs, motionblur etc are taken into consideration. :return The return list is a list of nodes and files they require. Eg. [Read1, [‘file1.dpx, file2.dpx’] ], [Read2, [‘file3.dpx’, ‘file4.dpx’] ] ]

firstFrame() Integer.

First frame. :return: Integer.

forceUpdateLocalization() Force Updates the localized files for this node.
Returns:

None

forceValidate() None

Force the node to validate itself, updating its hash.

format() Format.

Format of the node. :return: Format.

fps() integer

Return the FPS rounded to an int. This is deprecated. Please use real_fps().

frameRange() FrameRange.

Frame range for this node. :return: FrameRange.

fullName() str

Get the name of this node and any groups enclosing it in ‘group.group.name’ form. :return: The fully-qualified name of this node, as a string.

getNumKnobs()

self.numKnobs() -> The number of knobs. :return: The number of knobs.

getOCIOColorspaceFamily(colorspace) Family of colorspace

Gets the name of the family to which the specified colorspace belongs, for the root node’s current OCIO config. :param colorspace: Colorspace name. :return: Family name, may be an empty string.

getOCIOColorspaceFromViewTransform(display, view) Colorspace name

Gets the name of the colorspace to which the specified display and view names are mapped for the root node’s current OCIO config. :param display: Display name. :param view: View name. :return: The corresponding colorspace name.

hasError() bool

True if the node itself has an error, regardless of the state of the ops in its input tree, or False otherwise.

Error state of the node itself, regardless of the state of the ops in its input tree. Note that an error on a node may not appear if there is an error somewhere in its input tree, because it may not be possible to validate the node itself correctly in that case.

height() int.

Height of the node. :return: int.

help() str
Returns:

Help for the node.

hideControlPanel() None
Returns:

None

input(i) The i'th input.
Parameters:

i – Input number.

Returns:

The i’th input.

inputs() Gets the maximum number of connected inputs.
Returns:

Number of the highest connected input + 1. If inputs 0, 1, and 3 are connected, this will return 4.

isCloneable() If the node permits cloning.
Returns:

True if the node allows cloning, False otherwise.

isLocalizationOutdated() Returns if there are changes detected in the source file.
Returns:

true if the Localization source file has changed

isLocalized() returns True/False whether the node is completely localized.
Returns:

bool

isSelected() bool

Returns the current selection state of the node. This is the same as checking the ‘selected’ knob. :return: True if selected, or False if not.

knob(p[, follow_link]) The knob named p or the pth knob.
Parameters:
  • p – A string or an integer.

  • follow_link – Should it follow links to Link_Knob until resolution. Default is True.

Returns:

The knob named p or the pth knob.

knobs() dict

Get a dictionary of (name, knob) pairs for all knobs in this node.

For example:

>>> b = nuke.nodes.Blur()
>>> b.knobs()
Returns:

Dictionary of all knobs.

Note that this doesn’t follow the links for Link_Knobs

lastFrame() Integer.

Last frame. :return: Integer.

layers() Layer list.

Class method. :return: Layer list.

linkableKnobs(knobType) List

Returns a list of any knobs that may be linked to from the node as well as some meta information about the knob. This may include whether the knob is enabled and whether it should be used for absolute or relative values. Not all of these variables may make sense for all knobs.. :param knobType A KnobType describing the type of knobs you want.:return: A list of LinkableKnobInfo that may be empty .

localizationProgress() Checks and reports on progress of localization of the current node.
Returns:

float, between 0.0 (not localized) and 1.0 (localized)

lock() Sets the node to a locked state where knobs cannot be edited.
locked() Returns True if the node is locked, False otherwise.
maxInputs()

self.maximumInputs() -> Maximum number of inputs this node can have. :return: Maximum number of inputs this node can have.

maxOutputs()

self.maximumOutputs() -> Maximum number of outputs this node can have. :return: Maximum number of outputs this node can have.

maximumInputs() Maximum number of inputs this node can have.
Returns:

Maximum number of inputs this node can have.

maximumOutputs() Maximum number of outputs this node can have.
Returns:

Maximum number of outputs this node can have.

mergeFrameRange(a, b) None.

Merge frame range. :param a: Low-end of interval range. :param b: High-end of interval range. :return: None.

metadata(key, time, view) value or dict

Return the metadata item for key on this node at current output context, or at optional time and view. If key is not specified a dictionary containing all key/value pairs is returned. None is returned if key does not exist on this node. :param key: Optional name of the metadata key to retrieve. :param time: Optional time to evaluate at (default is taken from node’s current output context). :param view: Optional view to evaluate at (default is taken from node’s current output context). :return: The requested metadata value, a dictionary containing all keys if a key name is not provided, or None if the specified key is not matched.

minInputs()

self.minimumInputs() -> Minimum number of inputs this node can have. :return: Minimum number of inputs this node can have.

minimumInputs() Minimum number of inputs this node can have.
Returns:

Minimum number of inputs this node can have.

modified() True if modified, False otherwise.

Get or set the ‘modified’ flag in a script :return: True if modified, False otherwise.

name() str
Returns:

Name of node.

node(s) Node with name s or None.

Locate a node by name. :param s: A string. :return: Node with name s or None.

nodes() List of nodes

List of nodes in group. :return: List of nodes

numKnobs() The number of knobs.
Returns:

The number of knobs.

numNodes() Number of nodes

Number of nodes in group. :return: Number of nodes

opHashes() list of int

Returns a list of hash values, one for each op in this node.

optionalInput() Number of first optional input.
Returns:

Number of first optional input.

output() Node or None.

Return output node of group. :return: Node or None.

parent() Return the parent group node for this node.
performanceInfo(category) Returns performance information for this node. Performance timing must be enabled.

@category: performance category ( optional ).A performance category, must be either nuke.PROFILE_STORE, nuke.PROFILE_VALIDATE, nuke.PROFILE_REQUEST or nuke.PROFILE_ENGINE The default is nuke.PROFILE_ENGINE which gives the performance info of the render engine. :return: A dictionary containing the cumulative performance info for this category, where: callCount = the number of calls made timeTakenCPU = the CPU time spent in microseconds timeTakenWall = the actual time ( wall time ) spent in microseconds

pixelAspect() int.

Pixel Aspect ratio of the node. :return: float.

proxy() True if proxy is set, False otherwise.
Returns:

True if proxy is set, False otherwise.

readKnobs(s) None.

Read the knobs from a string (TCL syntax). :param s: A string. :return: None.

realFps() float

The global frames per second setting.

redraw() None.

Force a redraw of the node. :return: None.

removeCallback(string) Remove a callback to a specific event identified as a string.
removeKnob(k) None.

Remove knob k from this node or panel. Throws a ValueError exception if k is not found on the node. :param k: Knob. :return: None.

resetKnobsToDefault() None

Reset all the knobs to their default values.

rootNode() Returns this node's root node. This may differ from nuke.root() for example if the read node was created importing footage to the timeline.
run(callable) Result of callable.

Execute in the context of node. All names are evaluated relative to this object. :param callable: callable to execute. :return: Result of callable.

running() Node rendering when paralled threads are running or None.

Class method. :return: Node rendering when paralled threads are running or None.

sample(c, x, y, dx, dy) Floating point value.

Return pixel values from an image. This requires the image to be calculated, so performance may be very bad if this is placed into an expression in a control panel. Produces a cubic filtered result. Any sizes less than 1, including 0, produce the same filtered result, this is correct based on sampling theory. Note that integers are at the corners of pixels, to center on a pixel add .5 to both coordinates. If the optional dx,dy are not given then the exact value of the square pixel that x,y lands in is returned. This is also called ‘impulse filtering’. :param c: Channel name. :param x: Centre of the area to sample (X coordinate). :param y: Centre of the area to sample (Y coordinate). :param dx: Optional size of the area to sample (X coordinate). :param dy: Optional size of the area to sample (Y coordinate). :param frame: Optional frame to sample the node at. :return: Floating point value.

screenHeight() int.

Height of the node when displayed on screen in the DAG, at 1:1 zoom, in pixels. :return: int.

screenWidth() int.

Width of the node when displayed on screen in the DAG, at 1:1 zoom, in pixels. :return: int.

selectOnly() None.

Set this node to be the only selection, as if it had been clicked in the DAG. :return: None.

selectedNode() Node or None.

Returns the node the user is most likely thinking about. This is the last node the user clicked on, if it is selected. Otherwise it is an ‘output’ (one with no selected outputs) of the set of selected nodes. If no nodes are selected then None is returned. :return: Node or None.

selectedNodes() Node or None.

Selected nodes. :return: Node or None.

setCustomIcon(image, scale, offsetX, offsetY) bool.

Set a custom icon for the node. :param image: filepath to image to be used as an icon. :param scale: Optional. scale factor for the icon. :param offsetX: Optional. offset the icon in the x axis from the top left corner of the node. :param offsetY: Optional. offset the icon in the y axis from the top left corner of the node. :return: True if icon has been set, else false.

setFrame(n) None.

Set frame. :param n: Frame number. :return: None.

setInput(i, node) bool

Connect input i to node if canSetInput() returns true. :param i: Input number. :param node: The node to connect to input i. :return: True if canSetInput() returns true, or if the input is already correct.

setModified(b) None.

Set the ‘modified’ flag in a script. Setting the value will turn the indicator in the title bar on/off and will start or stop the autosave timeout. :param b: Boolean convertible object. :return: None.

setName(name, uncollide=True, updateExpressions=False) None

Set name of the node and resolve name collisions if optional named argument ‘uncollide’ is True. :param name: A string. :param uncollide: Optional boolean to resolve name collisions. Defaults to True. :param updateExpressions: Optional boolean to update expressions in other nodes to point at the new name. Defaults to False. :return: None

setProxy(b) None.

Set proxy. :param b: Boolean convertible object. :return: None.

setSelected(selected) None.

Set the selection state of the node. This is the same as changing the ‘selected’ knob. :param selected: New selection state - True or False. :return: None.

setTab(tabIndex) None
Parameters:

tabIndex – The tab to show (first is 0).

Returns:

None

setView(s) None.

Set view. :param s: Name of view. :return: None.

setXYpos(x, y) None.

Set the (x, y) position of node in node graph. :param x: The x position of node in node graph. :param y: The y position of node in node graph. :return: None.

setXpos(x) None.

Set the x position of node in node graph. :param x: The x position of node in node graph. :return: None.

setYpos(y) None.

Set the y position of node in node graph. :param y: The y position of node in node graph. :return: None.

showControlPanel(forceFloat=false) None
Parameters:

forceFloat – Optional python object. If it evaluates to True the control panel will always open as a floating panel. Default is False.

Returns:

None

showInfo(s) None.

Creates a dialog box showing the result of script s. :param s: A string. :return: None.

shown() true if the properties panel is open. This can be used to skip updates that are not visible to the user.
Returns:

true if the properties panel is open. This can be used to skip updates that are not visible to the user.

splaySelectedNodes(backward, inputA) None.

Splay the selected nodes. :param backward. :param inputA. :return: None.

treeHasError() bool

True if the node or any in its input tree have an error, or False otherwise.

Error state of the node and its input tree. Note that this will always return false for viewers, which cannot generate their input trees. Instead, choose an input of the viewer (e.g. the active one), and call treeHasError() on that.

unlock() Unlocks the node and makes knobs editable.
upstreamFrameRange(i) FrameRange

Frame range for the i’th input of this node. :param i: Input number. :return: FrameRange. Returns None when querying an invalid input.

width() int.

Width of the node. :return: int.

writeKnobs(i) String in .nk form.

Return a tcl list. If TO_SCRIPT | TO_VALUE is not on, this is a simple list of knob names. If it is on, it is an alternating list of knob names and the output of to_script().

Flags can be any of these or’d together: - nuke.TO_SCRIPT produces to_script(0) values - nuke.TO_VALUE produces to_script(context) values - nuke.WRITE_NON_DEFAULT_ONLY skips knobs with not_default() false - nuke.WRITE_USER_KNOB_DEFS writes addUserKnob commands for user knobs - nuke.WRITE_ALL writes normally invisible knobs like name, xpos, ypos

Parameters:

i – The set of flags or’d together. Default is TO_SCRIPT | TO_VALUE.

Returns:

String in .nk form.

xpos() X position of node in node graph.
Returns:

X position of node in node graph.

ypos() Y position of node in node graph.
Returns:

Y position of node in node graph.