Skip to content

FEAT: Added automatic search in modeler getitem of FaceID and Edge Ids. #6109

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 7 commits into from
May 7, 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/6109.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added automatic search in modeler getitem of FaceID and Edge Ids.
15 changes: 15 additions & 0 deletions src/ansys/aedt/core/modeler/cad/elements_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@
self.oeditor = object3d._oeditor
self._position = position

@property
def name(self):
"""Name of the object."""
return self._object3d.name

Check warning on line 196 in src/ansys/aedt/core/modeler/cad/elements_3d.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/elements_3d.py#L196

Added line #L196 was not covered by tests

@property
def position(self):
"""Position of the vertex.
Expand Down Expand Up @@ -239,6 +244,11 @@
self._object3d = object3d
self.oeditor = object3d._oeditor

@property
def name(self):
"""Name of the object."""
return self._object3d.name

Check warning on line 250 in src/ansys/aedt/core/modeler/cad/elements_3d.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/elements_3d.py#L250

Added line #L250 was not covered by tests

@property
def segment_info(self):
"""Compute segment information using the object-oriented method (from AEDT 2021 R2
Expand Down Expand Up @@ -415,6 +425,11 @@
self._object3d = object3d
self._is_planar = None

@property
def name(self):
"""Name of the object."""
return self._object3d.name

@property
def oeditor(self):
"""Oeditor Module."""
Expand Down
18 changes: 17 additions & 1 deletion src/ansys/aedt/core/modeler/cad/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
return self.objects[partId]
except KeyError:
pass

try:
return self.user_defined_components[partId]
except KeyError:
Expand All @@ -237,10 +238,25 @@
return self.planes[partId]
except KeyError:
pass

try:
return self.points[partId]
except KeyError:
return
pass
if isinstance(partId, int):
try:
obj_name = self.oeditor.GetObjectNameByFaceID(partId)
if obj_name:
return FacePrimitive(self.objects[obj_name], partId)
except AttributeError: # pragma: no cover
pass
try:
obj_name = self.oeditor.GetObjectNameByEdgeID(partId)
if obj_name:
return EdgePrimitive(self.objects[obj_name], partId)

Check warning on line 256 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#L255-L256

Added lines #L255 - L256 were not covered by tests
except Exception: # pragma: no cover
pass
return

def __init__(self, app, is3d=True):
self._app = app
Expand Down
4 changes: 4 additions & 0 deletions tests/system/general/test_02_3D_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,3 +1220,7 @@ def test_clean_objects_name(self):

assert self.aedtapp.modeler.get_matched_object_name("Part0")
assert self.aedtapp.modeler.get_matched_object_name("Part1")

def test_64_id(self):
box_0 = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 10], name="Object_Part_ids")
assert self.aedtapp.modeler[box_0.faces[0].id].name == box_0.name
Loading