Skip to content
Open
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
8 changes: 8 additions & 0 deletions cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7530,6 +7530,7 @@ def fillet(
:param history: If given, the operation is recorded in this history.
:param name: Name under which the operation is recorded in ``history``.
:return: The filleted shape.
:raises ValueError: If the fillet cannot be built.
"""

builder = BRepFilletAPI_MakeFillet(_get_one(s, (Shell, Solid)).wrapped,)
Expand All @@ -7539,6 +7540,9 @@ def fillet(

builder.Build()

if not builder.IsDone():
raise ValueError("Fillet failed, try a smaller radius or fewer edges")

_update_history(history, name, [s, edges], builder)

return _compound_or_shape(builder.Shape())
Expand All @@ -7560,6 +7564,7 @@ def chamfer(
:param history: If given, the operation is recorded in this history.
:param name: Name under which the operation is recorded in ``history``.
:return: The chamfered shape.
:raises ValueError: If the chamfer cannot be built.
"""

builder = BRepFilletAPI_MakeChamfer(_get_one(s, (Shell, Solid)).wrapped,)
Expand All @@ -7569,6 +7574,9 @@ def chamfer(

builder.Build()

if not builder.IsDone():
raise ValueError("Chamfer failed, try a smaller distance or fewer edges")

_update_history(history, name, [s, edges], builder)

return _compound_or_shape(builder.Shape())
Expand Down
8 changes: 8 additions & 0 deletions tests/test_free_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,14 @@ def test_chamfer():
assert r.faces(">Z").Area() < 1


@pytest.mark.parametrize("op", [fillet, chamfer])
def test_fillet_chamfer_raises(box_shape, op):

# too large to fit, the op must raise instead of crashing
with raises(ValueError):
op(box_shape, box_shape.edges(), 0.5)


@pytest.mark.parametrize("sel, n", [("|Z", 4), (">X and >Y", 1)])
def test_fillet_chamfer_methods_shape_arg(sel, n):

Expand Down
Loading