SUMMARY
This article will cover the use of the Comp Script Command dialogue box within the Node Graph, to run single-line TCL or Python commands.
MORE INFORMATION
The Comp Script Command dialogue box is a quick method to run a single-line Python or TCL command directly in Nuke. This saves time when running a simple commands that do not need longer Python scripts that require definitions, and is a good option if you only require a single operation to occur.
Below is shown how the Comp Script Command dialogue box can be used with the TCL command of getenv to get an environment variable's value. The NUKE_PATH environment variable will be used in the following example:
1. Open the Comp Script Command dialogue box by navigating to File > Comp Script Command... or by hovering the cursor in the Node Graph and pressing the X key:
2. In the Command text box, enter the code you wish to run and click OK, such as the following TCL command:
getenv NUKE_PATH3. A new dialog will appear returning the result of the command, which is the current value of the NUKE_PATH environment variable in this case:
If you do not currently have an environment variable set, you will receive a warning letting you know it is undefined:
The above example is used to display the value of an environment variable, but the Comp Script Command dialog can be used to execute and relay back many single-line commands, like the additional examples listed below:
- Using TCL: Checking the amount of independent Read nodes used within the script and the script’s location:
script_info- Using Python: Creating a Node with preset values within the Node Graph:
nuke.nodes.Blur(name="Big Blur", size=10)- Using Python: Altering an existing Nodes value, based upon its class the Node Graph:
[node.knob("size").setValue(100) for node in nuke.allNodes("Blur")]After the code is executed, a second dialog window will return a Boolean value that reports the success of the change.
FURTHER READING
For more information on Python commands, TCL commands and environment variables please refer to the documentation linked below:
We're sorry to hear that
Please tell us why