Skip to content

Commit

Permalink
fix: Validate input mesh name for USD compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fan-ziqi committed Oct 25, 2024
1 parent be52603 commit 3079480
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 3079480

Please sign in to comment.