Skip to content

Commit 7876fd0

Browse files
Extrude with both=True fix (#321)
Extrude with both=True will result in a single solid. * combineWithBase fix * Allow to self-fuse a compound * Formatting fix * Test if extrude with both=True fuses the solids
1 parent 6ecb0fc commit 7876fd0

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

cadquery/cq.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,6 +2675,8 @@ def _combineWithBase(self, obj):
26752675
r = obj
26762676
if baseSolid is not None:
26772677
r = baseSolid.fuse(obj)
2678+
elif isinstance(obj, Compound):
2679+
r = obj.fuse()
26782680

26792681
return self.newObject([r])
26802682

cadquery/occ_impl/shapes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1997,7 +1997,12 @@ def fuse(self, *toFuse):
19971997
fuse_op = BRepAlgoAPI_Fuse()
19981998
# fuse_op.SetFuzzyValue(TOLERANCE)
19991999

2000-
rv = self._bool_op(self, toFuse, fuse_op)
2000+
args = tuple(self) + toFuse
2001+
2002+
if len(args) <= 1:
2003+
rv = self
2004+
else:
2005+
rv = self._bool_op(args[:1], args[1:], fuse_op)
20012006

20022007
# fuse_op.RefineEdges()
20032008
# fuse_op.FuseEdges()

tests/test_cadquery.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,6 +2548,8 @@ def testExtrude(self):
25482548
# extrude symmetrically
25492549
s = Workplane("XY").circle(r).extrude(h, both=True)
25502550

2551+
self.assertTrue(len(s.val().Solids()) == 1)
2552+
25512553
top_face = s.faces(">Z")
25522554
bottom_face = s.faces("<Z")
25532555

0 commit comments

Comments
 (0)