Auto select node when checking display flag

   959   11   2
LukeP
Member
128 posts
Joined: March 2009
Offline
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
495 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
214 posts
Joined: April 2018
Offline
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.
LukeP
Member
128 posts
Joined: March 2009
Offline
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?
animatrix_
Member
3445 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]

patreon.com/animatrix | vimeo.com/animatrix3d
User Avatar
Member
6837 posts
Joined: July 2007
Offline
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
495 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
385 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)

SWest
Member
165 posts
Joined: Oct. 2016
Offline
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.
Full time IT-teacher (8y) / junior TD / Debian11 XFCE / Zbrush (Wine) / Python / VNC / networks / two small kids / BSc CS:CG / Stockholm
User Avatar
Member
291 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
214 posts
Joined: April 2018
Offline
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
SWest
Member
165 posts
Joined: Oct. 2016
Offline
raincole
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...?

Well, sometime I find myself making functions for things in Houdini that already exist in the API. Other times it can be solving something that is already solved or fixing something that is not broken.

At work (not Houdini related) I need to do a lot of scripting sometimes and these things have real issues, and can be urgent. I'm not talking about a click in one app, but a bunch of hosts and several apps or services. Such problems are never related with if one has to do one, two or three clicks, but rather just having a lot of stuff barely working. That is my point, but maybe you never have any such issues.

I do not see any problem with the case. A quick click-drag around a node and pressing R seem to work fine. However, it is still interesting to read about various technical methods available. Furthermore, I more often than not need to have the display set to another node than the one currently being edited (selected), and guess that is just part of a procedural workflow where you can jump around and tweak nodes arbitrarily.

No disrespect implied here man. I'm just pointing out the risk of loosing focus or spending too much time on tiny enhancements, when there is an elephant of issues waiting for attention. Maybe you don't have that however. It is okay.
Full time IT-teacher (8y) / junior TD / Debian11 XFCE / Zbrush (Wine) / Python / VNC / networks / two small kids / BSc CS:CG / Stockholm
  • Quick Links