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..dbdda8ce4 100644 --- a/tests/test_free_functions.py +++ b/tests/test_free_functions.py @@ -1235,6 +1235,23 @@ 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")