ID 158083 - BackdropNode.selectNodes() and BackdropNode.getNodes() doesn't work in terminal

Follow

Problem summary
BackdropNode.selectNodes() and BackdropNode.getNodes() doesn't work in terminal/non-GUI Nuke

Customer reported version
nuke.n/a

Customer reported platform

Steps to reproduce

1) Launch Nuke in GUI mode and open the attached Nuke script

2) Run the following code:
backdrop = nuke.toNode('BackdropTest')backdrop.selectNodes(True)selected_nodes = nuke.selectedNodes()print (selected_nodes)
It will return the list of nodes in the Backgrop node

3) Launch Nuke in terminal mode, again opening the same script, for example: Nuke13.0 -t <path/to>backdropTest.nk

4) Run the same code as step 2, it now returns an empty list

Expected behaviour
For all the nodes in the Backdrop node to be selected when using BackdropNode.selectNodes() or BackdropNode.getNodes()

Actual behaviour
Nothing was selected when running in Terminal mode

Workaround
Write a function to manually check every node to see if they are in the bounds of the Backdrop:
 
def activateBackdrop(node):
    xmin = node.knob('xpos').value()
    xmax = xmin + node.knob('bdwidth').value()
    ymin = node.knob('ypos').value()
    ymax = ymin + node.knob('bdheight').value()
    for i in [i for i in nuke.allNodes() if i is not node]:
        ixmin = i.knob('xpos').value()
        ixmax = ixmin + i.screenWidth()
        iymin = i.knob('ypos').value()
        iymax = iymin + i.screenHeight()
        if (ixmin >= xmin and ixmax < xmax) and (iymin >= ymin and iymax < ymax):
            i.knob('selected').setValue(True)
activateBackdrop(nuke.toNode('BackdropTest'))

selected_nodes = nuke.selectedNodes()
print (selected_nodes)


Reproduced by support
This bug has been reproduced in:
Nuke 13.0v5 - Windows 10, CentOS 7.5, macOS 11
Nuke 9.0v1 - Windows 10, CentOS 7.5

Previously tested in:
Nuke 6.3v6 - macOS 10.6.8

Earliest version tested
Nuke 9.0v1 - This issue appears to be in all versions of the product

    We're sorry to hear that

    Please tell us why