Scene Graph Tree selection with Python

   4109   9   2
User Avatar
Member
25 posts
Joined: Dec. 2015
Offline
Is it possible to get/set selection for the Scene Graph Tree in Python. I was looking at the docs and could not find anything.

https://www.sidefx.com/docs/houdini/hom/hou/SceneGraphTree.html [www.sidefx.com]
User Avatar
Staff
4565 posts
Joined: July 2005
Offline
The scene graph tree shows the selection owned by the LOP Network. You can get or set that selection using hou.LopNetwork methods (selection() and setSelection()).
User Avatar
Member
25 posts
Joined: Dec. 2015
Offline
Thank you mtucker! That was it. I was looking in the wrong place.
User Avatar
Member
3 posts
Joined: March 2015
Offline
Hello,
I have a follow up question.
Is there a selection change callback for the custom Panel editors?
Thanks.
User Avatar
Staff
4565 posts
Joined: July 2005
Offline
Yep, you can use `hou.node('/stage').addEventCallback(, cb_function)`
User Avatar
Member
3 posts
Joined: March 2015
Offline
Which event type that would be? I tried SelectionChanged but it's not firing up.
User Avatar
Staff
593 posts
Joined: June 2020
Offline
Zhuk Cmon
Which event type that would be? I tried SelectionChanged but it's not firing up.

It should be that. If you paste this in the Python pane and then click in the scenegraph tree you should see messages appearing.

hou.node('/stage').addEventCallback([hou.nodeEventType.SelectionChanged,], lambda node, event_type: print('Selection changed!'))

This of course assumes the lopnet you want to watch is indeed /stageand not, for example, /obj/lopnet1.
Edited by robp_sidefx - April 14, 2023 05:07:43
User Avatar
Member
3 posts
Joined: March 2015
Offline
Gotcha, yes this works. I was registering callback for particular lop node not network.
Thank you.
User Avatar
Member
2 posts
Joined: Oct. 2018
Offline
robp_sidefx
Zhuk Cmon
Which event type that would be? I tried SelectionChanged but it's not firing up.

It should be that. If you paste this in the Python pane and then click in the scenegraph tree you should see messages appearing.

hou.node('/stage').addEventCallback([hou.nodeEventType.SelectionChanged,], lambda node, event_type: print('Selection changed!'))

This of course assumes the lopnet you want to watch is indeed /stageand not, for example, /obj/lopnet1.

Hi,How to get the current selected prims in Scenegraphtree pane, why dont Houdini pass the selected prims to kwargs of the callback funtion?
Edited by jerrykyj.kon - Nov. 27, 2023 17:04:36
User Avatar
Staff
4565 posts
Joined: July 2005
Offline
We didn't bother to add that to the kwargs directly because it's information that is easy to get from the node:
kwargs['node'].selection()
  • Quick Links