In the Solaris LOPs stage context, in the Scene Graph Tree, when you right-mouse on a material, there is a menu item called Select All Bound Geometry.
I would like to be able to do this via python. i.e. return a list of all the USD.prims that are bound to this material. So that I can programmatically make modifications.
I checked here, but couldn't find any reference to this function:
https://www.sidefx.com/docs/houdini/nodes/lop/pythonscript.html [www.sidefx.com]
Thanks
How to Select All Material-Bound USD.prims Via Python?
2455 4 2- syntheticperson
- Member
- 159 posts
- Joined: July 2010
- Online
- mtucker
- Staff
- 4438 posts
- Joined: July 2005
- Offline
On that page, look for the example of using a hou.LopSelectionRule (search for `setPathPattern`). Then just change the setPathPattern call to `ls.setPathPattern('%geofrommat:/materials/iaTank_BrassMaterial')` (see https://www.sidefx.com/docs/houdini19.0/solaris/pattern.html [www.sidefx.com] for more information on specifying patterns).
- Cicuta
- Member
- 55 posts
- Joined: Nov. 2019
- Offline
I don't know if syntheticperson's question was more in the line of, "what is the python equivalent that computes %geofrommat/select all bound geometry?" For %matfromgeo we can use , but I am failing to find anything that could do the %geofrommat.
Does anyone know a python func that could do that?
links: https://docs.omniverse.nvidia.com/kit/docs/omni.kit.usd_docs/latest/USD%20in%20Kit.html [docs.omniverse.nvidia.com]
https://openusd.org/release/api/class_usd_shade_material_binding_a_p_i.html#a5602550a78f68f6a1d1bf62187e22edd [openusd.org]
bound_material, _ = UsdShade.MaterialBindingAPI(prim).ComputeBoundMaterial()
Does anyone know a python func that could do that?
links: https://docs.omniverse.nvidia.com/kit/docs/omni.kit.usd_docs/latest/USD%20in%20Kit.html [docs.omniverse.nvidia.com]
https://openusd.org/release/api/class_usd_shade_material_binding_a_p_i.html#a5602550a78f68f6a1d1bf62187e22edd [openusd.org]
Edited by Cicuta - July 3, 2023 11:21:30
- Cicuta
- Member
- 55 posts
- Joined: Nov. 2019
- Offline
mtuckerThe method you suggested, when working with a bit more complex scripts will quickly run into the following warning "Read lock failed because of existing lock: ... This may cause performance issues, and should be avoided if possible", which I am not too sure what it actually means and its implications.
On that page, look for the example of using a hou.LopSelectionRule (search for `setPathPattern`). Then just change the setPathPattern call to `ls.setPathPattern('%geofrommat:/materials/iaTank_BrassMaterial')` (see https://www.sidefx.com/docs/houdini19.0/solaris/pattern.html [www.sidefx.com] for more information on specifying patterns).
More on that warning in this topic: https://www.sidefx.com/forum/topic/76543/ [www.sidefx.com]
Thanks!
Edited by Cicuta - July 4, 2023 06:20:56
- robp_sidefx
- Staff
- 451 posts
- Joined: June 2020
- Offline
Cicuta
More on that warning in this topic: https://www.sidefx.com/forum/topic/76543/ [www.sidefx.com]
I'll reply with more info re this topic, on that page.
-
- Quick Links