Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pxr import Usd, UsdGeom
- def remove_st_primvars(prim):
- """
- Recursively removes 'st' primvars using PrimvarsAPI from the given prim and all its children.
- """
- primvars_api = UsdGeom.PrimvarsAPI(prim)
- if primvars_api.HasPrimvar("st"):
- primvar = primvars_api.GetPrimvar("st")
- primvar.GetAttr().Clear()
- print(f"'st' primvar removed from {prim.GetPath()}")
- # Recursively remove 'st' from all child prims
- for child in prim.GetChildren():
- remove_st_primvars(child)
- # Access the stage in Houdini's LOPs context
- stage = hou.node('/path/to/your/python_lop').stage()
- # Specify the top-level prim path
- top_prim_path = "/path/to/your/top/prim"
- top_prim = stage.GetPrimAtPath(top_prim_path)
- # Apply the function to the top prim and its descendants
- if top_prim:
- remove_st_primvars(top_prim)
- else:
- print(f"No prim found at path {top_prim_path}")
- # Save the stage to persist changes
- stage.GetRootLayer().Save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement