diff --git a/cadquery/CQ.py b/cadquery/CQ.py index addaa7c..0ecac23 100644 --- a/cadquery/CQ.py +++ b/cadquery/CQ.py @@ -1679,7 +1679,7 @@ class Workplane(CQ): else: return -1 - def cutEach(self, fcn, useLocalCoords=False): + def cutEach(self, fcn, useLocalCoords=False, clean=True): """ Evaluates the provided function at each point on the stack (ie, eachpoint) and then cuts the result from the context solid. @@ -1699,11 +1699,13 @@ class Workplane(CQ): for cb in results: s = s.cut(cb) + if clean: s = s.clean() + ctxSolid.wrapped = s.wrapped return self.newObject([s]) #but parameter list is different so a simple function pointer wont work - def cboreHole(self, diameter, cboreDiameter, cboreDepth, depth=None): + def cboreHole(self, diameter, cboreDiameter, cboreDepth, depth=None, clean=True): """ Makes a counterbored hole for each item on the stack. @@ -1750,7 +1752,7 @@ class Workplane(CQ): r = hole.fuse(cbore) return r - return self.cutEach(_makeCbore, True) + return self.cutEach(_makeCbore, True, clean) #TODO: almost all code duplicated! #but parameter list is different so a simple function pointer wont work @@ -1804,7 +1806,7 @@ class Workplane(CQ): #TODO: almost all code duplicated! #but parameter list is different so a simple function pointer wont work - def hole(self, diameter, depth=None): + def hole(self, diameter, depth=None, clean=True): """ Makes a hole for each item on the stack. @@ -1843,7 +1845,7 @@ class Workplane(CQ): hole = Solid.makeCylinder(diameter / 2.0, depth, center, boreDir) # local coordinates! return hole - return self.cutEach(_makeHole, True) + return self.cutEach(_makeHole, True, clean) #TODO: duplicated code with _extrude and extrude def twistExtrude(self, distance, angleDegrees, combine=True, clean=True): diff --git a/tests/TestCadQuery.py b/tests/TestCadQuery.py index 49955e0..6de3a63 100644 --- a/tests/TestCadQuery.py +++ b/tests/TestCadQuery.py @@ -1082,6 +1082,12 @@ class TestCadQuery(BaseTest): self.assertEqual(10, s.faces().size()) + # test removal of splitter caused by double hole operation + s = Workplane("XY").box(10,10,10).faces(">Z").workplane().\ + hole(3,5).faces(">Z").workplane().hole(3,10) + + self.assertEqual(7, s.faces().size()) + def testNoClean(self): """ Test the case when clean is disabled.