TCL Tips For Visualizing Data In Your Comp

Categories Nuke, TCL, Workflow

I often find myself labelling nodes with descriptors, so it’s clear what each node is doing. This usually involves a TCL snippet to return a value of a certain knob. This article is intended to serve as a reference, so we have a good cheat sheet to turn to when we might need to find a specific TCL snippet.


Set the value of a knob
Code: [knob <nodeName>.<knobName> <valueToSet>]
Example: [knob Transform2.translate.x 30]

Return a knob’s value
Code: [value <knobName>]
Example (Tracker Node): Motion: [value transform]\nRef Frame: [value reference_frame]

Return a knob’s value from a different node
Code: [value <nodeName>.<knobName>]
Example: [value Blur1.channels]

Return the name of the input node
Code: [value]

Return the filename of Read node connected up-stream
Code: [basename [value [topnode].file ]]

Return the filename of Read node connected up-stream, without the file extension
Code: [basename [file rootname [value [topnode].file]]]

Return the frame range of a Read node connected up-stream
Code: Frame Range: [value first_frame] – [value last_frame]

Sample a channel’s value at a specific coordinate
Code: [sample [node input] <colourChannel> <xCoordinate> <yCoordinate>]
Example: [sample [node input] red 1094 354]

Return the value of a switch node, and change the result from numbers to more-descriptive words
Code: [if {[value <nodeName>.<knobName>]==<value>} {return “<Whatever text you want to replace <value> with>”} elseif{[value <nodeName>.<knobName>]==<value2>} {return “<Whatever text you want to replace <value2> with>”} else {return “<Whatever your default value should be, if the previous conditions aren’t met>”}]
Example: [if {[value Switch1.which]==1} {return “Viewing the first option”} elseif {[value Switch1.which]==2} {return “Viewing the second option”} else {return “No Value Returned”}]

Replace string in certain expression with another word
Code: [regsub -all “<string to look for in expression>” [value <expression>] “What to replace the string with”]
Example: [
regsub all “THR-025” [value [node this].file] “Sequence: THR
// Shot: 025″]


Get the value of a knob on a specific frame
Code: <nodeName>.<knobName>(<frameNumber>)
Example: Transform1.translate.x(50)

Offset the timing of an animation by 50 frames in a new node
(useful for offsetting Trackers when the plate frame range changes)
Code: <nodeName>.<knobName>(frame+<offsetAmount>)
Example: Transform1.translate.x(frame+50)

Return the value of your project format
width: [value root.width]
height: [value root.height]

Return the value of a node input’s format
width: [value input.width]
height: [value input.height]

Find the center-point of your image
x: [value format.width]/2
y: [value format.height]/2

Return the value of your bbox
x: [value bbox.x]
y: [value bbox.y]
r: [value bbox.r]
t: [value bbox.t]

Return the center-point of your bbox
x: ([value bbox.x]+[value bbox.r])/2
y: ([value bbox.y]+[value bbox.t])/2 

Have I missed anything useful? Please let me know in the comments below, and I’ll update this article.

Still can’t find what you’re looking for? Click here to read some Nuke-specific TCL documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.