Skip to content

Commit 39e60f6

Browse files
adam-urbanczykmarcus7070
authored andcommitted
Check if wires are coplanar
1 parent 7546866 commit 39e60f6

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cadquery/occ_impl/shapes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,12 +2095,21 @@ def makeFromWires(
20952095
Makes a planar face from one or more wires
20962096
"""
20972097

2098+
# check if wires are coplanar
2099+
ws = Compound.makeCompound([outerWire] + innerWires)
2100+
if not BRepLib_FindSurface(ws.wrapped, OnlyPlane=True).Found():
2101+
raise ValueError("Cannot build face(s): wires not planar")
2102+
20982103
face_builder = BRepBuilderAPI_MakeFace(outerWire.wrapped, True)
20992104

21002105
for w in innerWires:
21012106
face_builder.Add(w.wrapped)
21022107

21032108
face_builder.Build()
2109+
2110+
if not face_builder.IsDone():
2111+
raise ValueError(f"Cannot build face(s): {face_builder.Error()}")
2112+
21042113
face = face_builder.Shape()
21052114

21062115
return cls(face).fix()

tests/test_cadquery.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,6 +3087,10 @@ def testExtrude(self):
30873087
delta.toTuple(), (0.0, 0.0, 2.0 * h), decimal_places
30883088
)
30893089

3090+
# check that non-conplanar extrusion raises
3091+
with self.assertRaises(ValueError):
3092+
Workplane().box(1, 1, 1).faces().circle(0.1).extrude(0.1)
3093+
30903094
def testTaperedExtrudeCutBlind(self):
30913095

30923096
h = 1.0

0 commit comments

Comments
 (0)