How to set Active, Visible, Solo in SceneGraph with python

   2682   5   4
User Avatar
Member
287 posts
Joined: Nov. 2014
Offline
Hello all.
Im redoing my group/shading tool from SOPs to LOPs and i would like to know, if there is a way how to toggle Active, Visible, Solo icons inside the Scene Graph Tree with python?
User Avatar
Staff
4565 posts
Joined: July 2005
Offline
Yes. Have a look at this help page: https://www.sidefx.com/docs/houdini/hom/hou/LopViewportOverrides.html [www.sidefx.com]
User Avatar
Member
287 posts
Joined: Nov. 2014
Offline
Thank you.
I have seen it there but had no luck to make it work.
I always get errors about the "with block". So my syntax must be bad.
Docu dais "end of the with block".

Can someone please help me to get the correct syntax?
User Avatar
Staff
4565 posts
Joined: July 2005
Offline
Yu have to create and use a LopViewportOverrides object in a python `with` block, like this (assuuming you first drop a Torus node in /stage):
lopnet = hou.node("/stage")
with lopnet.viewportOverrides(lopnet.node("torus1")) as overrides:
    selrule = hou.LopSelectionRule()
    selrule.setPathPattern("/torus1")
    overrides.setVisible(selrule, False)
User Avatar
Member
287 posts
Joined: Nov. 2014
Offline
Awesome.
Thank you very much for your help.
M.
User Avatar
Member
447 posts
Joined: April 2018
Offline
mtucker
Yu have to create and use a LopViewportOverrides object in a python `with` block, like this (assuuming you first drop a Torus node in /stage):
lopnet = hou.node("/stage")
with lopnet.viewportOverrides(lopnet.node("torus1")) as overrides:
    selrule = hou.LopSelectionRule()
    selrule.setPathPattern("/torus1")
    overrides.setVisible(selrule, False)
Hi,

I have a few questions about this:
- Why does the viewportOverrides function take a LOP node as an argument instead of a stage object or a prim? Viewport Overrides apply to prims, not LOP nodes. If the purpose is to get the stage of the current node, I'm thoroughly confused as to why you cannot just supply the stage.

- Why do we need to use a with statement along with a selection rule? Why can't we directly set the override on a prim?

- How do we get/query the state of an override? For the life of me, I cannot find any documentation on how to get the visibility override (for example) of a prim, and this is literally the only example I have found on how to set it.

Please and thank you.
Edited by eikonoklastes - May 3, 2025 07:27:16
  • Quick Links