Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Mesh assignment update for 24R2 new APIs #5558

Merged
merged 20 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6790a44
FIX: update for 24R2 new APIs
lorenzovecchietti Dec 11, 2024
021436c
TEST: change order of tests
lorenzovecchietti Dec 11, 2024
da84869
Merge branch 'main' into fix/issue_5485
lorenzovecchietti Dec 11, 2024
52d9b6e
TEST: avoid error for overlapping mesh regions
lorenzovecchietti Dec 12, 2024
31aafbf
Merge remote-tracking branch 'origin/fix/issue_5485' into fix/issue_5485
lorenzovecchietti Dec 12, 2024
83a1267
Merge branch 'main' into fix/issue_5485
lorenzovecchietti Dec 12, 2024
7ff1cb2
Merge branch 'main' into fix/issue_5485
lorenzovecchietti Dec 13, 2024
c950891
TEST: avoid error for overlapping mesh regions
lorenzovecchietti Dec 16, 2024
5cd6ea2
Merge branch 'main' into fix/issue_5485
lorenzovecchietti Dec 16, 2024
729250f
TEST: fix Unused variable 'mess1'
lorenzovecchietti Dec 16, 2024
60cbdbe
Merge remote-tracking branch 'origin/fix/issue_5485' into fix/issue_5485
lorenzovecchietti Dec 16, 2024
72e1e10
Merge branch 'main' into fix/issue_5485
lorenzovecchietti Dec 16, 2024
1fd0efd
TEST: remove coverage from code for backward compatibility
lorenzovecchietti Dec 19, 2024
4660163
Merge remote-tracking branch 'origin/fix/issue_5485' into fix/issue_5485
lorenzovecchietti Dec 19, 2024
3568c4d
Merge branch 'main' into fix/issue_5485
lorenzovecchietti Dec 19, 2024
64bcdc8
Merge branch 'main' into fix/issue_5485
Samuelopez-ansys Dec 20, 2024
12f3443
Merge branch 'main' into fix/issue_5485
Samuelopez-ansys Dec 20, 2024
094f810
TEST: improve coverage
lorenzovecchietti Dec 24, 2024
8c6e0a3
Merge remote-tracking branch 'origin/fix/issue_5485' into fix/issue_5485
lorenzovecchietti Dec 24, 2024
1e18a71
Merge branch 'main' into fix/issue_5485
lorenzovecchietti Dec 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 33 additions & 30 deletions src/ansys/aedt/core/modules/mesh_icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,38 +913,41 @@
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")
# 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():
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 = (

Check warning on line 948 in src/ansys/aedt/core/modules/mesh_icepak.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modules/mesh_icepak.py#L948

Added line #L948 was not covered by tests
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 = []
history = self._app.modeler[sr].history()
history_props = history.properties
if "Part Names" in history_props:
p1 = history_props.get("Part Names", None)
if not isinstance(p1, list):
p1 = [p1]
elif "Submodel Names" in history_props:
p2 = history_props.get("Submodel Names", None)
if not isinstance(p2, list):
p2 = [p2]
p1 += p2
if "CreateSubRegion" == 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
Expand Down
20 changes: 15 additions & 5 deletions tests/system/general/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ def test_03_AssignPCBRegion(self):
assert self.aedtapp.mesh.meshregions_dict
assert pcb_mesh_region.delete()

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)

Expand Down Expand Up @@ -376,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)
Expand Down Expand Up @@ -2013,3 +2013,13 @@ 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=[100, 100, 100], radius=2, height=15)
mesh_class = self.aedtapp.mesh
m1 = mesh_class.assign_mesh_region([c1.name])
m2 = mesh_class.assign_mesh_region([c2.name])
assert m1.assignment.name != m2.assignment.name
Loading