How to load USD without Replicator?

How can i load a USD file without Replicator? I know I can use:

import omni.replicator.core as rep

rep.create.from_usd("path/to/file")

The problem is that Replicator changes all the paths of all the prims in the scene. I want to load my USD file but I want that all the paths I see in the GUI are the same when I load the file from python.

Hi Federico. I think that replicator function probably adds the USD layer as a reference and you maybe want to open your USD file as a stage. If that’s the case, we have an example of how to do that here:

https://docs.omniverse.nvidia.com/kit/docs/omni.kit.usd_docs/latest/Omni.USD.html#async-operations

And there’s more information about the omni.usd API here: Overview — omni.usd 1.9.0 documentation

If I run this code following the example you mentioned:

from omni.isaac.kit import SimulationApp

simulation_app = SimulationApp(
    launch_config={"renderer": "RayTracedLighting", "headless": True}
)


import omni.usd
from omni.kit.usd_docs import variant_example_usd_scene

usd_context = omni.usd.get_context()

result = omni.usd.get_context().open_stage(variant_example_usd_scene)
stage = omni.usd.get_context().get_stage()

print(f"opened stage {stage} with result {result}")

I get this error:

Traceback (most recent call last):
  File "prova.py", line 9, in <module>
    from omni.kit.usd_docs import variant_example_usd_scene
ModuleNotFoundError: No module named 'omni.kit.usd_docs'
2023-05-08 07:30:42 [9,398ms] [Warning] [carb.audio.context] 1 contexts were leaked
/home/federico/.local/share/ov/pkg/isaac_sim-2022.2.1/python.sh: line 41: 3999991 Segmentation fault      (core dumped) $python_exe "$@" $args
There was an error running python

Looks like you’re on the right track, but you should not import omni.kit.usd_docs. Remove this like entirely:

from omni.kit.usd_docs import variant_example_usd_scene

You should give open_stage() a filepath to the USD file you want to open.

result = omni.usd.get_context().open_stage("C:/the/path/to/my_stage.usd")