Skip to content

Commit 99792e5

Browse files
Fix union with None (#1560)
* Fix union with None * Add test
1 parent 3451007 commit 99792e5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cadquery/cq.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,6 +3370,8 @@ def union(
33703370
self._mergeTags(toUnion)
33713371
elif isinstance(toUnion, (Solid, Compound)):
33723372
newS = [toUnion]
3373+
elif toUnion is None:
3374+
newS = []
33733375
else:
33743376
raise ValueError("Cannot union type '{}'".format(type(toUnion)))
33753377

tests/test_cadquery.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,6 +2797,15 @@ def testCombine(self):
27972797
objects2 = objects1.add(objects2).combine(glue=True, tol=None)
27982798
self.assertEqual(11, objects2.faces().size())
27992799

2800+
def testUnionNoArgs(self):
2801+
# combine using union with no arguments
2802+
s = Workplane(Plane.XY())
2803+
2804+
objects1 = s.rect(2.0, 2.0).extrude(0.5)
2805+
objects2 = s.rect(1.0, 1.0).extrude(0.5).translate((0, 0, 0.5))
2806+
objects2 = objects1.add(objects2).union(glue=True, tol=None)
2807+
self.assertEqual(11, objects2.faces().size())
2808+
28002809
def testCombineSolidsInLoop(self):
28012810
# duplicates a memory problem of some kind reported when combining lots of objects
28022811
s = Workplane("XY").rect(0.5, 0.5).extrude(5.0)

0 commit comments

Comments
 (0)