Skip to content

Commit dfb7c1b

Browse files
Samuelopez-ansyspyansys-ci-botSMoraisAnsys
authored
FIX: Import graphic dependencies if needed (#6246)
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>
1 parent 91adc3b commit dfb7c1b

7 files changed

Lines changed: 94 additions & 21 deletions

File tree

doc/changelog.d/6246.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Import graphic dependencies if needed

src/ansys/aedt/core/application/design.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,14 @@ def boundaries(self) -> List[BoundaryObject]:
472472
bb.append(component_boundary)
473473
bb.append(boundarytype)
474474

475+
if self.design_type == "Q3D Extractor" and self._aedt_version >= "2025.2":
476+
net_object = self.get_oo_object(self.odesign, "Nets")
477+
for net in self.get_oo_name(self.odesign, "Nets"):
478+
if net not in bb:
479+
bb.append(net)
480+
net_type = self.get_oo_property_value(net_object, net, "Type")
481+
bb.append(net_type)
482+
475483
current_boundaries = bb[::2]
476484
current_types = bb[1::2]
477485
if hasattr(self, "excitations"):

src/ansys/aedt/core/q3d.py

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,23 @@ def _init_from_design(self, *args, **kwargs):
13181318
def nets(self):
13191319
"""Nets in a Q3D project.
13201320
1321+
.. deprecated:: 0.17.1
1322+
Use :func:`net_names` property instead.
1323+
1324+
Returns
1325+
-------
1326+
List of nets in a Q3D project.
1327+
1328+
"""
1329+
mess = "The property `nets` is deprecated.\n"
1330+
mess += "Use `app.net_names` directly."
1331+
warnings.warn(mess, DeprecationWarning)
1332+
return self.net_names
1333+
1334+
@property
1335+
def net_names(self):
1336+
"""Nets in a Q3D project.
1337+
13211338
Returns
13221339
-------
13231340
List of nets in a Q3D project.
@@ -1326,13 +1343,53 @@ def nets(self):
13261343
----------
13271344
>>> oModule.ListNets
13281345
"""
1329-
nets_data = list(self.oboundary.ListNets())
1330-
net_names = []
1331-
for i in nets_data:
1332-
if isinstance(i, (list, tuple)):
1333-
net_names.append(i[0].split(":")[1])
1346+
try:
1347+
net_names = self.get_oo_name(self.odesign, "Nets")
1348+
except Exception: # pragma: no cover
1349+
nets_data = list(self.oboundary.ListNets())
1350+
net_names = []
1351+
for i in nets_data:
1352+
if isinstance(i, (list, tuple)):
1353+
net_names.append(i[0].split(":")[1])
13341354
return net_names
13351355

1356+
@property
1357+
def design_nets(self):
1358+
"""Get all nets.
1359+
1360+
Returns
1361+
-------
1362+
dict[str, :class:`ansys.aedt.core.modules.boundary.common.BoundaryObject`]
1363+
Nets.
1364+
1365+
References
1366+
----------
1367+
>>> oModule.GetExcitations
1368+
"""
1369+
net_objects = {}
1370+
for el in self.boundaries:
1371+
if el.name in self.net_names:
1372+
net_objects[el.name] = el
1373+
return net_objects
1374+
1375+
@property
1376+
def nets_by_type(self):
1377+
"""Design nets by type.
1378+
1379+
Returns
1380+
-------
1381+
dict
1382+
Dictionary of nets.
1383+
"""
1384+
_dict_out = {}
1385+
for bound in self.design_nets.values():
1386+
bound_type = bound.type
1387+
if bound_type in _dict_out:
1388+
_dict_out[bound_type].append(bound)
1389+
else:
1390+
_dict_out[bound_type] = [bound]
1391+
return _dict_out
1392+
13361393
@pyaedt_function_handler()
13371394
def delete_all_nets(self):
13381395
"""Delete all nets in the design."""

src/ansys/aedt/core/visualization/post/common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
from ansys.aedt.core.generic.file_utils import read_configuration_file
3939
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
4040
from ansys.aedt.core.generic.numbers import _units_assignment
41-
from ansys.aedt.core.visualization.plot.matplotlib import ReportPlotter
4241
from ansys.aedt.core.visualization.post.solution_data import SolutionData
4342
from ansys.aedt.core.visualization.report.constants import TEMPLATES_BY_DESIGN
4443
import ansys.aedt.core.visualization.report.emi
@@ -1615,7 +1614,7 @@ def create_report_from_configuration(
16151614
solution_name : str, optional
16161615
Setup name to use.
16171616
matplotlib : bool, optional
1618-
Whether if use AEDT or ReportPlotter to generate the plot. Eye diagrams are not supported.
1617+
Whether to use AEDT or ReportPlotter to generate the plot. Eye diagrams are not supported.
16191618
16201619
Returns
16211620
-------
@@ -1739,6 +1738,8 @@ def _update_props(prop_in, props_out):
17391738

17401739
@pyaedt_function_handler()
17411740
def _report_plotter(self, report):
1741+
from ansys.aedt.core.visualization.plot.matplotlib import ReportPlotter
1742+
17421743
sols = report.get_solution_data()
17431744
report_plotter = ReportPlotter()
17441745
report_plotter.title = report._legacy_props.get("plot_name", "PyAEDT Report")

src/ansys/aedt/core/visualization/post/post_common_3d.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
4747
from ansys.aedt.core.generic.settings import settings
4848
from ansys.aedt.core.modeler.cad.elements_3d import FacePrimitive
49-
from ansys.aedt.core.visualization.plot.pyvista import ModelPlotter
5049
from ansys.aedt.core.visualization.post.common import PostProcessorCommon
5150
from ansys.aedt.core.visualization.post.fields_calculator import FieldsCalculator
5251

@@ -1904,6 +1903,8 @@ def get_model_plotter_geometries(
19041903
:class:`ansys.aedt.core.generic.plot.ModelPlotter`
19051904
Model Object.
19061905
"""
1906+
from ansys.aedt.core.visualization.plot.pyvista import ModelPlotter
1907+
19071908
if self._app._aedt_version < "2021.2":
19081909
raise RuntimeError("Object is supported from AEDT 2021 R2.") # pragma: no cover
19091910

src/ansys/aedt/core/visualization/post/solution_data.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from ansys.aedt.core.generic.file_utils import write_csv
3636
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
3737
from ansys.aedt.core.generic.settings import settings
38-
from ansys.aedt.core.visualization.plot.matplotlib import ReportPlotter
3938

4039
np = None
4140
pd = None
@@ -813,6 +812,8 @@ def get_report_plotter(self, curves=None, formula=None, to_radians=False, props=
813812
:class:`ansys.aedt.core.visualization.plot.matplotlib.ReportPlotter`
814813
Report plotter class.
815814
"""
815+
from ansys.aedt.core.visualization.plot.matplotlib import ReportPlotter
816+
816817
if not curves:
817818
curves = self.expressions
818819
if isinstance(curves, str):
@@ -958,6 +959,8 @@ def plot_3d(
958959
:class:`matplotlib.figure.Figure`
959960
Matplotlib figure object.
960961
"""
962+
from ansys.aedt.core.visualization.plot.matplotlib import ReportPlotter
963+
961964
if self.primary_sweep == "Phi":
962965
primary_sweep = "Phi"
963966
secondary_sweep = "Theta"

tests/system/solvers/test_31_Q3D.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,25 +183,26 @@ def test_06c_auto_identify(self, aedtapp):
183183
assert len(aedtapp.nets) == 0
184184
assert aedtapp.auto_identify_nets()
185185
nets = aedtapp.nets
186+
assert "SignalNet" in aedtapp.nets_by_type
186187

187-
net1 = aedtapp.design_excitations[nets[0]]
188-
net2 = aedtapp.design_excitations[nets[1]]
188+
net1 = aedtapp.design_nets[nets[0]]
189+
net2 = aedtapp.design_nets[nets[1]]
189190

190191
new_net1 = aedtapp.toggle_net(net1, "Floating")
191192
assert new_net1.type == "FloatingNet"
192-
net1_1 = aedtapp.design_excitations[nets[0]]
193+
net1_1 = aedtapp.design_nets[nets[0]]
193194
assert net1_1.type == "FloatingNet"
194-
net1_2 = aedtapp.excitation_objects[nets[0]]
195+
net1_2 = aedtapp.design_nets[nets[0]]
195196
assert net1_2.type == "FloatingNet"
196-
assert "FloatingNet" in list(aedtapp.boundaries_by_type.keys())
197+
assert "FloatingNet" in list(aedtapp.nets_by_type.keys())
197198

198199
new_net2 = aedtapp.toggle_net(net2.name, "Ground")
199200
assert new_net2.type == "GroundNet"
200-
net2_1 = aedtapp.design_excitations[nets[1]]
201+
net2_1 = aedtapp.design_nets[nets[1]]
201202
assert net2_1.type == "GroundNet"
202-
net2_2 = aedtapp.excitation_objects[nets[1]]
203+
net2_2 = aedtapp.design_nets[nets[1]]
203204
assert net2_2.type == "GroundNet"
204-
assert "GroundNet" in list(aedtapp.boundaries_by_type.keys())
205+
assert "GroundNet" in list(aedtapp.nets_by_type.keys())
205206

206207
def test_07_create_source_sinks(self, aedtapp):
207208
udp = aedtapp.modeler.Position(0, 0, 0)
@@ -599,7 +600,8 @@ def test_toggle_net_with_sources(self, add_app):
599600
app.auto_identify_nets()
600601
net = app.nets[0]
601602
assert len(app.excitation_objects) == 3
602-
assert "SignalNet" in app.excitations_by_type
603+
assert len(app.design_excitations) == 3
604+
assert "SignalNet" in app.nets_by_type
603605
sources = app.net_sources(net)
604606
sinks = app.net_sinks(net)
605607

@@ -608,12 +610,12 @@ def test_toggle_net_with_sources(self, add_app):
608610

609611
new_net = app.toggle_net(net, "Ground")
610612
assert new_net.type == "GroundNet"
611-
assert len(app.excitation_objects) == 1
612613
assert len(app.boundaries) == 1
614+
assert len(app.nets) == 1
613615
new_sources = app.net_sources(net)
614616
new_sinks = app.net_sinks(net)
615617

616618
assert len(sources) != len(new_sources)
617619
assert len(sinks) != len(new_sinks)
618-
assert "GroundNet" in app.excitations_by_type
619-
assert "SignalNet" not in app.excitations_by_type
620+
assert "GroundNet" in app.nets_by_type
621+
assert "SignalNet" not in app.nets_by_type

0 commit comments

Comments
 (0)