From e209caca2106df5ee42db49b6a9d1e609a474ab4 Mon Sep 17 00:00:00 2001 From: David Straub Date: Thu, 5 Nov 2026 14:23:34 +0100 Subject: [PATCH 1/2] 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. --- cadquery/occ_impl/shapes.py | 3 +++ tests/test_free_functions.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/cadquery/occ_impl/shapes.py b/cadquery/occ_impl/shapes.py index 97a6bd65d..a07d44fa9 100644 --- a/cadquery/occ_impl/shapes.py +++ b/cadquery/occ_impl/shapes.py @@ -7783,6 +7783,9 @@ def loft( Loft edges, wires or faces. For faces cap has no effect. Do not mix faces with other types. """ + if any(el.Faces() for el in s) and any(el.edges() and not el.Faces() for el in s): + raise ValueError("Do not mix faces with other types") + results: list[TopoDS_Shape] = [] builders = [] # for history handling diff --git a/tests/test_free_functions.py b/tests/test_free_functions.py index 3802aefd8..02ae548c6 100644 --- a/tests/test_free_functions.py +++ b/tests/test_free_functions.py @@ -1235,6 +1235,25 @@ def test_loft_vertex(): assert len(r5.Faces()) == 4 +def test_loft_mixed_faces_wires(): + + # mixing faces and wires must not silently degrade a section to a vertex + with raises(ValueError): + loft(wire(circle(1)), face(rect(2, 1)).moved(z=1)) + + with raises(ValueError): + loft(face(circle(1)), wire(rect(2, 1)).moved(z=1)) + + with raises(ValueError): + loft( + face(rect(2, 1)).moved(z=-1), wire(circle(1)), face(rect(2, 1)).moved(z=1) + ) + + # vertex ends do not hide the mixing + with raises(ValueError): + loft(vertex(0, 0, -1), face(circle(1)), wire(rect(2, 1)).moved(z=1)) + + def test_project(): base = cylinder(1, 2).faces("%CYLINDER") From eedb5d6d0b7a099763bd81be4b7b116113407ad0 Mon Sep 17 00:00:00 2001 From: AU Date: Sun, 8 Nov 2026 11:31:01 +0100 Subject: [PATCH 2/2] Black fix --- tests/test_free_functions.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_free_functions.py b/tests/test_free_functions.py index 02ae548c6..dbdda8ce4 100644 --- a/tests/test_free_functions.py +++ b/tests/test_free_functions.py @@ -1245,9 +1245,7 @@ def test_loft_mixed_faces_wires(): loft(face(circle(1)), wire(rect(2, 1)).moved(z=1)) with raises(ValueError): - loft( - face(rect(2, 1)).moved(z=-1), wire(circle(1)), face(rect(2, 1)).moved(z=1) - ) + loft(face(rect(2, 1)).moved(z=-1), wire(circle(1)), face(rect(2, 1)).moved(z=1)) # vertex ends do not hide the mixing with raises(ValueError):