Skip to content

Commit 3241dff

Browse files
ecoussoux-ansyspyansys-ci-botSMoraisAnsys
authored
FIX: Add error message if extension is started with an empty HFSS 3D Layout design (#6822)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Sébastien Morais <[email protected]>
1 parent 0327d79 commit 3241dff

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

doc/changelog.d/6822.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add error message if extension is started with an empty HFSS 3D Layout design

src/ansys/aedt/core/extensions/hfss3dlayout/cutout.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ def execute_cutout(self):
209209
def __load_objects_net(self):
210210
"""Load objects by net from the EDB modeler."""
211211
res = defaultdict(list)
212+
if not self.aedt_application.modeler.edb:
213+
self.release_desktop()
214+
raise AEDTRuntimeError("Extension cannot be used with an empty HFSS 3D Layout design.")
212215
for net, net_objs in self.aedt_application.modeler.edb.modeler.primitives_by_net.items():
213216
res[net].extend(obj.aedt_name for obj in net_objs)
214217
for net_obj in self.aedt_application.modeler.edb.padstacks.instances.values():

tests/unit/extensions/test_cutout.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from ansys.aedt.core.extensions.hfss3dlayout.cutout import WAITING_FOR_SELECTION
3636
from ansys.aedt.core.extensions.hfss3dlayout.cutout import CutoutData
3737
from ansys.aedt.core.extensions.hfss3dlayout.cutout import CutoutExtension
38+
from ansys.aedt.core.internal.errors import AEDTRuntimeError
3839

3940
MOCK_LINE_0 = "line__0"
4041
MOCK_LINE_1 = "line__1"
@@ -79,6 +80,14 @@ def mock_hfss_3d_layout_with_primitives(request, mock_hfss_3d_layout_app):
7980
yield mock_hfss_3d_layout_app
8081

8182

83+
def test_cutout_extension_empty_design(mock_hfss_3d_layout_app):
84+
"""Test that CutoutExtension raises an error if launched with an empty design."""
85+
mock_hfss_3d_layout_app.modeler.edb = None
86+
87+
with pytest.raises(AEDTRuntimeError, match="Extension cannot be used with an empty HFSS 3D Layout design."):
88+
CutoutExtension(withdraw=True)
89+
90+
8291
def test_cutout_extension_default(mock_hfss_3d_layout_with_primitives):
8392
"""Test instantiation of CutoutExtension with default parameters."""
8493
EXPECTED_OBJS_NET = {

0 commit comments

Comments
 (0)