Depending on where you need to use an expression, you might find that you want to, for example, convert Nuke expressions to TCL expressions or embed Python functions in a Nuke expression. The different languages are used in different parts of Nuke:
• Python can be used in the Script Editor, in the Script Command (File > Script Command) and in scripts run when Nuke starts (such as init.py and menu.py).For more information, see the Nuke Python documentation (Help > Documentation).
• TCL can be used in most string knobs (where text other than just numbers can be entered), in the Script Command dialog (File > Script Command), to open some compatibility start up scripts (such as init.tcl and formats.tcl).
• Nuke expressions can be used on the Add Expression dialog with most knobs in Nuke and expression entry field in the Expression node.
You can use the following functions to use different types of expressions together:
• nuke.expression() to use a Nuke expression in Python code.
• expression to use a Nuke expression in TCL.
• nuke.tcl() to run TCL code in Python.
• python to run Python code in TCL
• [ ] (square brackets) to embed TCL in a Nuke expression (or a string knob)
• [python {...}] to embed Python in a Nuke expression.
TIP: Note that putting braces ( { } ) around Python code when embedding it in TCL may make the process a bit easier, because this prevents TCL from performing its own evaluation of the Python code before passing it through to the Python interpreter. For example: [python {"hello " + "world"}]
TIP: Note that the "python" TCL command by default evaluates a single line of code and returns the result. Use the "-exec" option (e.g. "python -exec") if you want to run multiple lines. Please refer to the Nuke TCL Scripting documentation (Help > Documentation > TCL Scripting) for further information.