You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the first bullet, I made a script that does the traversal on the entire scene, and appends all the prims that are a mesh type:
def get_all_stage_mesh(stage):
found_meshes = []
# Traverse the scene graph and print the paths of prims, including instance proxies
for x in Usd.PrimRange(stage.GetPseudoRoot(), Usd.TraverseInstanceProxies()):
if x.IsA(UsdGeom.Mesh):
found_meshes.append(x)
return found_meshes
def traverse_instanced_children(prim):
"""Get every Prim child beneath `prim`, even if `prim` is instanced.
Important:
If `prim` is instanced, any child that this function yields will
be an instance proxy.
Args:
prim (`pxr.Usd.Prim`): Some Prim to check for children.
Yields:
`pxr.Usd.Prim`: The children of `prim`.
"""
for child in prim.GetFilteredChildren(Usd.TraverseInstanceProxies()):
yield child
for subchild in traverse_instanced_children(child):
yield subchild
The typical methods for traversing a stage don't work in some cases, like an external stage being referenced in the current stage.
I would be happy to open a PR with a few examples, if told where to put them (I guess in https://github.com/NVIDIA-Omniverse/OpenUSD-Code-Samples/tree/main/source/hierarchy-traversal)
A few examples would be nice:
The text was updated successfully, but these errors were encountered: