pythonnodesnuke

How to select nodes in array via Python in Nuke?


I'd like to select all the nodes created in createdNodes[] array in The Foundry Nuke script.

createdNodes=[]

for r in ReadList:
    rn = nuke.createNode( 'Read' )
    rn['file'].fromUserText( r )

for i in createdNodes: 
    print i['file'].getValue()
    i.setSelected( True )

Can anyone help me?


Solution

  • If you want to select just one Grade2 node (for instance) use this command:

    import nuke
    
    nuke.toNode('Grade2').setSelected(True)
    

    If you want to select all Transform nodes in the script then use this:

    for w in nuke.allNodes('Transform'):
        w.setSelected(True)
    

    If you want to select all the nodes in the NUKE script including Viewer then use this:

    for a in nuke.allNodes():
        a.setSelected(True)
    

    And if you want to select all the nodes in the createdNodes[] array then use this:

    t = nuke.createNode('Transform')
    g = nuke.createNode('Grade')
    b = nuke.createNode('Blur')
    createdNodes = [t, g, b]
    
    for i in createdNodes: 
        i.setSelected(True)