Skip to content

Instantly share code, notes, and snippets.

View spatial-bit's full-sized avatar

spatial spatial-bit

View GitHub Profile
@spatial-bit
spatial-bit / snippet.py
Created January 25, 2022 23:02
USD more get cameras #USD #OMNIVERSE
# def _get_cameras(stage, filter) -> typing.List:
# """ Get all cameras in the scene except for the ones that are excluded (ie: Perspective, Top, Left, Right cameras)
# """
# cameras = {}
# for prim in Usd.PrimRange(stage.GetPseudoRoot()):
# if prim.IsA(UsdGeom.Camera) and prim.GetName():
# if filter in prim.GetPath().pathString:
# cameras[prim.GetName()] = prim.GetPath().pathString
# return cameras
@spatial-bit
spatial-bit / snippet.py
Created February 3, 2022 16:14
USD get prim starts_with #USD #OMNIVERSE
import omni.usd
from pxr import UsdGeom, Usd, UsdGeom
def get_prims_startswith(stage, root_path, starts_with):
matching_prims = []
root_prim = stage.GetPrimAtPath(root_path)
for prim in Usd.PrimRange(root_prim):
if prim.GetName().startswith(starts_with):
matching_prims.append(prim)
return matching_prims