Python get the node that has the display flag toggled

   3110   4   3
User Avatar
Member
13 posts
Joined: Dec. 2016
Offline
Hey guys,

I am writing a shelf tool that toggles on a parameter on a node. I have the shelf tool working if I have the node selected but I want it to work so that I do not need the node selected, just that if it has the display flag toggled.

I have been stuck on finding this node in python. I would not know the /obj/* path ahead of time so the tool would need to figure out my network editor path. Let me know if anyone has any tips!
User Avatar
Member
2568 posts
Joined: June 2008
Offline
Weird, when I Google “houdini python display flag” I see your answer. (and question)
Edited by Enivob - Sept. 14, 2020 08:34:11
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
13 posts
Joined: Dec. 2016
Offline
I was trying to search for finding the current context but that was the wrong keyword. I meant to be searching for getting the current pwd of the network editor.

def get_display_node():
    editors = [pane for pane in hou.ui.paneTabs() if isinstance(pane, hou.NetworkEditor) and pane.isCurrentTab()]
    if not editors:
        return None
    network_editor = editors[-1]
    network_path = network_editor.pwd()
    display_node = network_path.displayNode()
        return display_node
User Avatar
Member
192 posts
Joined: April 2015
Offline
For in an Object Merge node:

editors = [pane for pane in hou.ui.paneTabs() if isinstance(pane, hou.NetworkEditor) and pane.isCurrentTab()]
if not editors:
    return None
    
network_editor = editors[-1]
network_path = network_editor.pwd()
display_node_path = network_path.displayNode().path()

return display_node_path

I am wondering tho how I could have this updated every time I change a Display Flag in the currentTab..
Right now I have to change some parameter on the Object Merge to have it update.

Anyone any ideas ?
User Avatar
Member
29 posts
Joined: May 2019
Offline
I believe you can use nodesearch [www.sidefx.com] for this

I don't know the exact state that you need, but this may help you get started:

import nodesearch

matcher = nodesearch.State("displaydescriptivename", False)
network = hou.node("/obj/")
for node in matcher.nodes(network, recursive=True):
  ...
  • Quick Links