Skip to content

FIX: Import graphic dependencies if needed #6246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions doc/changelog.d/6246.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Import graphic dependencies if needed
8 changes: 8 additions & 0 deletions src/ansys/aedt/core/application/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,14 @@
bb.append(component_boundary)
bb.append(boundarytype)

if self.design_type == "Q3D Extractor" and self._aedt_version >= "2025.2":
net_object = self.get_oo_object(self.odesign, "Nets")
for net in self.get_oo_name(self.odesign, "Nets"):
if net not in bb:
bb.append(net)
net_type = self.get_oo_property_value(net_object, net, "Type")
bb.append(net_type)

Check warning on line 481 in src/ansys/aedt/core/application/design.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/application/design.py#L476-L481

Added lines #L476 - L481 were not covered by tests

current_boundaries = bb[::2]
current_types = bb[1::2]
if hasattr(self, "excitations"):
Expand Down
67 changes: 62 additions & 5 deletions src/ansys/aedt/core/q3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,23 @@ def _init_from_design(self, *args, **kwargs):
def nets(self):
"""Nets in a Q3D project.

.. deprecated:: 0.17.1
Use :func:`net_names` property instead.

Returns
-------
List of nets in a Q3D project.

"""
mess = "The property `nets` is deprecated.\n"
mess += "Use `app.net_names` directly."
warnings.warn(mess, DeprecationWarning)
return self.net_names

@property
def net_names(self):
"""Nets in a Q3D project.

Returns
-------
List of nets in a Q3D project.
Expand All @@ -1326,13 +1343,53 @@ def nets(self):
----------
>>> oModule.ListNets
"""
nets_data = list(self.oboundary.ListNets())
net_names = []
for i in nets_data:
if isinstance(i, (list, tuple)):
net_names.append(i[0].split(":")[1])
try:
net_names = self.get_oo_name(self.odesign, "Nets")
except Exception: # pragma: no cover
nets_data = list(self.oboundary.ListNets())
net_names = []
for i in nets_data:
if isinstance(i, (list, tuple)):
net_names.append(i[0].split(":")[1])
return net_names

@property
def design_nets(self):
"""Get all nets.

Returns
-------
dict[str, :class:`ansys.aedt.core.modules.boundary.common.BoundaryObject`]
Nets.

References
----------
>>> oModule.GetExcitations
"""
net_objects = {}
for el in self.boundaries:
if el.name in self.net_names:
net_objects[el.name] = el
return net_objects

@property
def nets_by_type(self):
"""Design nets by type.

Returns
-------
dict
Dictionary of nets.
"""
_dict_out = {}
for bound in self.design_nets.values():
bound_type = bound.type
if bound_type in _dict_out:
_dict_out[bound_type].append(bound)
else:
_dict_out[bound_type] = [bound]
return _dict_out

@pyaedt_function_handler()
def delete_all_nets(self):
"""Delete all nets in the design."""
Expand Down
5 changes: 3 additions & 2 deletions src/ansys/aedt/core/visualization/post/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
from ansys.aedt.core.generic.file_utils import read_configuration_file
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.generic.numbers import _units_assignment
from ansys.aedt.core.visualization.plot.matplotlib import ReportPlotter
from ansys.aedt.core.visualization.post.solution_data import SolutionData
from ansys.aedt.core.visualization.report.constants import TEMPLATES_BY_DESIGN
import ansys.aedt.core.visualization.report.emi
Expand Down Expand Up @@ -1615,7 +1614,7 @@ def create_report_from_configuration(
solution_name : str, optional
Setup name to use.
matplotlib : bool, optional
Whether if use AEDT or ReportPlotter to generate the plot. Eye diagrams are not supported.
Whether to use AEDT or ReportPlotter to generate the plot. Eye diagrams are not supported.

Returns
-------
Expand Down Expand Up @@ -1739,6 +1738,8 @@ def _update_props(prop_in, props_out):

@pyaedt_function_handler()
def _report_plotter(self, report):
from ansys.aedt.core.visualization.plot.matplotlib import ReportPlotter

sols = report.get_solution_data()
report_plotter = ReportPlotter()
report_plotter.title = report._legacy_props.get("plot_name", "PyAEDT Report")
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/aedt/core/visualization/post/post_common_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.modeler.cad.elements_3d import FacePrimitive
from ansys.aedt.core.visualization.plot.pyvista import ModelPlotter
from ansys.aedt.core.visualization.post.common import PostProcessorCommon
from ansys.aedt.core.visualization.post.fields_calculator import FieldsCalculator

Expand Down Expand Up @@ -1904,6 +1903,8 @@ def get_model_plotter_geometries(
:class:`ansys.aedt.core.generic.plot.ModelPlotter`
Model Object.
"""
from ansys.aedt.core.visualization.plot.pyvista import ModelPlotter

if self._app._aedt_version < "2021.2":
raise RuntimeError("Object is supported from AEDT 2021 R2.") # pragma: no cover

Expand Down
5 changes: 4 additions & 1 deletion src/ansys/aedt/core/visualization/post/solution_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from ansys.aedt.core.generic.file_utils import write_csv
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.visualization.plot.matplotlib import ReportPlotter

np = None
pd = None
Expand Down Expand Up @@ -813,6 +812,8 @@ def get_report_plotter(self, curves=None, formula=None, to_radians=False, props=
:class:`ansys.aedt.core.visualization.plot.matplotlib.ReportPlotter`
Report plotter class.
"""
from ansys.aedt.core.visualization.plot.matplotlib import ReportPlotter

if not curves:
curves = self.expressions
if isinstance(curves, str):
Expand Down Expand Up @@ -958,6 +959,8 @@ def plot_3d(
:class:`matplotlib.figure.Figure`
Matplotlib figure object.
"""
from ansys.aedt.core.visualization.plot.matplotlib import ReportPlotter

if self.primary_sweep == "Phi":
primary_sweep = "Phi"
secondary_sweep = "Theta"
Expand Down
26 changes: 14 additions & 12 deletions tests/system/solvers/test_31_Q3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,26 @@ def test_06c_auto_identify(self, aedtapp):
assert len(aedtapp.nets) == 0
assert aedtapp.auto_identify_nets()
nets = aedtapp.nets
assert "SignalNet" in aedtapp.nets_by_type

net1 = aedtapp.design_excitations[nets[0]]
net2 = aedtapp.design_excitations[nets[1]]
net1 = aedtapp.design_nets[nets[0]]
net2 = aedtapp.design_nets[nets[1]]

new_net1 = aedtapp.toggle_net(net1, "Floating")
assert new_net1.type == "FloatingNet"
net1_1 = aedtapp.design_excitations[nets[0]]
net1_1 = aedtapp.design_nets[nets[0]]
assert net1_1.type == "FloatingNet"
net1_2 = aedtapp.excitation_objects[nets[0]]
net1_2 = aedtapp.design_nets[nets[0]]
assert net1_2.type == "FloatingNet"
assert "FloatingNet" in list(aedtapp.boundaries_by_type.keys())
assert "FloatingNet" in list(aedtapp.nets_by_type.keys())

new_net2 = aedtapp.toggle_net(net2.name, "Ground")
assert new_net2.type == "GroundNet"
net2_1 = aedtapp.design_excitations[nets[1]]
net2_1 = aedtapp.design_nets[nets[1]]
assert net2_1.type == "GroundNet"
net2_2 = aedtapp.excitation_objects[nets[1]]
net2_2 = aedtapp.design_nets[nets[1]]
assert net2_2.type == "GroundNet"
assert "GroundNet" in list(aedtapp.boundaries_by_type.keys())
assert "GroundNet" in list(aedtapp.nets_by_type.keys())

def test_07_create_source_sinks(self, aedtapp):
udp = aedtapp.modeler.Position(0, 0, 0)
Expand Down Expand Up @@ -599,7 +600,8 @@ def test_toggle_net_with_sources(self, add_app):
app.auto_identify_nets()
net = app.nets[0]
assert len(app.excitation_objects) == 3
assert "SignalNet" in app.excitations_by_type
assert len(app.design_excitations) == 3
assert "SignalNet" in app.nets_by_type
sources = app.net_sources(net)
sinks = app.net_sinks(net)

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

new_net = app.toggle_net(net, "Ground")
assert new_net.type == "GroundNet"
assert len(app.excitation_objects) == 1
assert len(app.boundaries) == 1
assert len(app.nets) == 1
new_sources = app.net_sources(net)
new_sinks = app.net_sinks(net)

assert len(sources) != len(new_sources)
assert len(sinks) != len(new_sinks)
assert "GroundNet" in app.excitations_by_type
assert "SignalNet" not in app.excitations_by_type
assert "GroundNet" in app.nets_by_type
assert "SignalNet" not in app.nets_by_type