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

Add detach_faces method #4534

Merged
merged 6 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
11 changes: 11 additions & 0 deletions _unittest/test_07_Object3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pyaedt.generic.general_methods import time_fn
from pyaedt.modeler.cad.elements3d import EdgePrimitive
from pyaedt.modeler.cad.elements3d import FacePrimitive
from pyaedt.modeler.cad.object3d import Object3d


@pytest.fixture(scope="class")
Expand Down Expand Up @@ -671,3 +672,13 @@ def test_20_simplify_objects(self):
)
assert not self.aedtapp.modeler.simplify_objects(input_objects_list=None)
assert not self.aedtapp.modeler.simplify_objects(input_objects_list=1)

def test_21_detach_faces(self):
box = self.aedtapp.modeler.create_box([0, 0, 0], [1, 2, 3])
out_obj = box.detach_faces(box.top_face_z)
assert len(out_obj) == 1
assert isinstance(out_obj[0], Object3d)
box = self.aedtapp.modeler.create_box([0, 0, 0], [1, 2, 3])
out_obj = box.detach_faces([box.top_face_z.id, box.bottom_face_z.id])
assert len(out_obj) == 2
assert all(isinstance(o, Object3d) for o in out_obj)
30 changes: 30 additions & 0 deletions pyaedt/modeler/cad/object3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,36 @@ def section(self, plane, create_new=True, section_cross_object=False):
self._primitives.section(self, plane, create_new, section_cross_object)
return self

@pyaedt_function_handler()
def detach_faces(self, faces):
"""Section the object.

Parameters
----------
faces : List[FacePrimitive] or List[int] or int or FacePrimitive
Face or faces to be detached from the object.
lorenzovecchietti marked this conversation as resolved.
Show resolved Hide resolved

Returns
-------
List[:class:`pyaedt.modeler.cad.object3d.Object3d`]
List of object resulting from the operation.

References
----------

>>> oEditor.DetachFaces

"""
if isinstance(faces, FacePrimitive) or isinstance(faces, int):
faces = [faces]
if isinstance(faces[0], FacePrimitive):
faces = [f.id for f in faces]
result = self._primitives.oeditor.DetachFaces(
["NAME:Selections", "Selections:=", self.name, "NewPartsModelFlag:=", "Model"],
["NAME:Parameters", ["NAME:DetachFacesToParameters", "FacesToDetach:=", faces]],
)
return [getattr(self._primitives, "_modeler")[o] for o in result]

@pyaedt_function_handler()
def clone(self):
"""Clone the object and return the new 3D object.
Expand Down
Loading