Skip to content

Commit 303d27c

Browse files
wip - cs failure
1 parent 52a11ec commit 303d27c

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

src/ansys/geometry/core/tools/prepare_tools.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,28 +528,48 @@ def detect_helixes(
528528
]
529529
}
530530

531-
def is_body_sweepable(self, body: "Body", get_source_target_faces: bool) -> bool:
531+
@min_backend_version(26, 1, 0)
532+
def is_body_sweepable(
533+
self,
534+
body: "Body",
535+
get_source_target_faces: bool = False,
536+
) -> tuple[bool, list["Face"]]:
532537
"""Check if a body is sweepable.
533538
534539
Parameters
535540
----------
536541
body : Body
537542
Body to check.
538543
get_source_target_faces : bool
539-
Whether to get source and target faces.
544+
Whether to get source and target faces. By default, ``False``.
540545
541546
Returns
542547
-------
543-
bool
544-
True if the body is sweepable, False otherwise.
548+
tuple[bool, list[Face]]
549+
Tuple containing a boolean indicating if the body is sweepable and
550+
a list of source and target faces if requested.
545551
"""
546552
from ansys.geometry.core.designer.body import Body
553+
from ansys.geometry.core.designer.face import Face, SurfaceType
547554

548555
# Verify inputs
549556
check_type_all_elements_in_iterable([body], Body)
550557

551558
response = self._grpc_client._services.prepare_tools.is_body_sweepable(
552559
body_id=body.id,
560+
get_source_target_faces=get_source_target_faces,
553561
)
554562

555-
return response.get("is_sweepable")
563+
faces = []
564+
if get_source_target_faces:
565+
faces = [
566+
Face(
567+
face.get("id"),
568+
SurfaceType(face.get("surface_type")),
569+
self,
570+
self._grpc_client,
571+
)
572+
for face in response.get("faces")
573+
]
574+
575+
return (response.get("result"), faces)

tests/integration/test_prepare_tools.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,12 @@ def test_helix_detection(modeler: Modeler):
238238

239239
def test_is_body_sweepable(modeler: Modeler):
240240
"""Test body sweepability detection."""
241-
design = modeler.open_file(FILES_DIR / "simpleSweepableBody.scdocx")
241+
design = modeler.open_file(FILES_DIR / "1mm_Cube.dsco")
242242

243243
bodies = design.bodies
244244
assert len(bodies) == 1
245245

246246
# Test sweepability of the body
247-
is_sweepable = modeler.prepare_tools.is_body_sweepable(bodies[0])
248-
assert is_sweepable is True
247+
is_sweepable, faces = modeler.prepare_tools.is_body_sweepable(bodies[0])
248+
assert is_sweepable
249+
assert len(faces) == 0

0 commit comments

Comments
 (0)