Skip to content

Commit 4406062

Browse files
committed
implement fillet and test
1 parent ffd4df2 commit 4406062

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from typing import TYPE_CHECKING, List, Union
2525

26-
from ansys.api.geometry.v0.commands_pb2 import ChamferRequest
26+
from ansys.api.geometry.v0.commands_pb2 import ChamferRequest, FilletRequest
2727
from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub
2828
from ansys.geometry.core.connection import GrpcClient
2929
from ansys.geometry.core.errors import protect_grpc
@@ -79,3 +79,33 @@ def chamfer(
7979
)
8080

8181
return result.success
82+
83+
@protect_grpc
84+
@min_backend_version(25, 1, 0)
85+
def fillet(
86+
self, selection: Union["Edge", List["Edge"], "Face", List["Face"]], radius: Real
87+
) -> bool:
88+
"""Create a fillet on an edge or adjust the fillet of a face.
89+
90+
Parameters
91+
----------
92+
edges_or_faces : Edge | List[Edge] | Face | List[Face]
93+
Edge(s) or face(s) to act on.
94+
radius : Real
95+
Fillet radius.
96+
97+
Returns
98+
-------
99+
bool
100+
Success of fillet command.
101+
"""
102+
selection = selection if isinstance(selection, list) else [selection]
103+
104+
for ef in selection:
105+
ef.body._reset_tessellation_cache()
106+
107+
result = self._commands_stub.Fillet(
108+
FilletRequest(ids=[ef.id for ef in selection], radius=radius)
109+
)
110+
111+
return result.success

tests/integration/test_pull_tools.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,54 @@ def test_chamfer(modeler: Modeler):
6161
assert body2.volume.m == pytest.approx(
6262
Quantity(0.945333333333333333, UNITS.m**3).m, rel=1e-6, abs=1e-8
6363
)
64+
65+
66+
def test_fillet(modeler: Modeler):
67+
"""Test fillet on edge and face."""
68+
design = modeler.create_design("chamfer")
69+
70+
body = design.extrude_sketch("box", Sketch().box(Point2D([0, 0]), 1, 1), 1)
71+
assert len(body.faces) == 6
72+
assert len(body.edges) == 12
73+
assert body.volume.m == pytest.approx(Quantity(1, UNITS.m**3).m, rel=1e-6, abs=1e-8)
74+
75+
modeler.pull_tools.fillet(body.edges[0], 0.1)
76+
assert len(body.faces) == 7
77+
assert len(body.edges) == 15
78+
assert body.volume.m == pytest.approx(
79+
Quantity(0.9978539816339744, UNITS.m**3).m, rel=1e-6, abs=1e-8
80+
)
81+
82+
modeler.pull_tools.fillet(body.faces[-1], 0.5)
83+
assert len(body.faces) == 7
84+
assert len(body.edges) == 15
85+
assert body.volume.m == pytest.approx(
86+
Quantity(0.946349540849362, UNITS.m**3).m, rel=1e-6, abs=1e-8
87+
)
88+
89+
# multiple edges
90+
body2 = design.extrude_sketch("box2", Sketch().box(Point2D([0, 0]), 1, 1), 1)
91+
assert len(body2.faces) == 6
92+
assert len(body2.edges) == 12
93+
assert body2.volume.m == pytest.approx(Quantity(1, UNITS.m**3).m, rel=1e-6, abs=1e-8)
94+
95+
modeler.pull_tools.fillet(body2.edges, 0.1)
96+
assert len(body2.faces) == 26
97+
assert len(body2.edges) == 48
98+
assert body2.volume.m == pytest.approx(
99+
Quantity(0.9755870138909422, UNITS.m**3).m, rel=1e-6, abs=1e-8
100+
)
101+
102+
modeler.pull_tools.fillet(body2.faces, 0.3)
103+
assert len(body2.faces) == 26
104+
assert len(body2.edges) == 48
105+
assert body2.volume.m == pytest.approx(
106+
Quantity(0.8043893421169303, UNITS.m**3).m, rel=1e-6, abs=1e-8
107+
)
108+
109+
modeler.pull_tools.fillet(body2.faces, 0.05)
110+
assert len(body2.faces) == 26
111+
assert len(body2.edges) == 48
112+
assert body2.volume.m == pytest.approx(
113+
Quantity(0.9937293491873294, UNITS.m**3).m, rel=1e-6, abs=1e-8
114+
)

0 commit comments

Comments
 (0)