How to add an Isaacsim asset through Python API

Isaac Sim Version

4.5.0
4.2.0
4.1.0
4.0.0
4.5.0
2023.1.1
2023.1.0-hotfix.1
Other (please specify):

Operating System

Ubuntu 22.04
Ubuntu 20.04
Windows 11
Windows 10
Other (please specify):

GPU Information

  • Model: A4500

How to add an Isaacsim asset through Python script API

Detailed Description

Adding mesh prims is well documented but I couldn’t find an example of how to add an Isaacsim asset (E.g., factory gear) through the Python script API with its visualization and collision meshes.

The following piece of code doesn’t work (usd file was copied to this path):

factory_large_gear_usd_asset_path = "standalone_examples/factory_gear_large.usd"
factory_large_gear_prim_path = "/World/factory_gear_large"

itemPrim = stage.DefinePrim(factory_large_gear_prim_path, "Xform")
itemPrim.GetReferences().AddReference(
    assetPath = factory_large_gear_usd_asset_path,
    primPath = factory_large_gear_prim_path)
xformable = UsdGeom.Xformable(itemPrim)

# Move cube (translate)
xformable.AddTranslateOp().Set(value=(10, 0, 12))

# Rotate
xformable.AddRotateXYZOp().Set(Gf.Vec3d(0, 1, 0))

# Scale
xformable.AddScaleOp().Set((5, 10, 5))

Screenshots or Videos

Using the GUI it is straightforward:

Have you tried something like:


from omni.isaac.core.utils import stage as stage_utils
stage_utils.add_reference_to_stage(usd_path=usd_file_path, prim_path="/World")
2 Likes

If you want to add Assets from the asset browser, you have to use the assets_root_path from Isaac Sim, for example with your gear:

from isaacsim.core.utils.stage import add_reference_to_stage
from isaacsim.storage.native import get_assets_root_path

assets_root_path = get_assets_root_path()
asset_path = assets_root_path + "/Isaac/IsaacLab/Factory/factory_gear_large.usd"
add_reference_to_stage(asset_path, "/large_gear")
1 Like

It works! Thank you.

1 Like

Thank you for the answer.

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