Introduction to Python Scripting in NUKE
Python is a widely used scripting language that is integrated into NUKE to let us artists control the user interface, quickly modify many nodes, and integrate with external applications. Software required: NUKE 6.3v6.
What you'll learn
Python is a widely used scripting language that is integrated into NUKE to let us artists control the user interface, quickly modify many nodes, and integrate with external applications. By learning some Python commands and workflows we can extend NUKE and write scripts that let us focus on creating art. We will start this NUKE tutorial by echoing the Python commands that NUKE uses internally and begin writing our own code. From there we will learn how to correctly create nodes, set properties at node creation and have our scripts automatically run whenever NUKE starts up. From there, we can begin working on some projects, like a script that selects all nodes of a specific class based on user input and a script to automatically break a multi-channel EXR into individual auto-cropped shuffle nodes so we can begin compositing faster. Software required: NUKE 6.3v6.
Table of contents
- Accessing Our Script Editor and Writing a Python Script 4m
- Running and Finding Help on Python Commands 9m
- Creating New Nodes and Setting Knob Values 9m
- Using Variables to Store Information and Nodes for Later Edits 8m
- Printing Numbers with Strings in Python 7m
- Setting Node and Knob Defaults and Saving Them in menu.py 8m
- General Coding Workflows to Save Time and Headache 4m
- Getting Selected Nodes to Modify in Python 7m
- Using and Working with Lists to Store Multiple Nodes 7m
- Modifying Each Item in a List with a for in Loop 10m
- Controlling Script Flow Using if Statements 13m
- Doing Common Operations Using the Included Python Scripts 5m
- Getting Input from the User to Customize Our Commands 6m
- Selecting All Nodes of a Certain Type by Checking Their Class 7m
- Creating a Quick Message to Our User with the Results 5m
- Working with Layers and Channels in Python 8m
- Using String Splits and Sets to Gather Unique Channel Layer Names 9m
- Connecting Node Inputs to Shuffle Our Channels Out 11m
- Executing Commands and Copying Animation in Python 13m
- Packaging Pieces of Code in Functions for Reuse and Simplicity 11m
- Adding Commands to the NUKE User Interface for Later Use 10m