From 20691bc8ecae5bb8308c29e4cba7d744d1cb522c Mon Sep 17 00:00:00 2001 From: Marcus Boyd Date: Sat, 25 Sep 2021 20:37:42 +0930 Subject: [PATCH] Handle extrude until=Face and combine=False Added test for this and changed extrude to raise a ValueError --- cadquery/cq.py | 6 ++++-- tests/test_cadquery.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cadquery/cq.py b/cadquery/cq.py index 0ce909901..960979461 100644 --- a/cadquery/cq.py +++ b/cadquery/cq.py @@ -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)}" diff --git a/tests/test_cadquery.py b/tests/test_cadquery.py index 333e10a85..a5c261548 100644 --- a/tests/test_cadquery.py +++ b/tests/test_cadquery.py @@ -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