From e644d94170dc21598790bfbf275f9a97925f79c4 Mon Sep 17 00:00:00 2001 From: Edouard Coussoux Date: Mon, 27 Oct 2025 18:13:37 +0100 Subject: [PATCH 1/2] fix: Add error message if extension is launched with empty HFSS 3D Layout design --- src/ansys/aedt/core/extensions/hfss3dlayout/cutout.py | 3 +++ tests/unit/extensions/test_cutout.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/ansys/aedt/core/extensions/hfss3dlayout/cutout.py b/src/ansys/aedt/core/extensions/hfss3dlayout/cutout.py index 59b5e1cd76c..81b5d321ae8 100644 --- a/src/ansys/aedt/core/extensions/hfss3dlayout/cutout.py +++ b/src/ansys/aedt/core/extensions/hfss3dlayout/cutout.py @@ -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(): diff --git a/tests/unit/extensions/test_cutout.py b/tests/unit/extensions/test_cutout.py index 3587d6e4a48..eb8360b8979 100644 --- a/tests/unit/extensions/test_cutout.py +++ b/tests/unit/extensions/test_cutout.py @@ -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" @@ -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 = { From a35d6a76aaf966bb6e972c512c67b18cc1eb5feb Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Mon, 27 Oct 2025 17:18:57 +0000 Subject: [PATCH 2/2] chore: adding changelog file 6822.fixed.md [dependabot-skip] --- doc/changelog.d/6822.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/6822.fixed.md diff --git a/doc/changelog.d/6822.fixed.md b/doc/changelog.d/6822.fixed.md new file mode 100644 index 00000000000..153b7561fbb --- /dev/null +++ b/doc/changelog.d/6822.fixed.md @@ -0,0 +1 @@ +Add error message if extension is started with an empty HFSS 3D Layout design