diff --git a/cadquery/cq.py b/cadquery/cq.py index 5cf27ed5..8e2e9233 100644 --- a/cadquery/cq.py +++ b/cadquery/cq.py @@ -2378,13 +2378,11 @@ class Workplane(CQ): return self.newObject([s]) - def union(self, toUnion=None, combine=True, clean=True): + def union(self, toUnion=None, clean=True): """ Unions all of the items on the stack of toUnion with the current solid. If there is no current solid, the items in toUnion are unioned together. - if combine=True, the result and the original are updated to point to the new object - if combine=False, the result will be on the stack, but the original is unmodified - + :param toUnion: :type toUnion: a solid object, or a CQ object having a solid, :param boolean clean: call :py:meth:`clean` afterwards to have a clean shape @@ -2409,9 +2407,8 @@ class Workplane(CQ): # now combine with existing solid, if there is one # look for parents to cut from solidRef = self.findSolid(searchStack=True, searchParents=True) - if combine and solidRef is not None: + if solidRef is not None: r = solidRef.fuse(newS) - solidRef.wrapped = newS.wrapped else: r = newS @@ -2420,13 +2417,10 @@ class Workplane(CQ): return self.newObject([r]) - def cut(self, toCut, combine=True, clean=True): + def cut(self, toCut, clean=True): """ Cuts the provided solid from the current solid, IE, perform a solid subtraction - - if combine=True, the result and the original are updated to point to the new object - if combine=False, the result will be on the stack, but the original is unmodified - + :param toCut: object to cut :type toCut: a solid object, or a CQ object having a solid, :param boolean clean: call :py:meth:`clean` afterwards to have a clean shape @@ -2451,19 +2445,13 @@ class Workplane(CQ): if clean: newS = newS.clean() - - if combine: - solidRef.wrapped = newS.wrapped - + return self.newObject([newS]) - def intersect(self, toIntersect, combine=True, clean=True): + def intersect(self, toIntersect, clean=True): """ Intersects the provided solid from the current solid. - - if combine=True, the result and the original are updated to point to the new object - if combine=False, the result will be on the stack, but the original is unmodified - + :param toIntersect: object to intersect :type toIntersect: a solid object, or a CQ object having a solid, :param boolean clean: call :py:meth:`clean` afterwards to have a clean shape @@ -2488,10 +2476,7 @@ class Workplane(CQ): newS = solidRef.intersect(solidToIntersect) if clean: newS = newS.clean() - - if combine: - solidRef.wrapped = newS.wrapped - + return self.newObject([newS]) def cutBlind(self, distanceToCut, clean=True, taper=None): diff --git a/tests/TestCadQuery.py b/tests/TestCadQuery.py index 45ddbd6b..0e70ee9c 100644 --- a/tests/TestCadQuery.py +++ b/tests/TestCadQuery.py @@ -771,9 +771,9 @@ class TestCadQuery(BaseTest): currentS = s.rect(2.0, 2.0).extrude(0.5) toCut = s.rect(1.0, 1.0).extrude(0.5) - currentS.cut(toCut.val()) + resS = currentS.cut(toCut.val()) - self.assertEqual(10, currentS.faces().size()) + self.assertEqual(10, resS.faces().size()) def testIntersect(self): """ @@ -783,15 +783,15 @@ class TestCadQuery(BaseTest): currentS = s.rect(2.0, 2.0).extrude(0.5) toIntersect = s.rect(1.0, 1.0).extrude(1) - currentS.intersect(toIntersect.val()) + resS = currentS.intersect(toIntersect.val()) - self.assertEqual(6, currentS.faces().size()) - self.assertAlmostEqual(currentS.val().Volume(),0.5) + self.assertEqual(6, resS.faces().size()) + self.assertAlmostEqual(resS.val().Volume(),0.5) - currentS.intersect(toIntersect) + resS = currentS.intersect(toIntersect) - self.assertEqual(6, currentS.faces().size()) - self.assertAlmostEqual(currentS.val().Volume(),0.5) + self.assertEqual(6, resS.faces().size()) + self.assertAlmostEqual(resS.val().Volume(),0.5) def testBoundingBox(self): """ @@ -1414,10 +1414,9 @@ class TestCadQuery(BaseTest): currentS = s.rect(2.0, 2.0).extrude(0.5) toUnion = s.rect(1.0, 1.0).extrude(1.0) - currentS.union(toUnion.val(), combine=False) - - # TODO: When unioning and combining is figured out, uncomment the following assert - # self.assertEqual(10,currentS.faces().size()) + resS = currentS.union(toUnion) + + self.assertEqual(11,resS.faces().size()) def testCombine(self): s = Workplane(Plane.XY())