Auto select node when checking display flag

   2766   9   2
User Avatar
Member
233 posts
Joined: March 2009
Online
Is there a way to auto select the node that I'm turning the display flag on? Seems like not being able to do so doubles the number of clicks one has to do...
User Avatar
Member
679 posts
Joined: Feb. 2017
Offline
Hey LukeP,

I only have this snippet to set the display flag on the selected node. so you can put that to a shortcut.
# put all currently selected nodes in a tuple
allnodes = hou.selectedNodes()
if len(allnodes) == 0:
    hou.ui.displayMessage('Please select Nodes')
else:
#find last node Position of selected nodes
    lastNodePosition = len(allnodes)-1
# select last node
    lastnode = allnodes[lastNodePosition]
# set display/render/selection flag on node
lastnode.setDisplayFlag (True)
lastnode.setRenderFlag (True)
lastnode.setSelected(1,1)

But I barely use it as I work with this all the time: Hotkey System [animatrixx.gumroad.com]
It's money well spent. As it will speed up your Houdini workflow a lot. It provides a function to select and display the node that is nearest to the mouse. so you don't even have to be over the node, just near it.

Cheers
CYTE
User Avatar
Member
331 posts
Joined: April 2018
Online
LukeP
Is there a way to auto select the node that I'm turning the display flag on? Seems like not being able to do so doubles the number of clicks one has to do...
It doubles the number of clicks only when you want to do this. It's quite common to want to set the display flag to some other node, but continue working on the selected node.

As a workaround, you can click to select the node (or drag around it if you don't want to be precise), and hit R to display it.
User Avatar
Member
233 posts
Joined: March 2009
Online
CYTE
Hey LukeP,

I only have this snippet to set the display flag on the selected node. so you can put that to a shortcut.
# put all currently selected nodes in a tuple
allnodes = hou.selectedNodes()
if len(allnodes) == 0:
    hou.ui.displayMessage('Please select Nodes')
else:
#find last node Position of selected nodes
    lastNodePosition = len(allnodes)-1
# select last node
    lastnode = allnodes[lastNodePosition]
# set display/render/selection flag on node
lastnode.setDisplayFlag (True)
lastnode.setRenderFlag (True)
lastnode.setSelected(1,1)

But I barely use it as I work with this all the time: Hotkey System [animatrixx.gumroad.com]
It's money well spent. As it will speed up your Houdini workflow a lot. It provides a function to select and display the node that is nearest to the mouse. so you don't even have to be over the node, just near it.

Cheers
CYTE

Thank you. Where would I out this snipped of code?
User Avatar
Member
4508 posts
Joined: Feb. 2012
Offline
LukeP
CYTE
Hey LukeP,

I only have this snippet to set the display flag on the selected node. so you can put that to a shortcut.
# put all currently selected nodes in a tuple
allnodes = hou.selectedNodes()
if len(allnodes) == 0:
    hou.ui.displayMessage('Please select Nodes')
else:
#find last node Position of selected nodes
    lastNodePosition = len(allnodes)-1
# select last node
    lastnode = allnodes[lastNodePosition]
# set display/render/selection flag on node
lastnode.setDisplayFlag (True)
lastnode.setRenderFlag (True)
lastnode.setSelected(1,1)

But I barely use it as I work with this all the time: Hotkey System [animatrixx.gumroad.com]
It's money well spent. As it will speed up your Houdini workflow a lot. It provides a function to select and display the node that is nearest to the mouse. so you don't even have to be over the node, just near it.

Cheers
CYTE

Thank you. Where would I out this snipped of code?

Drag the code onto a shelf and then right click -> Edit Tool -> Hotkeys tab to assign a hotkey.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
8539 posts
Joined: July 2007
Online
CYTE
I only have this snippet to set the display flag on the selected node
why?

isn't that what R is doing by default?
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
679 posts
Joined: Feb. 2017
Offline
tamte
CYTE
I only have this snippet to set the display flag on the selected node
why?

isn't that what R is doing by default?

It also sets the display flag on the selected node while the mouse is over the viewport. that can be handy in some situations.
I use it mostly when I traverse the network via the Move to Previous/Next Operation commands, while the mouse is in the viewport.

Cheers
CYTE
User Avatar
Member
387 posts
Joined: Nov. 2008
Offline
You can add this code to "$HOUDINI_USER_PREF_DIR/houdini19.5/scripts/OnCreated.py"file. (Create the scripts folder and this file if it doesn't exist.)
import hou

def auto_select_on_display_flag_set(node, event_type, **kwargs):     # pylint: disable=W0613
    node.setSelected(node.isDisplayFlagSet())

def add_callback(kwargs):
    node = kwargs["node"]
    node.addEventCallback((hou.nodeEventType.FlagChanged,), auto_select_on_display_flag_set)

add_callback(kwargs)    # pylint: disable=E0602

This will auto-select a node with the display flag set (and auto-deselect nodes without it):


This is just quick Proof of Concept (not production tested).

Attachments:
autoselect_displayed.gif (196.9 KB)

User Avatar
Member
438 posts
Joined: Aug. 2019
Offline
SWest
Hey, this thread is interesting because of the methods discussed. However, scripting and automation is more meaningful when there are hundreds or thousans of manual steps. Just saying.

Or when there are 3 manual steps but you do them thousands times? What's your point...?
User Avatar
Member
331 posts
Joined: April 2018
Online
raincole
Or when there are 3 manual steps but you do them thousands times? What's your point...?

A bit of a straw man here. The scenario being discussed is two manual steps, not three, and both steps are very comfortably in the natural resting positions for either hand.

You have to click on the node, so do that with the mouse, and then just hit R with your other hand.

You don't even need a precision click, because you can drag a rectangle over the node.

I'm huge on automating a grind, and use macros heavily, but this one seems entirely unnecessary to me. Still, I'm glad that there does exist a solution for those looking to minmax their lives.
Edited by eikonoklastes - Oct. 1, 2022 16:22:56
  • Quick Links