bubble up/raise a sop node from behind a netbox

   1988   3   1
User Avatar
Member
380 posts
Joined: July 2005
Offline
Wondering if anyone have a shelf script to do this handy?

i find it distracting when i drop a node into a netbox and go back to later
discover its now obscured by the netbox. couldn't find anything that would
let me easily ‘bring to front’ a node thats behind a netbox… so I thought
there might be a shelf script out there to hotkey this.

Its also odd that you have to drag the node way outside the netbox
and then drag it back into the netbox to effectively raise it, when you
should be able to double click the node in place or click it with a modifier
key.

havent looked at how to do it yet, maybe its as simple as caching the
position and adding it to the netbox or something, but then i suppose
you have to select the netbox unless theres a way to ‘find nearest netbox’.
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
Something like this would probably work. You might want to add some sort of extra threshold on the boundaries due to the shapes but it's not necessary.

def addToBoxes(parent):

for box in parent.networkBoxes():
minPos = box.position()
maxPos = minPos + box.size()
nodes = box.nodes()

for node in parent.children():
if node in nodes:
continue

x, y = node.position()

if x > minPos and x < maxPos and y > minPos and y < maxPos:
box.addNode(node)
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
380 posts
Joined: July 2005
Offline
cool, thanks. something like i guess.

still need to bind to the selected node and the bounds of each netbox
to test if the nodes position is contained in the bounds of the netbox
before adding it. ill mess with it. cheers.
User Avatar
Member
380 posts
Joined: July 2005
Offline
This works pretty well for me dropping it into a shelf button and
assigning seperate hotkeys. Any number of selected nodes in any
number of networks. Cheers.


def raiseInNetBox(nodes):
if nodes:
parent = nodes.parent()
netboxes = parent.networkBoxes()
for node in nodes:
x,y = node.position()
#print node,x,y
for nb in netboxes:
nbMin = nb.position()
nbMax = nbMin + nb.size()
#print nb,nbMin,nbMax
if x > nbMin and x < nbMax and y > nbMin and y < nbMax:
if not node in nb.nodes(): nb.addNode(node)
break

def lowerInNetBox(nodes):
if nodes:
parent = nodes.parent()
netboxes = parent.networkBoxes()
for node in nodes:
for nb in netboxes:
if node in nb.nodes():
nb.removeNode(node)
break

selected = hou.selectedNodes()
#raiseInNetBox(selected)
lowerInNetBox(selected)
  • Quick Links