Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix union with None #1560

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -3370,6 +3370,8 @@ def union(
self._mergeTags(toUnion)
elif isinstance(toUnion, (Solid, Compound)):
newS = [toUnion]
elif toUnion is None:
newS = []
else:
raise ValueError("Cannot union type '{}'".format(type(toUnion)))

Expand Down
9 changes: 9 additions & 0 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2797,6 +2797,15 @@ def testCombine(self):
objects2 = objects1.add(objects2).combine(glue=True, tol=None)
self.assertEqual(11, objects2.faces().size())

def testUnionNoArgs(self):
# combine using union with no arguments
s = Workplane(Plane.XY())

objects1 = s.rect(2.0, 2.0).extrude(0.5)
objects2 = s.rect(1.0, 1.0).extrude(0.5).translate((0, 0, 0.5))
objects2 = objects1.add(objects2).union(glue=True, tol=None)
self.assertEqual(11, objects2.faces().size())

def testCombineSolidsInLoop(self):
# duplicates a memory problem of some kind reported when combining lots of objects
s = Workplane("XY").rect(0.5, 0.5).extrude(5.0)
Expand Down