Using the Script Editor (2024)

If you're not using a third-party Python interpreter, you can type Python scripts into Nuke’s Script Editor.

To open the Script Editor, click on one of the content menus and select Script Editor from the menu that opens.

The Script Editor is divided into two parts, as shown in the figure below. You use the lower part (input pane) to type in and execute your Python statement, and when you have done so, statements and their outputs appear in the upper part of the editor (output pane). Successfully executed statements are followed by a hash mark (#).

Using the Script Editor (1)

The two parts of the Script Editor.

To hide the output or input pane, click the Show input only or Show output only button Using the Script Editor (2) on top of the Script Editor.

To show both panes again, click the Show both input and output button Using the Script Editor (3).

To enter a statement in the Script Editor:

1. Click on the input pane of the editor to insert the cursor there.
2. Type in your statement. To use the usual editing functions, such as copy and paste, right-click on the editor and select the desired function.

When entering the statement, you’ll notice that any words that are Python’s keywords (such as print and import) turn green, while strings (basically, anything in quotation marks) become either red or cyan. Comments are shown in yellow.

Using the Script Editor (4)

If you like, you can change these colors and the font on the Script Editor tab of the Preferences dialog. To open the preferences, press Shift+S.

Tip: You can also use auto-complete to help you with entering Python statements. Start writing a command and press the Tab key. If there’s only one way to end your command, Nuke auto-completes it straight away. If there are several possible completions, Nuke gives you a pop-up menu listing them. If there’s no known way to complete your command, nothing happens. Even if your command is automatically completed, it is not executed automatically, just in case you don’t like surprise side effects.

3. If your statement includes several lines or you want to enter several statements at once, press Return to move to the next line.
4. To execute the statement, click the Run the current script button on the top of the Editor, or press Ctrl/Cmd+Return.

Tip: You can also execute statements by pressing Ctrl/Cmd+Enter on the numeric keypad.

By default, successful statements disappear from the input pane, and appear in the output pane. However, if you want all statements to stay in the input pane after they are executed, you can do the following:

1. Press Shift+S to open the Preferences dialog.
2. Go to the Script Editor tab.
3. Uncheck clear input window on successful script execution.
4. Click Close to save the preference for the current project only, or Save Prefs to save the preference for the current and future projects.

If you enter an invalid statement, Nuke produces an error in the output pane of the Script Editor, leaving the invalid statement in the input pane. Correct the statement and execute it again until you get it right.

Note: Sometimes you may get an error if you copy and paste statements into the Script Editor from another source, like an e-mail. This may be caused by the mark-up or encoding of the source you copied the statement from. To fix the problem, re-enter the statement manually.

If you want to have all executed Python commands appear in the output pane of the Script Editor, open the Preferences dialog (press Shift+S), go to the Script Editor tab, and check echo all commands to output window. This applies to both commands executed by yourself and by Nuke. For example, if you select a node from the Toolbar, the corresponding Python command is displayed in the output pane. This does not apply to all actions you take in the graphical user interface, however, but only those that are performed by executing Python script commands.

To only execute part of a script, enter the script in the input pane and select the part you want to execute. Press Ctrl/Cmd+Return. Nuke runs the selected part of the script, leaving the script in the input pane.

To repeat a statement, click the Previous Script button Using the Script Editor (5) on top of the Editor to move back to the previous statement. You can do this until you reach the statement you want to repeat. To execute the statement again, press Ctrl/Cmd+Enter.

To increase the indentation in the input window, press Tab.

To decrease the indentation in the input window, press Shift+Tab.

In addition to stepping backwards through the history of your script, you can also step forwards. Click the Next script button Using the Script Editor (6) to move forward through your statements.

To clear the history, click the Clear history button. Using the Script Editor (7)

Click the Clear output window button Using the Script Editor (8) (or press Ctrl/Cmd+Backspace).

Using the Script Editor (2024)
Top Articles
Latest Posts
Article information

Author: Rob Wisoky

Last Updated:

Views: 5877

Rating: 4.8 / 5 (48 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Rob Wisoky

Birthday: 1994-09-30

Address: 5789 Michel Vista, West Domenic, OR 80464-9452

Phone: +97313824072371

Job: Education Orchestrator

Hobby: Lockpicking, Crocheting, Baton twirling, Video gaming, Jogging, Whittling, Model building

Introduction: My name is Rob Wisoky, I am a smiling, helpful, encouraging, zealous, energetic, faithful, fantastic person who loves writing and wants to share my knowledge and understanding with you.