From 54bdf57fb75ca840f0c3290c6f3defe711fa3ad1 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Thu, 19 Sep 2024 01:13:34 -0400 Subject: [PATCH] Sanitize USD paths to prevent having dashes. --- glue_ar/common/usd_builder.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/glue_ar/common/usd_builder.py b/glue_ar/common/usd_builder.py index 715222c..1acbb40 100644 --- a/glue_ar/common/usd_builder.py +++ b/glue_ar/common/usd_builder.py @@ -15,8 +15,11 @@ def __init__(self, filepath: str): self._create_stage(filepath) self._material_map: Dict[MaterialInfo, UsdShade.Shader] = {} + def _sanitize(self, identifier: str) -> str: + return identifier.replace("-", "_") + def _create_stage(self, filepath: str): - self.stage = Usd.Stage.CreateNew(filepath) + self.stage = Usd.Stage.CreateNew(self._sanitize(filepath)) # TODO: Do we want to make changing this an option? UsdGeom.SetStageUpAxis(self.stage, UsdGeom.Tokens.y) @@ -63,6 +66,7 @@ def add_mesh(self, for other meshes that we create. """ identifier = identifier or unique_id() + identifier = self._sanitize(identifier) count = self._mesh_counts[identifier] xform_key = f"{self.default_prim_key}/xform_{identifier}_{count}" UsdGeom.Xform.Define(self.stage, xform_key) @@ -87,6 +91,7 @@ def add_translated_reference(self, identifier: Optional[str] = None) -> UsdGeom.Mesh: prim = mesh.GetPrim() identifier = identifier or unique_id() + identifier = self._sanitize(identifier) count = self._mesh_counts[identifier] xform_key = f"{self.default_prim_key}/xform_{identifier}_{count}" UsdGeom.Xform.Define(self.stage, xform_key)