Python get nodes in network box

   1765   1   1
User Avatar
Member
388 posts
Joined: July 2018
Offline
root = hou.node("/obj/")
netbox = root.findNetworkBox("My_networkbox")
nodes = netbox.nodes()

Why isn't this working?
netbox prints None
User Avatar
Member
9280 posts
Joined: July 2007
Offline
if by My_networkbox if you are referring to the visible text
it is not the name of your network box but the comment, you can have many network boxes with the same comment, but each still has unique name you can't see directly

there may be a simpler way, but try this to get all net boxes matching the comment and or one of them:
root = hou.node("/obj/")
allboxes = root.findNetworkBoxes("*")
matchingboxes = [box for box in allboxes if box.comment() == "My_networkbox"]
firstmatchingbox = matchingboxes[0]
Edited by tamte - March 23, 2022 20:58:30
Tomas Slancik
CG Supervisor
Framestore, NY
  • Quick Links