Skip to content

Commit 7afbb37

Browse files
committed
Mixin3D.shell: allow faceList=None
1 parent 47519f6 commit 7afbb37

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

cadquery/occ_impl/shapes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,7 @@ def chamfer(
23512351

23522352
def shell(
23532353
self: Any,
2354-
faceList: Iterable[Face],
2354+
faceList: Optional[Iterable[Face]],
23552355
thickness: float,
23562356
tolerance: float = 0.0001,
23572357
kind: Literal["arc", "intersection"] = "arc",
@@ -2375,8 +2375,9 @@ def shell(
23752375
occ_faces_list = TopTools_ListOfShape()
23762376
shell_builder = BRepOffsetAPI_MakeThickSolid()
23772377

2378-
for f in faceList:
2379-
occ_faces_list.Append(f.wrapped)
2378+
if faceList:
2379+
for f in faceList:
2380+
occ_faces_list.Append(f.wrapped)
23802381

23812382
shell_builder.MakeThickSolidByJoin(
23822383
self.wrapped,

tests/test_cadquery.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,6 +2290,14 @@ def testClosedShell(self):
22902290
s3 = Workplane().polyline(pts).close().extrude(1).shell(-0.05)
22912291
self.assertTrue(s3.val().isValid())
22922292

2293+
s4_shape = Workplane("XY").box(2, 2, 2).val()
2294+
# test that None and empty list both work and are equivalent
2295+
s4_shell_1 = s4_shape.shell(faceList=None, thickness=-0.1)
2296+
s4_shell_2 = s4_shape.shell(faceList=[], thickness=-0.1)
2297+
# this should be the same as the first shape
2298+
self.assertEqual(len(s4_shell_1.Faces()), s1.faces().size())
2299+
self.assertEqual(len(s4_shell_2.Faces()), s1.faces().size())
2300+
22932301
def testOpenCornerShell(self):
22942302
s = Workplane("XY").box(1, 1, 1)
22952303
s1 = s.faces("+Z")

0 commit comments

Comments
 (0)