added clean argument for hole method

This commit is contained in:
hyOzd
2015-08-02 17:36:35 +03:00
parent c0444cb0fa
commit 2d1bdcad7b
2 changed files with 13 additions and 5 deletions

View File

@ -1679,7 +1679,7 @@ class Workplane(CQ):
else: else:
return -1 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) Evaluates the provided function at each point on the stack (ie, eachpoint)
and then cuts the result from the context solid. and then cuts the result from the context solid.
@ -1699,11 +1699,13 @@ class Workplane(CQ):
for cb in results: for cb in results:
s = s.cut(cb) s = s.cut(cb)
if clean: s = s.clean()
ctxSolid.wrapped = s.wrapped ctxSolid.wrapped = s.wrapped
return self.newObject([s]) return self.newObject([s])
#but parameter list is different so a simple function pointer wont work #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. Makes a counterbored hole for each item on the stack.
@ -1750,7 +1752,7 @@ class Workplane(CQ):
r = hole.fuse(cbore) r = hole.fuse(cbore)
return r return r
return self.cutEach(_makeCbore, True) return self.cutEach(_makeCbore, True, clean)
#TODO: almost all code duplicated! #TODO: almost all code duplicated!
#but parameter list is different so a simple function pointer wont work #but parameter list is different so a simple function pointer wont work
@ -1804,7 +1806,7 @@ class Workplane(CQ):
#TODO: almost all code duplicated! #TODO: almost all code duplicated!
#but parameter list is different so a simple function pointer wont work #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. 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! hole = Solid.makeCylinder(diameter / 2.0, depth, center, boreDir) # local coordinates!
return hole return hole
return self.cutEach(_makeHole, True) return self.cutEach(_makeHole, True, clean)
#TODO: duplicated code with _extrude and extrude #TODO: duplicated code with _extrude and extrude
def twistExtrude(self, distance, angleDegrees, combine=True, clean=True): def twistExtrude(self, distance, angleDegrees, combine=True, clean=True):

View File

@ -1082,6 +1082,12 @@ class TestCadQuery(BaseTest):
self.assertEqual(10, s.faces().size()) 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): def testNoClean(self):
""" """
Test the case when clean is disabled. Test the case when clean is disabled.