Last active
November 27, 2025 14:42
-
-
Save keerah/de6076698765651773cd69ba106840c9 to your computer and use it in GitHub Desktop.
Houdini Solaris inspector custom data via Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This can run a custom python code to evaluate something useful. | |
| # The code is located in Program Files/SideFx.../Houdini v.v.v/houdini/scene/inspect_usd_prim.py | |
| # | |
| # Coded this little function to fetch the first Mesh subprim and a specific attribute from it. | |
| # It detects if the attribute is a list/array and then it outputs min:max values, | |
| # otherwise it outputs the actual value or indicates if the attribute is not present. | |
| # Not sure how Python can handle all the diversity of the USD datatypes yet, | |
| # so you'll have to take care of it from here for vectors/matrices/etc. | |
| # | |
| # Read the help text in the inspect_usd_prim.py, there's a flag to disable code caching, | |
| # so your edits would be live while you working on it. Have fun! | |
| import hou | |
| from pxr import Sdf, Usd, UsdGeom # can be useful but not here | |
| def inspect(viewer, viewport, stage, primpath): | |
| attr_name = "primvars:hl" # set the attribute name | |
| try: | |
| parent_prim = stage.GetPrimAtPath(primpath) | |
| child_prim = parent_prim.GetChildren()[0] | |
| attr = child_prim.GetAttribute(attr_name) | |
| if attr.IsValid(): | |
| attr_val = attr.Get(hou.time()) | |
| if hasattr(type(attr_val), '__len__'): | |
| res = f'{child_prim.GetName()}\n {attr_name}({len(attr_val)}) = {min(attr_val)}:{max(attr_val)}' # min:max values for data that has length | |
| else: | |
| res = f'{child_prim.GetName()}\n {attr_name} = {attr_val}' | |
| else: | |
| res = f'{child_prim.GetName()}\n {attr_name} not found' | |
| return res | |
| except: | |
| import traceback | |
| return traceback.format_exc() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment