3

Command applied for NUKE's nodes:

some_node.width() 

shows wrong width.

Like backdrop width is lesser than node width inside it (is it normal!?)

some_node.screenWidth()

always shows 0 width in terminal mode.

Actually I need it for determine nodes in backdrop. Tried next code:

backdrop_node.selectNodes(True)
print nuke.selectedNodes()

But this one returns nothing in terminal mode.

Thanks in advance for any help.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Evgeny
  • 61
  • 4

2 Answers2

1

If you want to know the value of bdwidth property in The Foundry NUKE (I used mac version 11.3v3) you should type a very simple Python command:

nuke.toNode('BackdropNode1').knob(21).value()

This command works in Script Editor as well as in terminal mode.

enter image description here\

To find out what Backdrop knobs' values are in NUKE's UI just select a node and press shortcut i on your keyboard to see a DetailNodeInfo window.

enter image description here

Hope this helps.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
0

Luckily I had to do something similar recently - haven't tested this in the terminal, but it doesn't rely on anything that isn't available in that context, AFAIK.

def locateNodes():
    '''get all backdrop nodes in a script, and return a dictionary of {backdropName:[list of nodes]}'''


    bdNodes=nuke.allNodes(filter="BackdropNode")

    containedNodes={}

    #create a dictionary of backdropName : (xpos, ypos, xpos+width, ypos+height)
    regions={}
    for backdropNode in bdNodes:
        regions[backdropNode.name()]=(backdropNode.knob('xpos').value(), 
                                        backdropNode.knob('ypos').value(),
                                        backdropNode.knob('xpos').value()+backdropNode.knob('bdwidth').value(),
                                        backdropNode.knob('ypos').value()+backdropNode.knob('bdheight').value())

    for node in nuke.allNodes():
        if node.Class()!="BackdropNode":
            pos=(node.knob('xpos').value(), node.knob('ypos').value())
            for backdropNodeName in regions:
                backdropRegion=regions[backdropNodeName]
                if pos[0]>=backdropRegion[0] and pos[0]<=backdropRegion[2] and pos[1]>=backdropRegion[1] and pos[1]<=backdropRegion[3]:
                    try:
                        containedNodes[backdropNodeName].append(node)
                    except KeyError:
                        containedNodes[backdropNodeName]=[node]

    return containedNodes
tk421storm
  • 333
  • 1
  • 2
  • 10