Skip to content

Commit 8df1d11

Browse files
Raise in loft when faces are mixed with edges/wires (#2125)
* Raise in loft when faces are mixed with edges/wires Mixing faces and wires silently degraded the non-face sections to a vertex or dropped them. The docstring already forbids mixing; enforce it. * Black fix --------- Co-authored-by: AU <adam-urbanczyk@users.noreply.github.com>
1 parent b3f9afd commit 8df1d11

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎cadquery/occ_impl/shapes.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8195,6 +8195,9 @@ def loft(
81958195
:return: The lofted shape.
81968196
"""
81978197

8198+
if any(el.Faces() for el in s) and any(el.edges() and not el.Faces() for el in s):
8199+
raise ValueError("Do not mix faces with other types")
8200+
81988201
results: list[TopoDS_Shape] = []
81998202
builders = []
82008203
# for history handling

‎tests/test_free_functions.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,23 @@ def test_loft_vertex():
12351235
assert len(r5.Faces()) == 4
12361236

12371237

1238+
def test_loft_mixed_faces_wires():
1239+
1240+
# mixing faces and wires must not silently degrade a section to a vertex
1241+
with raises(ValueError):
1242+
loft(wire(circle(1)), face(rect(2, 1)).moved(z=1))
1243+
1244+
with raises(ValueError):
1245+
loft(face(circle(1)), wire(rect(2, 1)).moved(z=1))
1246+
1247+
with raises(ValueError):
1248+
loft(face(rect(2, 1)).moved(z=-1), wire(circle(1)), face(rect(2, 1)).moved(z=1))
1249+
1250+
# vertex ends do not hide the mixing
1251+
with raises(ValueError):
1252+
loft(vertex(0, 0, -1), face(circle(1)), wire(rect(2, 1)).moved(z=1))
1253+
1254+
12381255
def test_project():
12391256

12401257
base = cylinder(1, 2).faces("%CYLINDER")

0 commit comments

Comments
 (0)