Skip to content
Draft
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/7383.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Props test implementation for GetObjData
63 changes: 63 additions & 0 deletions src/ansys/aedt/core/application/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,66 @@ def _fix_dict(p_list, p_out) -> None:
props = {}
_fix_dict(props_list, props)
return props


@pyaedt_function_handler()
def _get_obj_data(child_object):
import json

def _obj_data_parser(node):

# Case 1: If the node is a list, parse each item in the list
if isinstance(node, list):
return [_obj_data_parser(item) for item in node]

# Case 2: If the node is a dictionary without "name", parse its values
if isinstance(node, dict) and "name" not in node:
return node

# Case 3: schema dict with "name"
if isinstance(node, dict):
name = node.get("name")

if "value" in node:
return {name: node["value"]}

values = node.get("values", [])

if not values:
return {name: {}}

parsed_children = [_obj_data_parser(child) for child in values]

result = {}

for child in parsed_children:
if isinstance(child, dict):
for k, v in child.items():
if k in result:
if not isinstance(result[k], list):
result[k] = [result[k]]
result[k].append(v)
else:
result[k] = v
else:
return {name: parsed_children}

return {name: result}
# return result

obj_data = child_object.GetObjData()

data = json.loads(obj_data)
result = {}

data_2 = data.get("data_2", [])

if data_2 and isinstance(data_2, list):
values = data_2[0].get("values", [])
else:
values = []

for item in values:
result.update(_obj_data_parser(item))

return result
28 changes: 22 additions & 6 deletions src/ansys/aedt/core/application/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from typing import Any

from ansys.aedt.core.aedt_logger import AedtLogger
from ansys.aedt.core.application import _get_obj_data
from ansys.aedt.core.application.aedt_objects import AedtObjects
from ansys.aedt.core.application.design_solutions import DesignSolution
from ansys.aedt.core.application.design_solutions import HFSSDesignSolution
Expand Down Expand Up @@ -266,6 +267,11 @@ def __init__(
if self._design_type not in ["Maxwell Circuit", "Circuit Netlist"]:
self.design_settings = DesignSettings(self)

if self._aedt_version >= "2026.1":
self.__get_props = _get_obj_data
else:
self.__get_props = lambda obj: None

@property
def _pyaedt_details(self) -> dict[str, str]:
"""Retrieve detailed session information for PyAEDT.
Expand Down Expand Up @@ -518,16 +524,26 @@ def boundaries(self) -> list[BoundaryObject]:
continue
if boundarytype == "MaxwellParameters":
maxwell_parameter_type = self.get_oo_property_value(self.odesign, f"Parameters\\{boundary}", "Type")

self._boundaries[boundary] = MaxwellParameters(self, boundary, boundarytype=maxwell_parameter_type)
child_obj = self.get_oo_object(self.odesign, f"Parameters\\{boundary}")
props = self.__get_props(child_obj)
self._boundaries[boundary] = MaxwellParameters(
self, boundary, props=props, boundarytype=maxwell_parameter_type
)
elif boundarytype == "MotionSetup":
maxwell_motion_type = self.get_oo_property_value(self.odesign, f"Model\\{boundary}", "Type")

self._boundaries[boundary] = BoundaryObject(self, boundary, boundarytype=maxwell_motion_type)
child_obj = self.get_oo_object(self.odesign, f"Model\\{boundary}")
props = self.__get_props(child_obj)
self._boundaries[boundary] = BoundaryObject(
self, boundary, props=props, boundarytype=maxwell_motion_type
)
elif boundarytype == "Network":
self._boundaries[boundary] = NetworkObject(self, boundary)
child_obj = self.get_oo_object(self.odesign, f"Thermal\\{boundary}")
props = self.__get_props(child_obj)
self._boundaries[boundary] = NetworkObject(self, boundary, props=props)
else:
self._boundaries[boundary] = BoundaryObject(self, boundary, boundarytype=boundarytype)
child_obj = self.get_oo_object(self.odesign, f"Boundaries\\{boundary}")
props = self.__get_props(child_obj)
self._boundaries[boundary] = BoundaryObject(self, boundary, props=props, boundarytype=boundarytype)

try:
for k, v in zip(current_excitations, current_excitation_types):
Expand Down
13 changes: 13 additions & 0 deletions src/ansys/aedt/core/modules/boundary/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

"""This module contains these classes: ``BoundaryCommon`` and ``BoundaryObject``."""

from ansys.aedt.core.application import _get_obj_data
from ansys.aedt.core.base import PyAedtBase
from ansys.aedt.core.generic.data_handlers import _dict2arg
from ansys.aedt.core.generic.general_methods import PropsManager
Expand Down Expand Up @@ -308,6 +309,18 @@ def props(self) -> BoundaryProps:
self._type = props[1]
return self.__props

@property
def props_test(self):
"""Boundary data test."""
if self.__props:
return self.__props
props = _get_obj_data(self._child_object)

if props:
self.__props = BoundaryProps(self, props)
self._type = self.get_oo_property_value(self.odesign, f"Boundaries\\{self.name}", "Type")
return self.__props

@property
def type(self) -> str:
"""Boundary type.
Expand Down
19 changes: 19 additions & 0 deletions src/ansys/aedt/core/modules/boundary/maxwell_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from dataclasses import dataclass
from dataclasses import field

from ansys.aedt.core.application import _get_obj_data
from ansys.aedt.core.base import PyAedtBase
from ansys.aedt.core.generic.constants import SolutionsMaxwell3D
from ansys.aedt.core.generic.data_handlers import _dict2arg
Expand Down Expand Up @@ -235,6 +236,11 @@ def __init__(self, app, name, props=None, boundarytype=None) -> None:
self.type = boundarytype
self._initialize_tree_node()

if self._app._aedt_version >= "2026.1":
self.__get_props = _get_obj_data
else:
self.__get_props = lambda obj: None

@property
def _child_object(self):
cc = self._app.odesign.GetChildObject("Parameters")
Expand Down Expand Up @@ -263,6 +269,19 @@ def props(self) -> BoundaryProps:
self._type = props[1]
return self.__props

@property
def props_test(self) -> BoundaryProps:
"""Maxwell parameter data."""
if self.__props:
return self.__props

props = self.__get_props(self.child_object)

if props:
self.__props = BoundaryProps(self, props)
self._type = self.get_oo_property_value(self.odesign, f"Parameters\\{self.name}", "Type")
return self.__props

@property
def name(self) -> str:
"""Boundary Name."""
Expand Down
8 changes: 8 additions & 0 deletions src/ansys/aedt/core/modules/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import os
import shutil

from ansys.aedt.core.application import _get_obj_data
from ansys.aedt.core.base import PyAedtBase
from ansys.aedt.core.generic.data_handlers import _dict2arg
from ansys.aedt.core.generic.file_utils import generate_unique_name
Expand Down Expand Up @@ -189,6 +190,13 @@ def props(self) -> MeshProps:
self._legacy_props = MeshProps(self, props)
return self._legacy_props

@property
def props_test(self):
if not self._legacy_props:
props = _get_obj_data(self._child_object)
self._legacy_props = MeshProps(self, props)
return self._legacy_props

@pyaedt_function_handler()
def _get_args(self):
"""Retrieve arguments."""
Expand Down
68 changes: 19 additions & 49 deletions src/ansys/aedt/core/modules/solve_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from typing import TYPE_CHECKING
import warnings

from ansys.aedt.core.application import _get_obj_data
from ansys.aedt.core.base import PyAedtBase
from ansys.aedt.core.generic.aedt_constants import DesignType
from ansys.aedt.core.generic.constants import AEDT_UNITS
Expand Down Expand Up @@ -307,6 +308,24 @@ def props(self) -> SetupProps:
def props(self, value: dict) -> None:
self._legacy_props = SetupProps(self, value)

@property
def props_test(self) -> SetupProps:
"""Properties of the setup."""
if self._legacy_props:
return self._legacy_props
if self._is_new_setup:
setup_template = SetupKeys.get_setup_templates()[self.setuptype]
setup_template["Name"] = self._name
self._legacy_props = SetupProps(self, setup_template)
self._is_new_setup = False
else:
setup_data = _get_obj_data(self._child_object)
self._legacy_props = SetupProps(self, setup_data)

@props_test.setter
def props_test(self, value: dict) -> None:
self._legacy_props = SetupProps(self, value)

@property
def is_solved(self) -> bool:
"""Verify if solutions are available for given setup.
Expand Down Expand Up @@ -1163,30 +1182,6 @@ class SetupCircuit(CommonSetup):
def __init__(self, app, solution_type, name: str = "MySetupAuto", is_new_setup: bool = True) -> None:
CommonSetup.__init__(self, app, solution_type, name, is_new_setup)

@property
def props(self) -> SetupProps:
if self._legacy_props:
return self._legacy_props
if self._is_new_setup:
setup_template = SetupKeys.get_setup_templates()[self.setuptype]
setup_template["Name"] = self.name
self._legacy_props = SetupProps(self, setup_template)
self._is_new_setup = False
else:
self._legacy_props = SetupProps(self, {})
try:
setups_data = self._app.design_properties["SimSetups"]["SimSetup"]
if not isinstance(setups_data, list):
setups_data = [setups_data]
for setup in setups_data:
if self.name == setup["Name"]:
setup_data = setup
setup_data.pop("Sweeps", None)
self._legacy_props = SetupProps(self, setup_data)
except Exception:
self._legacy_props = SetupProps(self, {})
return self._legacy_props

@property
def _odesign(self):
"""Design."""
Expand Down Expand Up @@ -1876,31 +1871,6 @@ def sweeps(self) -> list["SweepHFSS3DLayout"]:
pass
return self._sweeps

@property
def props(self) -> SetupProps:
if self._legacy_props:
return self._legacy_props
if self._is_new_setup:
setup_template = SetupKeys.get_setup_templates()[self.setuptype]
setup_template["Name"] = self.name
self._legacy_props = SetupProps(self, setup_template)
self._is_new_setup = False

else:
try:
setups_data = self._app.design_properties["Setup"]["Data"]
if self.name in setups_data:
setup_data = setups_data[self.name]
self._legacy_props = SetupProps(self, setup_data)
except Exception:
self._legacy_props = SetupProps(self, {})
settings.logger.error("Unable to set props.")
return self._legacy_props

@props.setter
def props(self, value: dict) -> None:
self._legacy_props = SetupProps(self, value)

@property
def is_solved(self) -> bool:
"""Verify if solutions are available for a given setup.
Expand Down
Loading