Skip to content

Commit a89e278

Browse files
ramin4667pyansys-ci-botSMoraisAnsyspre-commit-ci[bot]maxcapodi78
authored
FIX: COM connection (#7465)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Co-authored-by: Sébastien Morais <146729917+SMoraisAnsys@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Massimo Capodiferro <77293250+maxcapodi78@users.noreply.github.com> Co-authored-by: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com>
1 parent 9e14954 commit a89e278

4 files changed

Lines changed: 37 additions & 39 deletions

File tree

doc/changelog.d/7465.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
COM connection

src/ansys/aedt/core/desktop.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,14 @@ def __init__(
674674

675675
self.logger.info(f"AEDT version {self.aedt_version_id}{' Student' if student_version else ''}.")
676676

677+
# Determine the starting mode (grpc, com, or console) based on environment,
678+
# user preferences, and whether we are connecting to an existing session.
679+
self.check_starting_mode()
680+
677681
if aedt_versions.is_pyaedt_in_edt():
678682
self.logger.info("PyAEDT launched from AEDT installation folder. Forcing grpc mode.")
679683
self.__starting_mode = "grpc"
684+
680685
# Starting AEDT
681686
if "console" in self.__starting_mode: # pragma no cover
682687
# technically not a startup mode, we have just to load oDesktop
@@ -691,6 +696,8 @@ def __init__(
691696
settings.aedt_version = self.aedt_version_id
692697
if self.__starting_mode == "com": # pragma no cover
693698
self.logger.info("Launching PyAEDT with CPython and PythonNET.")
699+
self.is_grpc_api = False
700+
self.new_desktop = new_desktop
694701
self.__init_dotnet()
695702
elif self.__starting_mode == "grpc":
696703
result = self.__init_grpc()

tests/system/filter_solutions/test_desktop_types.py

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,84 +29,77 @@
2929
from ansys.aedt.core import Hfss3dLayout
3030
from ansys.aedt.core.generic.settings import is_linux
3131
from tests.conftest import DESKTOP_VERSION
32-
from tests.conftest import USE_GRPC
3332

3433

3534
@pytest.mark.skipif(is_linux, reason="FilterSolutions API is not supported on Linux.")
36-
@pytest.mark.skipif(
37-
DESKTOP_VERSION < "2026.1" or USE_GRPC, reason="Skipped on versions earlier than 2026.1 or gRPC mode"
38-
)
35+
@pytest.mark.skipif(DESKTOP_VERSION < "2026.1", reason="Skipped on versions earlier than 2026.1")
3936
class TestClass:
4037
def test_lumped_exported_desktop(self, lumped_design):
4138
schem_name = lumped_design.export_to_aedt.schematic_name
4239
schem_name_length = len(schem_name)
43-
app = lumped_design.export_to_aedt.export_design()
4440
circuit = lumped_design.export_to_aedt.export_design()
4541
assert isinstance(circuit, Circuit)
4642
assert circuit.project_name.split()[0][:schem_name_length] == schem_name
4743
assert circuit.design_name == schem_name
4844
assert next(iter(circuit.setup_sweeps_names)) == "FS_Advanced Setup"
4945
variables = circuit.variable_manager.variables
50-
assert variables["C1"].value == pytest.approx(1.967e-12)
51-
assert variables["L2"].value == pytest.approx(1.288e-8)
52-
assert variables["C3"].value == pytest.approx(6.366e-12)
53-
app.desktop_class.close_desktop()
46+
assert variables["C1"].si_value == pytest.approx(1.967e-12)
47+
assert variables["L2"].si_value == pytest.approx(1.288e-8)
48+
assert variables["C3"].si_value == pytest.approx(6.366e-12)
49+
circuit.desktop_class.close_desktop()
5450

5551
def test_distributed_circuit_exported_desktop(self, distributed_design):
5652
schem_name = distributed_design.export_to_aedt.schematic_name
5753
schem_name_length = len(schem_name)
5854
distributed_design.export_to_aedt.insert_circuit_design = True
59-
app = distributed_design.export_to_aedt.export_design()
6055
circuit = distributed_design.export_to_aedt.export_design()
6156
assert isinstance(circuit, Circuit)
6257
assert circuit.project_name.split()[0][:schem_name_length] == schem_name
6358
assert circuit.design_name == schem_name
6459
assert next(iter(circuit.setup_sweeps_names)) == "FS_Advanced Setup"
6560
variables = circuit.variable_manager.variables
66-
assert variables["W1"].value == pytest.approx(5.08e-3)
67-
assert variables["W2"].value == pytest.approx(3.175e-4)
68-
assert variables["W3"].value == pytest.approx(5.08e-3)
69-
assert variables["S1"].value == pytest.approx(3.362e-3)
70-
assert variables["S2"].value == pytest.approx(2.172e-2)
71-
assert variables["S3"].value == pytest.approx(1.008e-2)
72-
app.desktop_class.close_desktop()
61+
assert variables["W1"].si_value == pytest.approx(5.08e-3)
62+
assert variables["W2"].si_value == pytest.approx(3.175e-4)
63+
assert variables["W3"].si_value == pytest.approx(5.08e-3)
64+
assert variables["S1"].si_value == pytest.approx(3.362e-3)
65+
assert variables["S2"].si_value == pytest.approx(2.172e-2)
66+
assert variables["S3"].si_value == pytest.approx(1.008e-2)
67+
circuit.desktop_class.close_desktop()
7368

7469
def test_distributed_hfss3dl_exported_desktop(self, distributed_design):
7570
schem_name = distributed_design.export_to_aedt.schematic_name
7671
schem_name_length = len(schem_name)
7772
distributed_design.export_to_aedt.insert_hfss_3dl_design = True
78-
app = distributed_design.export_to_aedt.export_design()
7973
hfss3dl = distributed_design.export_to_aedt.export_design()
8074
assert isinstance(hfss3dl, Hfss3dLayout)
8175
assert hfss3dl.project_name.split()[0][:schem_name_length] == schem_name
8276
assert hfss3dl.design_name == schem_name
8377
assert next(iter(hfss3dl.setup_sweeps_names)) == "FS_Advanced Setup"
8478
variables = hfss3dl.variable_manager.variables
85-
assert variables["Win"].value == pytest.approx(1.234e-3)
86-
assert variables["W1"].value == pytest.approx(5.08e-3)
87-
assert variables["W2"].value == pytest.approx(3.175e-4)
88-
assert variables["W3"].value == pytest.approx(5.08e-3)
89-
assert variables["S1"].value == pytest.approx(3.36225452227e-3)
90-
assert variables["S2"].value == pytest.approx(2.17231965814e-2)
91-
assert variables["S3"].value == pytest.approx(1.00773795179e-2)
92-
app.desktop_class.close_desktop()
79+
assert variables["Win"].si_value == pytest.approx(1.234e-3)
80+
assert variables["W1"].si_value == pytest.approx(5.08e-3)
81+
assert variables["W2"].si_value == pytest.approx(3.175e-4)
82+
assert variables["W3"].si_value == pytest.approx(5.08e-3)
83+
assert variables["S1"].si_value == pytest.approx(3.36225452227e-3)
84+
assert variables["S2"].si_value == pytest.approx(2.17231965814e-2)
85+
assert variables["S3"].si_value == pytest.approx(1.00773795179e-2)
86+
hfss3dl.desktop_class.close_desktop()
9387

9488
def test_distributed_hfss_exported_desktop(self, distributed_design):
9589
schem_name = distributed_design.export_to_aedt.schematic_name
9690
schem_name_length = len(schem_name)
9791
distributed_design.export_to_aedt.insert_hfss_design = True
98-
app = distributed_design.export_to_aedt.export_design()
9992
hfss = distributed_design.export_to_aedt.export_design()
10093
assert isinstance(hfss, Hfss)
10194
assert hfss.project_name.split()[0][:schem_name_length] == schem_name
10295
assert hfss.design_name == schem_name
10396
assert next(iter(hfss.setup_sweeps_names)) == "FS_Advanced_Setup"
10497
variables = hfss.variable_manager.variables
105-
assert variables["Win"].value == pytest.approx(1.234e-3)
106-
assert variables["W1"].value == pytest.approx(5.08e-3)
107-
assert variables["W2"].value == pytest.approx(3.175e-4)
108-
assert variables["W3"].value == pytest.approx(5.08e-3)
109-
assert variables["S1"].value == pytest.approx(3.36225452227e-3)
110-
assert variables["S2"].value == pytest.approx(2.17231965814e-2)
111-
assert variables["S3"].value == pytest.approx(1.00773795179e-2)
112-
app.desktop_class.close_desktop()
98+
assert variables["Win"].si_value == pytest.approx(1.234e-3)
99+
assert variables["W1"].si_value == pytest.approx(5.08e-3)
100+
assert variables["W2"].si_value == pytest.approx(3.175e-4)
101+
assert variables["W3"].si_value == pytest.approx(5.08e-3)
102+
assert variables["S1"].si_value == pytest.approx(3.36225452227e-3)
103+
assert variables["S2"].si_value == pytest.approx(2.17231965814e-2)
104+
assert variables["S3"].si_value == pytest.approx(1.00773795179e-2)
105+
hfss.desktop_class.close_desktop()

tests/system/filter_solutions/test_export_to_aedt/test_export_to_aedt.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from ansys.aedt.core.generic.settings import is_linux
3636
from tests.conftest import DESKTOP_VERSION
3737
from tests.conftest import SKIP_MODELITHICS
38-
from tests.conftest import USE_GRPC
3938
from tests.system.filter_solutions.resources import read_resource_file
4039
from tests.system.filter_solutions.resources import resource_path
4140

@@ -472,9 +471,7 @@ def test_save_library_parts_config(self, lumped_design):
472471
assert lumped_design.export_to_aedt.substrate_dielectric_height == "3 mm"
473472
assert lumped_design.export_to_aedt.substrate_loss_tangent == "0.065 "
474473

475-
@pytest.mark.skipif(
476-
DESKTOP_VERSION < "2026.1" or USE_GRPC, reason="Skipped on versions earlier than 2026.1 or gRPC mode"
477-
)
474+
@pytest.mark.skipif(DESKTOP_VERSION < "2026.1", reason="Skipped on versions earlier than 2026.1")
478475
def test_import_tuned_variables(self, lumped_design):
479476
lumped_design.export_to_aedt.simulate_after_export_enabled = True
480477
lumped_design.export_to_aedt.optimize_after_export_enabled = True

0 commit comments

Comments
 (0)