Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if wires are coplanar #710

Merged
merged 1 commit into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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