Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
3 changes: 3 additions & 0 deletions src/ansys/aedt/core/extensions/hfss3dlayout/cutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ def execute_cutout(self):
def __load_objects_net(self):
"""Load objects by net from the EDB modeler."""
res = defaultdict(list)
if not self.aedt_application.modeler.edb:
self.release_desktop()
raise AEDTRuntimeError("Extension cannot be used with an empty HFSS 3D Layout design.")
for net, net_objs in self.aedt_application.modeler.edb.modeler.primitives_by_net.items():
res[net].extend(obj.aedt_name for obj in net_objs)
for net_obj in self.aedt_application.modeler.edb.padstacks.instances.values():
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/extensions/test_cutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from ansys.aedt.core.extensions.hfss3dlayout.cutout import WAITING_FOR_SELECTION
from ansys.aedt.core.extensions.hfss3dlayout.cutout import CutoutData
from ansys.aedt.core.extensions.hfss3dlayout.cutout import CutoutExtension
from ansys.aedt.core.internal.errors import AEDTRuntimeError

MOCK_LINE_0 = "line__0"
MOCK_LINE_1 = "line__1"
Expand Down Expand Up @@ -79,6 +80,14 @@ def mock_hfss_3d_layout_with_primitives(request, mock_hfss_3d_layout_app):
yield mock_hfss_3d_layout_app


def test_cutout_extension_empty_design(mock_hfss_3d_layout_app):
"""Test that CutoutExtension raises an error if launched with an empty design."""
mock_hfss_3d_layout_app.modeler.edb = None

with pytest.raises(AEDTRuntimeError, match="Extension cannot be used with an empty HFSS 3D Layout design."):
CutoutExtension(withdraw=True)


def test_cutout_extension_default(mock_hfss_3d_layout_with_primitives):
"""Test instantiation of CutoutExtension with default parameters."""
EXPECTED_OBJS_NET = {
Expand Down
Loading