Skip to content
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
5 changes: 1 addition & 4 deletions cq_editor/cq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ def to_compound(
elif isinstance(obj, list) and isinstance(obj[0], TopoDS_Shape):
vals.extend(cq.Shape.cast(o) for o in obj)
elif isinstance(obj, cq.Sketch):
if obj._faces:
vals.append(obj._faces)
else:
vals.extend(obj._edges)
vals.extend(obj)
else:
raise ValueError(f"Invalid type {type(obj)}")

Expand Down
13 changes: 13 additions & 0 deletions tests/test_cq_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import cadquery as cq
import pytest

from cq_editor.cq_utils import to_compound


def test_to_compound_applies_sketch_placement():
sk = cq.Sketch().rect(1, 1)
placed = cq.Workplane("XZ").placeSketch(sk).val()
f = to_compound(placed).face()

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