Skip to content
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

FIX: Examples repo compatibility #5219

Merged
merged 17 commits into from
Sep 28, 2024
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
2 changes: 1 addition & 1 deletion examples/07-Circuit/Virtual_Compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import os.path
import ansys.aedt.core
from ansys.aedt.core.post.compliance import VirtualCompliance
from ansys.aedt.core.visualization.post.compliance import VirtualCompliance

##########################################################
# Set AEDT version
Expand Down
20 changes: 13 additions & 7 deletions src/ansys/aedt/core/application/analysis_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,11 @@ def copy_solid_bodies_from(self, design, assignment=None, no_vacuum=True, no_pec
or original_design_type == dest_design_type
):
new_udc_list.append(udc)
for part_id in design.modeler.user_defined_components[udc].parts:
if design.modeler.user_defined_components[udc].parts[part_id].name in body_list:
body_list.remove(design.modeler.user_defined_components[udc].parts[part_id].name)
parts = design.modeler.user_defined_components[udc].parts
for part_id in parts:
part_name = parts[part_id].name
if part_name in body_list:
body_list.remove(part_name)

selection_list = []
udc_selection = []
Expand Down Expand Up @@ -1087,10 +1089,12 @@ def flatten_3d_components(self, components=None, purge_history=True, password=No
"""
if password is None:
password = os.getenv("PYAEDT_ENCRYPTED_PASSWORD", "")
native_comp_names = [nc for nc in self.native_components.keys()]
native_comp_names = [nc.definition_name for nc in self.native_components.values()]
if not components:
components = [
key for key, val in self.modeler.user_defined_components.items() if val.name not in native_comp_names
key
for key, val in self.modeler.user_defined_components.items()
if val.definition_name not in native_comp_names
]
else:
if isinstance(components, str):
Expand All @@ -1101,6 +1105,7 @@ def flatten_3d_components(self, components=None, purge_history=True, password=No

for cmp in components:
comp = self.modeler.user_defined_components[cmp]
# TODO: Call edit_definition only once
target_cs = self.modeler._create_reference_cs_from_3dcomp(comp, password=password)
app = comp.edit_definition(password=password)
for var, val in comp.parameters.items():
Expand All @@ -1110,7 +1115,8 @@ def flatten_3d_components(self, components=None, purge_history=True, password=No
monitor_cache = {}
if self.design_type == "Icepak":
objs_monitors = [part.name for _, part in comp.parts.items()]
for mon_name, mon_obj in self.monitor.all_monitors.items():
all_monitors = self.monitor.all_monitors.items()
for _, mon_obj in all_monitors:
obj_name = mon_obj.properties["Geometry Assignment"]
if obj_name in objs_monitors:
monitor_cache.update({mon_obj.name: mon_obj.properties})
Expand Down Expand Up @@ -1147,7 +1153,7 @@ def flatten_3d_components(self, components=None, purge_history=True, password=No
m_type, m_obj, dict_in["monitor"][monitor_obj]["Quantity"], monitor_obj
): # pragma: no cover
return False
app.oproject.Close()
app.close_project()

if not self.design_type == "Icepak":
self.mesh._refresh_mesh_operations()
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@
except Exception:
print("failed to get pin2")
if pin1 and pin2:
pin1.connect_to_component(component_pin=pin2, use_wire=False)
pin1.connect_to_component(assignment=pin2, use_wire=False)

Check warning on line 1613 in src/ansys/aedt/core/circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/circuit.py#L1613

Added line #L1613 was not covered by tests
for model_name, ports in ports.items():
if any(cmp for cmp in list(self.modeler.schematic.components.values()) if model_name in cmp.name):
model = next(
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/generic/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,7 @@ def apply_operations_to_native_components(obj, operation_dict, native_dict): #
vector_list = [decompose_variable_value(operation_dict["Props"]["Vector"][i])[0] for i in range(3)]
new_objs = obj.duplicate_along_line(
vector_list,
nclones=operation_dict["Props"]["Total Number"],
clones=operation_dict["Props"]["Total Number"],
attach_object=operation_dict["Props"]["Attach To Original Object"],
)
elif operation_dict["Props"]["Command"] == "DuplicateAroundAxis":
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/modeler/advanced_cad/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def insert(self, app):
if self["duplicate_vector"]:
d_vect = [float(i) for i in self["duplicate_vector"]]
duplicate_result = app.modeler.duplicate_along_line(
aedt_objects[0], d_vect, nclones=int(self["duplicate_number"]), is_3d_comp=True
aedt_objects[0], d_vect, clones=int(self["duplicate_number"]), is_3d_comp=True
)
if duplicate_result[0]:
for d in duplicate_result[1]:
Expand Down
5 changes: 3 additions & 2 deletions src/ansys/aedt/core/modeler/cad/components_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,11 +890,10 @@ def edit_definition(self, password=None):
"""
# TODO: Edit documentation to include all supported returned classes.

from ansys.aedt.core.generic.design_types import get_pyaedt_app

# from ansys.aedt.core.generic.general_methods import is_linux
if password is None:
password = os.getenv("PYAEDT_ENCRYPTED_PASSWORD", "")

project_list = [i for i in self._primitives._app.project_list]

self._primitives.oeditor.Edit3DComponentDefinition(
Expand All @@ -907,6 +906,8 @@ def edit_definition(self, password=None):
new_project = [i for i in self._primitives._app.project_list if i not in project_list]

if new_project:
from ansys.aedt.core.generic.design_types import get_pyaedt_app

project = self._primitives._app.desktop_class.active_project(new_project[0])
# project = self._primitives._app.odesktop.GetActiveProject()
project_name = project.GetName()
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/modeler/cad/primitives_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ def _create_reference_cs_from_3dcomp(self, assignment, password):
)
return cs_name
else:
app.oproject.Close()
app.close_project()
return assignment.target_coordinate_system

@staticmethod
Expand Down
5 changes: 3 additions & 2 deletions src/ansys/aedt/core/visualization/plot/pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -1540,8 +1540,9 @@ def p_callback():
break
i = 0
first_loop = False
scalars = self.frames[i]._cached_polydata.point_data[self.frames[i].scalar_name]
self.pv.update_scalars(scalars, render=False)
mesh_i = self.frames[i]._cached_polydata
scalars = mesh_i.point_data[self.frames[i].scalar_name]
mesh_i.point_data[self.frames[i].scalar_name] = scalars
if not hasattr(self.pv, "ren_win"):
break
time.sleep(max(0, (1 / self.frame_per_seconds) - (time.time() - start)))
Expand Down
13 changes: 11 additions & 2 deletions src/ansys/aedt/core/visualization/post/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,8 +1663,17 @@ def create_report_from_configuration(self, input_file=None, report_settings=None
else:
report_temp = TEMPLATES_BY_NAME[props["report_category"]]
report = report_temp(self, props["report_category"], solution_name)
for k, v in props.items():
report._props[k] = v

def _update_props(prop_in, props_out):
for k, v in prop_in.items():
if isinstance(v, dict):
if k not in props_out:
props_out[k] = {}
_update_props(v, props_out[k])
else:
props_out[k] = v

_update_props(props, report._props)
for el, k in self._app.available_variations.nominal_w_values_dict.items():
if (
report._props.get("context", None)
Expand Down
8 changes: 5 additions & 3 deletions src/ansys/aedt/core/visualization/report/eye.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ def __init__(self, app, report_category, setup_name, expressions=None):
self.domain = "Time"
self._props["report_type"] = "Rectangular Contour Plot"
self.variations.pop("Time", None)
self._props["context"]["variations"]["__UnitInterval"] = "All"
self._props["context"]["variations"]["__Amplitude"] = "All"
self._props["context"]["variations"]["__EyeOpening"] = "0"
self._props["context"]["variations"]["__UnitInterval"] = ["All"]
self._props["context"]["variations"]["__Amplitude"] = ["All"]
self._props["context"]["variations"]["__EyeOpening"] = ["0"]
self._props["context"]["primary_sweep"] = "__UnitInterval"
self._props["context"]["secondary_sweep"] = "__Amplitude"
self.quantity_type = 0
self.min_latch_overlay = "0"
self.noise_floor = "1e-16"
Expand Down
Loading