diff --git a/src/ansys/motorcad/core/geometry.py b/src/ansys/motorcad/core/geometry.py index b78dca47f..92a047183 100644 --- a/src/ansys/motorcad/core/geometry.py +++ b/src/ansys/motorcad/core/geometry.py @@ -36,6 +36,7 @@ class Region(object): def __init__(self, motorcad_instance=None): """Create geometry region and set parameters to defaults.""" self.name = "" + self._base_name = "" self.material = "air" self.colour = (0, 0, 0) self.area = 0.0 @@ -175,7 +176,14 @@ def _from_json(cls, json, motorcad_instance=None): new_region._region_type = RegionType(json["region_type"]) # self.Entities = json.Entities - new_region.name = json["name"] + + if "name_unique" in json: + new_region.name = json["name_unique"] + else: + new_region.name = json["name"] + + new_region._base_name = json["name"] + new_region.material = json["material"] new_region.colour = (json["colour"]["r"], json["colour"]["g"], json["colour"]["b"]) @@ -217,6 +225,7 @@ def _to_json(self): region_dict = { "name": self.name, + "name_base": self._base_name, "material": self.material, "colour": {"r": self.colour[0], "g": self.colour[1], "b": self.colour[2]}, "area": self.area, diff --git a/tests/test_geometry.py b/tests/test_geometry.py index 815e1a01b..5299ecb78 100644 --- a/tests/test_geometry.py +++ b/tests/test_geometry.py @@ -343,6 +343,7 @@ def test_region_remove_entity(): def test_region_from_json(): raw_region = { "name": "test_region", + "name_base": "test_region_base", "material": "copper", "colour": {"r": 240, "g": 0, "b": 0}, "area": 5.1, @@ -359,6 +360,7 @@ def test_region_from_json(): test_region = geometry.Region() test_region.name = "test_region" + test_region._base_name = "test_region_base" test_region.material = "copper" test_region.colour = (240, 0, 0) test_region.area = 5.1 @@ -379,6 +381,7 @@ def test_region_from_json(): def test_region_to_json(): raw_region = { "name": "test_region", + "name_base": "test_region_base", "material": "copper", "colour": {"r": 240, "g": 0, "b": 0}, "area": 5.1, @@ -396,6 +399,7 @@ def test_region_to_json(): test_region = geometry.Region() test_region.name = "test_region" + test_region._base_name = "test_region_base" test_region.material = "copper" test_region.colour = (240, 0, 0) test_region.area = 5.1