How do I get the name of the prim?

I found this code to get a list of all objects on the stage.

# Get the stage
stage = omni.usd.get_context().get_stage()
default_prim = UsdGeom.Xform.Define(stage, Sdf.Path("/World"))

# find the prims with of type UsdGeom.Mesh
prims: List[Usd.Prim] = find_prims_by_type(stage, UsdGeom.Mesh)

prim: Usd.Prim
for prim in prims:
    if prim.GetTypeName() == "Mesh":
        label.text =

I tried Name with lowercase and uppercase. In my test scene I only have 1 cube.


Does something like prim.GetPrimPath() work? I think that should do the trick.

GetPrimPath did work. I had tried GetPrimPath before, but I kept getting label doesn’t support an arg of type None

What worked was adding str to the result.

if len(str(primPath)) == 0:
(indent) label.text = “Prim Path is Empty”
(indent) label.text = str(primPath)

(This forum doesn’t indent for white space, so I added the indent above)

And the result is /World/Cube, which I can parse out the name.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.