diff --git a/source/extensions/omni.isaac.lab/omni/isaac/lab/sim/converters/mesh_converter.py b/source/extensions/omni.isaac.lab/omni/isaac/lab/sim/converters/mesh_converter.py index 8a42138644..a33d158ce1 100644 --- a/source/extensions/omni.isaac.lab/omni/isaac/lab/sim/converters/mesh_converter.py +++ b/source/extensions/omni.isaac.lab/omni/isaac/lab/sim/converters/mesh_converter.py @@ -10,7 +10,7 @@ import omni.kit.commands import omni.usd from omni.isaac.core.utils.extensions import enable_extension -from pxr import Usd, UsdGeom, UsdPhysics, UsdUtils +from pxr import Tf, Usd, UsdGeom, UsdPhysics, UsdUtils from omni.isaac.lab.sim.converters.asset_converter_base import AssetConverterBase from omni.isaac.lab.sim.converters.mesh_converter_cfg import MeshConverterCfg @@ -81,6 +81,17 @@ def _convert_asset(self, cfg: MeshConverterCfg): mesh_file_basename, mesh_file_format = os.path.basename(cfg.asset_path).split(".") mesh_file_format = mesh_file_format.lower() + # Check if mesh_file_basename is a valid USD identifier + if not Tf.IsValidIdentifier(mesh_file_basename): + # Correct the name to a valid identifier + corrected_name = Tf.MakeValidIdentifier(mesh_file_basename) + print( + f"Warning: File name '{mesh_file_basename}.{mesh_file_format}' is invalid for the input mesh path." + f" Using '{corrected_name}.{mesh_file_format}' as the identifier for this conversion." + ) + # Update the basename + mesh_file_basename = corrected_name + # Convert USD asyncio.get_event_loop().run_until_complete( self._convert_mesh_to_usd(