Well, I've just started getting into Nuke's API. Here I import the footage:
nuke.nodes.Read(file="E:/Final/Practice/MVI_8411.mov", name="Footage")
selected the footage (and stored in a variable):
footage = nuke.toNode("Footage")
When I pipe it to Write node, it doesn't work:
nuke.createNode("Write")
I create a Write node though, but it's not connected to Read node. I expected it to connect. Doesn't toNode()
function selects nodes in non-GUI mode?
Pay particular attention to classes of nodes and their names in Node Graph. In the following example Read
is a class, Read1
is a name.
So try this script to get your Write
node connected:
import nuke as nk
import nukescripts
nk.nodes.Read(file="E:/Final/Practice/MVI_8411.mov")
nk.toNode("Read1").setSelected(True)
nk.createNode("Write")
nukescripts.connect_selected_to_viewer(0)
or this way:
import nuke as nk
import nukescripts
nk.createNode("Read", "file E:/Final/Practice/MVI_8411.mov name footage")
nk.toNode("footage").setSelected(True)
nk.createNode("Write")
nukescripts.connect_selected_to_viewer(0)
To find out what the class a node belongs to, create, for example, a CheckerBoard
, select it and press i shortcut on your keyboard. You'll see its class is CheckerBoard2
and its name is CheckerBoard1
.
And in case you use a node of class 2
your lines should look like this:
nk.createNode("CheckerBoard2")
nk.toNode("CheckerBoard1").setSelected(True)
nk.createNode("Write")
Or your syntax would be like this:
nk.nodes.CheckerBoard2(name="board")
nk.toNode("board").setSelected(True)
nk.createNode("Write")
...or just like that:
nk.createNode("CheckerBoard2", "name board")
nk.toNode("board").setSelected(True)
nk.createNode("Write")