How to catch a node that is created by a button?

861 views Asked by At

In The Foundry Nuke, I am trying to make a script. After pressing Create button I got a special Transform node. I want to catch this node that is being created i.e. if it's a tracker, I want that tracker to get it in my script so I can manipulate it.

Example:

track.knob('cornerPinOptions').setValue('Transform (match-move)')
cc = track.knob('createCornerPin')
nuke.Script_Knob.execute(cc) # this creates a transform node

# Now here is the part I can't figure out:
# How to select that transform node being previously created in my script?

I tried looking for last created node built-in function but there is none I could find. I tried some callbacks but I am not sure how to use them properly.

1

There are 1 answers

0
Andy Jazz On

For selecting and deselecting a previously created NUKE's node you should use a method nuke.toNode('nodename').setSelected( boolean ).

Here's an example how to do it:

# create a node (class=Tracker4) and assign a variable to it
tracker = nuke.nodes.Tracker4()

# connect a Viewer to its first input and deselect Viewer node
nuke.connectViewer( 0, tracker )
nuke.toNode('Viewer1').setSelected( False )

# select a node (name=Tracker1)
nuke.toNode('Tracker1').setSelected( True )