Skip to content
Open
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 cq_editor/cq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def to_compound(
vals.extend(obj.vals())
elif isinstance(obj, cq.Shape):
vals.append(obj)
elif isinstance(obj, list) and not obj:
pass # an empty list produces an empty compound (see #600)
elif isinstance(obj, list) and isinstance(obj[0], cq.Workplane):
for o in obj:
vals.extend(o.vals())
Expand Down
9 changes: 9 additions & 0 deletions tests/test_cq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ def test_to_compound_applies_sketch_placement():

assert f.Area() == pytest.approx(1)
assert f.normalAt().toTuple() == pytest.approx((0, -1, 0))


def test_to_compound_empty_list():
# #600: to_compound([]) used to raise IndexError while type-checking obj[0].
result = to_compound([])

assert isinstance(result, cq.Compound)
assert result.Solids() == []
assert result.Faces() == []
Loading