Skip to content

Commit fe74571

Browse files
authored
Return the correct stage path when using layer_structure=False (#42)
1 parent ac7f9e7 commit fe74571

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

mujoco_usd_converter/_impl/_flatten.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .utils import get_authoring_metadata
1212

1313

14-
def export_flattened(asset_stage: Usd.Stage, output_dir: str, asset_dir: str, asset_stem: str, asset_format: str, comment: str):
14+
def export_flattened(asset_stage: Usd.Stage, output_dir: str, asset_dir: str, asset_stem: str, asset_format: str, comment: str) -> str:
1515
output_path = pathlib.Path(output_dir)
1616
layer: Sdf.Layer = asset_stage.Flatten()
1717
asset_identifier = f"{output_path.absolute().as_posix()}/{asset_stem}.{asset_format}"
@@ -40,3 +40,4 @@ def export_flattened(asset_stage: Usd.Stage, output_dir: str, asset_dir: str, as
4040
Tf.Status(f"Copied textures from {temp_textures_dir} to {output_textures_dir}")
4141

4242
shutil.rmtree(asset_dir, ignore_errors=True)
43+
return asset_identifier

mujoco_usd_converter/_impl/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def convert(self, input_file: str, output_dir: str) -> Sdf.AssetPath:
126126

127127
# optionally flatten the asset
128128
if not self.params.layer_structure:
129-
export_flattened(asset_stage, output_dir, asset_dir, asset_stem, asset_format, self.params.comment)
129+
asset_identifier = export_flattened(asset_stage, output_dir, asset_dir, asset_stem, asset_format, self.params.comment)
130130
else:
131131
usdex.core.saveStage(asset_stage, comment=self.params.comment)
132132

tests/testAssetStructure.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,11 @@ def test_no_layer_structure_material_texture(self):
360360
[(Tf.TF_DIAGNOSTIC_WARNING_TYPE, ".*will discard textures at render time")],
361361
level=usdex.core.DiagnosticsLevel.eWarning,
362362
):
363-
mujoco_usd_converter.Converter(layer_structure=False).convert(model, output_dir)
363+
asset_identifier = mujoco_usd_converter.Converter(layer_structure=False).convert(model, output_dir)
364+
365+
# check that the asset identifier returned from convert() is the same as the usdc path
366+
flattened_usdc_path = pathlib.Path(asset_identifier.path).absolute().as_posix()
367+
self.assertEqual(flattened_usdc_path, usdc_path.absolute().as_posix())
364368

365369
# check usdc and texture
366370
self.assertTrue(usdc_path.exists(), f"{usdc_path} not found")

0 commit comments

Comments
 (0)