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: bug when parsing data for object3d. #5662

Closed
wants to merge 1 commit into from
Closed
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
170 changes: 87 additions & 83 deletions src/ansys/aedt/core/modeler/cad/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,106 +864,110 @@
from ansys.aedt.core.application import _get_data_model

dm = _get_data_model(self.oeditor, 2)

lines = self.line_names[::]

Check warning on line 867 in src/ansys/aedt/core/modeler/cad/primitives.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/primitives.py#L867

Added line #L867 was not covered by tests
for attribs in dm.get("children", []):
if attribs["type"] == "Part":
pid = 0
is_polyline = False
try:
if attribs["children"][0]["Command"] == "CreatePolyline":
is_polyline = True
except Exception:
if attribs["Name"] in lines:
is_polyline = True

Check warning on line 872 in src/ansys/aedt/core/modeler/cad/primitives.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/primitives.py#L871-L872

Added lines #L871 - L872 were not covered by tests
else:
is_polyline = False
try:
if attribs["children"][0]["Command"] == "CreatePolyline":
is_polyline = True
except Exception:
is_polyline = False

Check warning on line 879 in src/ansys/aedt/core/modeler/cad/primitives.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/primitives.py#L875-L879

Added lines #L875 - L879 were not covered by tests

o = self._create_object(name=attribs["Name"], pid=pid, use_cached=True, is_polyline=is_polyline)
o._part_coordinate_system = attribs["Orientation"]
o._model = attribs["Model"]
o._wireframe = attribs["Display Wireframe"]
o._m_groupName = attribs["Model"]
o._m_groupName = attribs["Group"]

Check warning on line 885 in src/ansys/aedt/core/modeler/cad/primitives.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/primitives.py#L885

Added line #L885 was not covered by tests
o._color = (attribs["Color/Red"], attribs["Color/Green"], attribs["Color/Blue"])
o._material_name = attribs.get("Material", None)
o._surface_material = attribs.get("Surface Material", None)
o._solve_inside = attribs.get("Solve Inside", False)
o._transparent = attribs.get("Transparent", 0.0)

Check warning on line 890 in src/ansys/aedt/core/modeler/cad/primitives.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/primitives.py#L890

Added line #L890 was not covered by tests
o._is_updated = True
# pid+=1
return len(self.objects)

@pyaedt_function_handler()
def _refresh_all_ids_from_aedt_file(self):
self._app.logger.info("Refreshing objects from AEDT file")

dp = copy.deepcopy(self._app.design_properties)
if not dp or "ModelSetup" not in dp:
return False

try:
groups = dp["ModelSetup"]["GeometryCore"]["GeometryOperations"]["Groups"]["Group"]
except KeyError:
groups = []
if not isinstance(groups, list):
groups = [groups]
try:
dp["ModelSetup"]["GeometryCore"]["GeometryOperations"]["ToplevelParts"]["GeometryPart"]
except KeyError:
return 0

for el in dp["ModelSetup"]["GeometryCore"]["GeometryOperations"]["ToplevelParts"]["GeometryPart"]:
if isinstance(el, dict):
attribs = el["Attributes"]
operations = el.get("Operations", None)
else:
attribs = dp["ModelSetup"]["GeometryCore"]["GeometryOperations"]["ToplevelParts"]["GeometryPart"][
"Attributes"
]
operations = dp["ModelSetup"]["GeometryCore"]["GeometryOperations"]["ToplevelParts"]["GeometryPart"][
"Operations"
]
if attribs["Name"] in self._all_object_names:
pid = 0

if operations and isinstance(operations.get("Operation", None), dict):
try:
pid = operations["Operation"]["ParentPartID"]
except Exception as e: # pragma: no cover
self.logger.debug(e)
elif operations and isinstance(operations.get("Operation", None), list):
try:
pid = operations["Operation"][0]["ParentPartID"]
except Exception as e:
self.logger.debug(e)

is_polyline = False
if operations and "PolylineParameters" in operations.get("Operation", {}):
is_polyline = True

o = self._create_object(name=attribs["Name"], pid=pid, use_cached=True, is_polyline=is_polyline)
o._part_coordinate_system = attribs["PartCoordinateSystem"]
if "NonModel" in attribs["Flags"]:
o._model = False
else:
o._model = True
if "Wireframe" in attribs["Flags"]:
o._wireframe = True
else:
o._wireframe = False
groupname = ""
for group in groups:
if attribs["GroupId"] == group["GroupID"]:
groupname = group["Attributes"]["Name"]

o._m_groupName = groupname
try:
o._color = tuple(int(x) for x in attribs["Color"][1:-1].split(" "))
except Exception:
o._color = None
o._surface_material = attribs.get("SurfaceMaterialValue", None)
if o._surface_material:
o._surface_material = o._surface_material[1:-1].lower()
if "MaterialValue" in attribs:
o._material_name = attribs["MaterialValue"][1:-1].lower()

o._is_updated = True
return len(self.objects)
# @pyaedt_function_handler()
# def _refresh_all_ids_from_aedt_file(self):
# self._app.logger.info("Refreshing objects from AEDT file")
#
# dp = copy.deepcopy(self._app.design_properties)
# if not dp or "ModelSetup" not in dp:
# return False
#
# try:
# groups = dp["ModelSetup"]["GeometryCore"]["GeometryOperations"]["Groups"]["Group"]
# except KeyError:
# groups = []
# if not isinstance(groups, list):
# groups = [groups]
# try:
# dp["ModelSetup"]["GeometryCore"]["GeometryOperations"]["ToplevelParts"]["GeometryPart"]
# except KeyError:
# return 0
#
# for el in dp["ModelSetup"]["GeometryCore"]["GeometryOperations"]["ToplevelParts"]["GeometryPart"]:
# if isinstance(el, dict):
# attribs = el["Attributes"]
# operations = el.get("Operations", None)
# else:
# attribs = dp["ModelSetup"]["GeometryCore"]["GeometryOperations"]["ToplevelParts"]["GeometryPart"][
# "Attributes"
# ]
# operations = dp["ModelSetup"]["GeometryCore"]["GeometryOperations"]["ToplevelParts"]["GeometryPart"][
# "Operations"
# ]
# if attribs["Name"] in self._all_object_names:
# pid = 0
#
# if operations and isinstance(operations.get("Operation", None), dict):
# try:
# pid = operations["Operation"]["ParentPartID"]
# except Exception as e: # pragma: no cover
# self.logger.debug(e)
# elif operations and isinstance(operations.get("Operation", None), list):
# try:
# pid = operations["Operation"][0]["ParentPartID"]
# except Exception as e:
# self.logger.debug(e)
#
# is_polyline = False
# if operations and "PolylineParameters" in operations.get("Operation", {}):
# is_polyline = True
#
# o = self._create_object(name=attribs["Name"], pid=pid, use_cached=True, is_polyline=is_polyline)
# o._part_coordinate_system = attribs["PartCoordinateSystem"]
# if "NonModel" in attribs["Flags"]:
# o._model = False
# else:
# o._model = True
# if "Wireframe" in attribs["Flags"]:
# o._wireframe = True
# else:
# o._wireframe = False
# groupname = ""
# for group in groups:
# if attribs["GroupId"] == group["GroupID"]:
# groupname = group["Attributes"]["Name"]
#
# o._m_groupName = groupname
# try:
# o._color = tuple(int(x) for x in attribs["Color"][1:-1].split(" "))
# except Exception:
# o._color = None
# o._surface_material = attribs.get("SurfaceMaterialValue", None)
# if o._surface_material:
# o._surface_material = o._surface_material[1:-1].lower()
# if "MaterialValue" in attribs:
# o._material_name = attribs["MaterialValue"][1:-1].lower()
#
# o._is_updated = True
# return len(self.objects)

@pyaedt_function_handler()
def cleanup_objects(self):
Expand Down
Loading