File tree Expand file tree Collapse file tree
isaaclab/sim/spawners/materials Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66from __future__ import annotations
77
88import importlib .util
9+ import os
910from pathlib import Path
1011from typing import TYPE_CHECKING
1112
@@ -119,13 +120,18 @@ def spawn_from_mdl_file(
119120
120121 mdl_path = cfg .mdl_path .format (NVIDIA_NUCLEUS_DIR = NVIDIA_NUCLEUS_DIR )
121122 if Path (mdl_path ).name == mdl_path :
123+ # Archive installs expose the Kit root directly; pip installs nest it inside isaacsim.
124+ kit_paths = []
125+ if carb_app_path := os .environ .get ("CARB_APP_PATH" ):
126+ kit_paths .append (Path (carb_app_path ))
122127 isaacsim_spec = importlib .util .find_spec ("isaacsim" )
123128 if isaacsim_spec is not None and isaacsim_spec .submodule_search_locations :
124- for location in isaacsim_spec .submodule_search_locations :
125- builtin_path = Path (location ) / "kit/mdl/core/Base" / mdl_path
126- if builtin_path .is_file ():
127- mdl_path = str (builtin_path )
128- break
129+ kit_paths .extend (Path (location ) / "kit" for location in isaacsim_spec .submodule_search_locations )
130+ for kit_path in kit_paths :
131+ builtin_path = kit_path / "mdl/core/Base" / mdl_path
132+ if builtin_path .is_file ():
133+ mdl_path = str (builtin_path )
134+ break
129135 material_name = Path (mdl_path ).stem
130136 material_prim = UsdShade .Material .Define (stage , prim_path )
131137 shader = UsdShade .Shader .Define (stage , f"{ prim_path } /Shader" )
Original file line number Diff line number Diff line change @@ -56,3 +56,17 @@ def test_builtin_mdl_authors_and_binds_without_kit() -> None:
5656 Sdf .Path ("/World/Looks/OmniPBR/Shader.outputs:out" )
5757 ]
5858 _make_cube_and_bind (stage , "/World/Looks/OmniPBR" )
59+
60+
61+ def test_builtin_mdl_resolves_archive_kit_path (tmp_path : Path , monkeypatch : pytest .MonkeyPatch ) -> None :
62+ mdl_path = tmp_path / "mdl/core/Base/OmniPBR.mdl"
63+ mdl_path .parent .mkdir (parents = True )
64+ mdl_path .touch ()
65+ monkeypatch .setenv ("CARB_APP_PATH" , str (tmp_path ))
66+ stage = sim_utils .create_new_stage ()
67+ cfg = sim_utils .MdlFileCfg (mdl_path = "OmniPBR.mdl" )
68+
69+ shader_prim = cfg .func ("/World/Looks/OmniPBR" , cfg )
70+
71+ assert Path (UsdShade .Shader (shader_prim ).GetSourceAsset ("mdl" ).path ) == mdl_path
72+ assert stage .GetPrimAtPath ("/World/Looks/OmniPBR" ).IsValid ()
You can’t perform that action at this time.
0 commit comments