Skip to content

Commit

Permalink
Check if wires are coplanar
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-urbanczyk committed Apr 1, 2021
1 parent 7546866 commit fd0f1f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2095,12 +2095,21 @@ def makeFromWires(
Makes a planar face from one or more wires
"""

# check if wires are coplanar
ws = Compound.makeCompound([outerWire] + innerWires)
if not BRepLib_FindSurface(ws.wrapped, OnlyPlane=True).Found():
raise ValueError("Cannot build face(s): wires not planar")

face_builder = BRepBuilderAPI_MakeFace(outerWire.wrapped, True)

for w in innerWires:
face_builder.Add(w.wrapped)

face_builder.Build()

if not face_builder.IsDone():
raise ValueError(f"Cannot build face(s): {face_builder.Error()}")

face = face_builder.Shape()

return cls(face).fix()
Expand Down
4 changes: 4 additions & 0 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -3087,6 +3087,10 @@ def testExtrude(self):
delta.toTuple(), (0.0, 0.0, 2.0 * h), decimal_places
)

# check that non-conplanar extrusion raises
with self.assertRaises(ValueError):
Workplane().box(1, 1, 1).faces().circle(0.1).extrude(0.1)

def testTaperedExtrudeCutBlind(self):

h = 1.0
Expand Down

0 comments on commit fd0f1f6

Please sign in to comment.