Skip to content

Commit

Permalink
Handle extrude until=Face and combine=False
Browse files Browse the repository at this point in the history
Added test for this and changed extrude to raise a ValueError
  • Loading branch information
marcus7070 committed Sep 25, 2021
1 parent a91f623 commit 20691bc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -3018,15 +3018,17 @@ def extrude(

r = self._extrude(distance=None, both=both, taper=taper, upToFace=faceIndex)

elif isinstance(until, Face):
elif isinstance(until, Face) and combine:
r = self._extrude(None, both=both, taper=taper, upToFace=until)

elif isinstance(until, (int, float)):
r = self._extrude(until, both=both, taper=taper, upToFace=None)

elif isinstance(until, str) and combine is False:
elif isinstance(until, (str, Face)) and combine is False:
raise ValueError(
"`combine` can't be set to False when extruding until a face"
)

else:
raise ValueError(
f"Do not know how to handle until argument of type {type(until)}"
Expand Down
16 changes: 16 additions & 0 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -3233,6 +3233,22 @@ def testExtrudeUntilFace(self):
.extrude(until="next", combine=False)
)

# Same as previous test, but use an object of type Face
with self.assertRaises(ValueError):
wp = (
Workplane()
.box(5, 5, 5)
.faces(">X")
)
face0 = wp.val()
wp = (
wp
.workplane(offset=10)
.transformed((90, 0, 0))
.circle(2)
.extrude(until=face0, combine=False)
)

# Test extrude up to next face when workplane is inside a solid (which should still extrude
# past solid surface and up to next face)
# make an I-beam shape
Expand Down

0 comments on commit 20691bc

Please sign in to comment.