From 6790a44daadbc8042aec23bfb7e7e77fd27063f8 Mon Sep 17 00:00:00 2001 From: lorenzovecchietti Date: Wed, 11 Dec 2024 10:37:00 +0100 Subject: [PATCH 1/7] FIX: update for 24R2 new APIs --- src/ansys/aedt/core/modules/mesh_icepak.py | 61 ++++++++++++---------- tests/system/general/test_98_Icepak.py | 13 +++++ 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/ansys/aedt/core/modules/mesh_icepak.py b/src/ansys/aedt/core/modules/mesh_icepak.py index c58b9778459..339d711a86b 100644 --- a/src/ansys/aedt/core/modules/mesh_icepak.py +++ b/src/ansys/aedt/core/modules/mesh_icepak.py @@ -862,36 +862,41 @@ def assignment(self): list """ if isinstance(self._assignment, SubRegion): - # try to update name if self.name in self._app.odesign.GetChildObject("Mesh").GetChildNames(): - parts = [] - subparts = [] - if "Parts" in self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropNames(): - parts = self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropValue("Parts") - if "Submodels" in self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropNames(): - subparts = ( - self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropValue("Submodels") + if self._app.settings.aedt_version < "2024.2": + # try to update name, APIs lacking a lot + parts = [] + subparts = [] + if "Parts" in self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropNames(): + parts = self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropValue("Parts") + if "Submodels" in self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropNames(): + subparts = ( + self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropValue("Submodels") + ) + if not isinstance(parts, list): + parts = [parts] + if not isinstance(subparts, list): + subparts = [subparts] + parts += subparts + sub_regions = self._app.modeler.non_model_objects + for sr in sub_regions: + p1 = [] + p2 = [] + if "Part Names" in self._app.modeler[sr].history().props: + p1 = self._app.modeler[sr].history().props.get("Part Names", None) + if not isinstance(p1, list): + p1 = [p1] + elif "Submodel Names" in self._app.modeler[sr].history().props: + p2 = self._app.modeler[sr].history().props.get("Submodel Names", None) + if not isinstance(p2, list): + p2 = [p2] + p1 += p2 + if "CreateSubRegion" == self._app.modeler[sr].history().command and all(p in p1 for p in parts): + self._assignment.name = sr + else: + self._assignment.name = ( + self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropValue("Assignment") ) - if not isinstance(parts, list): - parts = [parts] - if not isinstance(subparts, list): - subparts = [subparts] - parts += subparts - sub_regions = self._app.modeler.non_model_objects - for sr in sub_regions: - p1 = [] - p2 = [] - if "Part Names" in self._app.modeler[sr].history().props: - p1 = self._app.modeler[sr].history().props.get("Part Names", None) - if not isinstance(p1, list): - p1 = [p1] - elif "Submodel Names" in self._app.modeler[sr].history().props: - p2 = self._app.modeler[sr].history().props.get("Submodel Names", None) - if not isinstance(p2, list): - p2 = [p2] - p1 += p2 - if "CreateSubRegion" == self._app.modeler[sr].history().command and all(p in p1 for p in parts): - self._assignment.name = sr return self._assignment elif isinstance(self._assignment, list): return self._assignment diff --git a/tests/system/general/test_98_Icepak.py b/tests/system/general/test_98_Icepak.py index e1184c056e1..91d829bda34 100644 --- a/tests/system/general/test_98_Icepak.py +++ b/tests/system/general/test_98_Icepak.py @@ -318,6 +318,19 @@ def test_03_AssignPCBRegion(self): assert self.aedtapp.mesh.meshregions_dict assert pcb_mesh_region.delete() + def test_03b_MultipleMeshRegions(self): + # test issue 5485 + self.aedtapp.insert_design("test03b") + c1 = self.aedtapp.modeler.create_cylinder(orientation=0, origin=[0, 0, 0], radius=5, height=10) + c2 = self.aedtapp.modeler.create_cylinder(orientation=1, origin=[1, 1, 1], radius=2, height=15) + mesh_class = self.aedtapp.mesh + mess1 = self.aedtapp.logger.get_messages() + m1 = mesh_class.assign_mesh_region([c1.name, c2.name]) + m2 = mesh_class.assign_mesh_region([c2.name]) + assert m1.assignment.name != m2.assignment.name + mess2 = self.aedtapp.logger.get_messages() + assert len(mess1.global_level) == len(mess2.global_level) + def test_04_ImportGroup(self): assert self.aedtapp.copyGroupFrom("Group1", "uUSB", src_project_name, self.project_path) From 021436c174d44d111146af3bb92078b2cc3b4642 Mon Sep 17 00:00:00 2001 From: lorenzovecchietti Date: Wed, 11 Dec 2024 15:12:23 +0100 Subject: [PATCH 2/7] TEST: change order of tests --- tests/system/general/test_98_Icepak.py | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/system/general/test_98_Icepak.py b/tests/system/general/test_98_Icepak.py index 91d829bda34..aa54fa4f09c 100644 --- a/tests/system/general/test_98_Icepak.py +++ b/tests/system/general/test_98_Icepak.py @@ -318,18 +318,10 @@ def test_03_AssignPCBRegion(self): assert self.aedtapp.mesh.meshregions_dict assert pcb_mesh_region.delete() - def test_03b_MultipleMeshRegions(self): - # test issue 5485 - self.aedtapp.insert_design("test03b") - c1 = self.aedtapp.modeler.create_cylinder(orientation=0, origin=[0, 0, 0], radius=5, height=10) - c2 = self.aedtapp.modeler.create_cylinder(orientation=1, origin=[1, 1, 1], radius=2, height=15) - mesh_class = self.aedtapp.mesh - mess1 = self.aedtapp.logger.get_messages() - m1 = mesh_class.assign_mesh_region([c1.name, c2.name]) - m2 = mesh_class.assign_mesh_region([c2.name]) - assert m1.assignment.name != m2.assignment.name - mess2 = self.aedtapp.logger.get_messages() - assert len(mess1.global_level) == len(mess2.global_level) + def test_07_ExportStepForWB(self): + file_path = self.local_scratch.path + file_name = "WBStepModel" + assert self.aedtapp.export_3d_model(file_name, file_path, ".x_t", [], ["Region", "Component_Region"]) def test_04_ImportGroup(self): assert self.aedtapp.copyGroupFrom("Group1", "uUSB", src_project_name, self.project_path) @@ -389,11 +381,6 @@ def test_05_EMLoss(self): def test_06_clear_linked_data(self): assert self.aedtapp.clear_linked_data() - def test_07_ExportStepForWB(self): - file_path = self.local_scratch.path - file_name = "WBStepModel" - assert self.aedtapp.export_3d_model(file_name, file_path, ".x_t", [], ["Region", "Component_Region"]) - def test_08_Setup(self): setup_name = "DomSetup" my_setup = self.aedtapp.create_setup(setup_name) @@ -2018,3 +2005,16 @@ def test_82_folder_settings(self, add_app): fs.scale_settings.unit = "kel" assert fs.scale_settings.unit == "kel" app.close_project() + + def test_83_MultipleMeshRegions(self): + # test issue 5485 + self.aedtapp.insert_design("test83") + c1 = self.aedtapp.modeler.create_cylinder(orientation=0, origin=[0, 0, 0], radius=5, height=10) + c2 = self.aedtapp.modeler.create_cylinder(orientation=1, origin=[1, 1, 1], radius=2, height=15) + mesh_class = self.aedtapp.mesh + mess1 = self.aedtapp.logger.get_messages() + m1 = mesh_class.assign_mesh_region([c1.name, c2.name]) + m2 = mesh_class.assign_mesh_region([c2.name]) + assert m1.assignment.name != m2.assignment.name + mess2 = self.aedtapp.logger.get_messages() + assert len(mess1.global_level) == len(mess2.global_level) From 52d9b6eb8b920aa332ab265d5b01ade05e200ee1 Mon Sep 17 00:00:00 2001 From: lorenzovecchietti Date: Thu, 12 Dec 2024 13:48:33 +0100 Subject: [PATCH 3/7] TEST: avoid error for overlapping mesh regions --- tests/system/general/test_98_Icepak.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/system/general/test_98_Icepak.py b/tests/system/general/test_98_Icepak.py index aa54fa4f09c..fdaf43ea67d 100644 --- a/tests/system/general/test_98_Icepak.py +++ b/tests/system/general/test_98_Icepak.py @@ -2010,10 +2010,10 @@ def test_83_MultipleMeshRegions(self): # test issue 5485 self.aedtapp.insert_design("test83") c1 = self.aedtapp.modeler.create_cylinder(orientation=0, origin=[0, 0, 0], radius=5, height=10) - c2 = self.aedtapp.modeler.create_cylinder(orientation=1, origin=[1, 1, 1], radius=2, height=15) + c2 = self.aedtapp.modeler.create_cylinder(orientation=1, origin=[100, 100, 100], radius=2, height=15) mesh_class = self.aedtapp.mesh mess1 = self.aedtapp.logger.get_messages() - m1 = mesh_class.assign_mesh_region([c1.name, c2.name]) + m1 = mesh_class.assign_mesh_region([c1.name]) m2 = mesh_class.assign_mesh_region([c2.name]) assert m1.assignment.name != m2.assignment.name mess2 = self.aedtapp.logger.get_messages() From c9508912d952fda56881de6f7b35c8f01297f6c2 Mon Sep 17 00:00:00 2001 From: lorenzovecchietti Date: Mon, 16 Dec 2024 09:22:01 +0100 Subject: [PATCH 4/7] TEST: avoid error for overlapping mesh regions --- tests/system/general/test_98_Icepak.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/system/general/test_98_Icepak.py b/tests/system/general/test_98_Icepak.py index 0bff7a08321..3e6aed070d6 100644 --- a/tests/system/general/test_98_Icepak.py +++ b/tests/system/general/test_98_Icepak.py @@ -2018,5 +2018,3 @@ def test_83_MultipleMeshRegions(self): m1 = mesh_class.assign_mesh_region([c1.name]) m2 = mesh_class.assign_mesh_region([c2.name]) assert m1.assignment.name != m2.assignment.name - mess2 = self.aedtapp.logger.get_messages() - assert len(mess1.global_level) == len(mess2.global_level) From 729250fcb3826b00528af5b32e4c2829027f0dd3 Mon Sep 17 00:00:00 2001 From: lorenzovecchietti Date: Mon, 16 Dec 2024 09:55:18 +0100 Subject: [PATCH 5/7] TEST: fix Unused variable 'mess1' --- tests/system/general/test_98_Icepak.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/system/general/test_98_Icepak.py b/tests/system/general/test_98_Icepak.py index 3e6aed070d6..4149c69d8e0 100644 --- a/tests/system/general/test_98_Icepak.py +++ b/tests/system/general/test_98_Icepak.py @@ -2014,7 +2014,6 @@ def test_83_MultipleMeshRegions(self): c1 = self.aedtapp.modeler.create_cylinder(orientation=0, origin=[0, 0, 0], radius=5, height=10) c2 = self.aedtapp.modeler.create_cylinder(orientation=1, origin=[100, 100, 100], radius=2, height=15) mesh_class = self.aedtapp.mesh - mess1 = self.aedtapp.logger.get_messages() m1 = mesh_class.assign_mesh_region([c1.name]) m2 = mesh_class.assign_mesh_region([c2.name]) assert m1.assignment.name != m2.assignment.name From 1fd0efdabafebccc0d497aaeec8a0694748b03ec Mon Sep 17 00:00:00 2001 From: lorenzovecchietti Date: Thu, 19 Dec 2024 09:10:20 +0100 Subject: [PATCH 6/7] TEST: remove coverage from code for backward compatibility --- src/ansys/aedt/core/modules/mesh_icepak.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansys/aedt/core/modules/mesh_icepak.py b/src/ansys/aedt/core/modules/mesh_icepak.py index d1a4b5052ad..184ad6c9498 100644 --- a/src/ansys/aedt/core/modules/mesh_icepak.py +++ b/src/ansys/aedt/core/modules/mesh_icepak.py @@ -870,8 +870,8 @@ def assignment(self): """ if isinstance(self._assignment, SubRegion): if self.name in self._app.odesign.GetChildObject("Mesh").GetChildNames(): - if self._app.settings.aedt_version < "2024.2": - # try to update name, APIs lacking a lot + if self._app.settings.aedt_version < "2024.2": # pragma : no cover + # try to update name, APIs lacking an easy method before 242 parts = [] subparts = [] if "Parts" in self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropNames(): From 094f8105e181aaec967b0fb835d2d217a104b16b Mon Sep 17 00:00:00 2001 From: lorenzovecchietti Date: Tue, 24 Dec 2024 10:27:31 +0100 Subject: [PATCH 7/7] TEST: improve coverage --- src/ansys/aedt/core/modules/mesh_icepak.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansys/aedt/core/modules/mesh_icepak.py b/src/ansys/aedt/core/modules/mesh_icepak.py index 184ad6c9498..a440ec3f077 100644 --- a/src/ansys/aedt/core/modules/mesh_icepak.py +++ b/src/ansys/aedt/core/modules/mesh_icepak.py @@ -870,8 +870,8 @@ def assignment(self): """ if isinstance(self._assignment, SubRegion): if self.name in self._app.odesign.GetChildObject("Mesh").GetChildNames(): - if self._app.settings.aedt_version < "2024.2": # pragma : no cover - # try to update name, APIs lacking an easy method before 242 + # try to update name, APIs lacking an easy method before 242 + if self._app.settings.aedt_version < "2024.2": # pragma: no cover parts = [] subparts = [] if "Parts" in self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropNames():