Senior Compositor | Python Enthusiast | Freelancer |
Nuke Pyhton Snippet
Here's a collection of Python commands for Nuke that you can use directly or refer to when writing your own code. This page aims to assist compositors who are familiar with Python but don't code extensively, helping to accelerate their workflow. If you require comprehensive guidance on Python within Nuke, The Foundry provides a Python Developers Guide.
############### Create menu.py ###############
menubar=nuke.menu("Nuke")
m=menubar.addMenu("&Custom")
m.addCommand("&Cue Render", "nuke.createNode('cue_render')", "Ctrl+R")
############### Added plugin path ###############
nuke.pluginAddPath("/path/to/your/plugin/folder")
############### Accessing nuke.root ###############
nuke.root().knob('first_frame').value()
############### Create Blur Node ###############
nuke.createNode('Blur', inpanel=False)
############### Selecting Node through Class ###############
nest = nuke.allNodes()
for i in nest:
if i.Class() == ('Blur'):
i.setSelected(True)
############### Changing knob value ###############
nuke.createNode('Blur', inpanel=False)
var = nuke.selectedNodes()
for i in var:
i['name'].setValue('DirBlur')
i['size'].setValue(20)
i['label'].setValue('size = [value size]')
############### Manage input of node ###############
var = nuke.allNodes('Blur')
for i in var:
i.setInput(0, nuke.toNode('nodename'))
############### Defining position of the node ###############
nuke.createNode('Shuffle1', inpanel=False)
Sfl = nuke.selectedNodes('Shuffle1')
for i in Sfl:
i['xpos'].setValue(158)
i['ypos'].setValue(100)