MCPcopy
hub / github.com/CadQuery/cadquery / makeFromWires

Method makeFromWires

cadquery/occ_impl/shapes.py:3642–3678  ·  view source on GitHub ↗

Makes a planar face from one or more wires

(cls, outerWire: Wire, innerWires: list[Wire] = [])

Source from the content-addressed store, hash-verified

3640
3641 @classmethod
3642 def makeFromWires(cls, outerWire: Wire, innerWires: list[Wire] = []) -> Face:
3643 """
3644 Makes a planar face from one or more wires
3645 """
3646
3647 if innerWires and not outerWire.IsClosed():
3648 raise ValueError("Cannot build face(s): outer wire is not closed")
3649
3650 # check if wires are coplanar
3651 ws = Compound.makeCompound([outerWire] + innerWires)
3652 if not BRepLib_FindSurface(ws.wrapped, OnlyPlane=True).Found():
3653 raise ValueError("Cannot build face(s): wires not planar")
3654
3655 # fix outer wire
3656 sf_s = ShapeFix_Shape(outerWire.wrapped)
3657 sf_s.Perform()
3658 wo = TopoDS.Wire(sf_s.Shape())
3659
3660 face_builder = BRepBuilderAPI_MakeFace(wo, True)
3661
3662 for w in innerWires:
3663 if not w.IsClosed():
3664 raise ValueError("Cannot build face(s): inner wire is not closed")
3665 face_builder.Add(w.wrapped)
3666
3667 face_builder.Build()
3668
3669 if not face_builder.IsDone():
3670 raise ValueError(f"Cannot build face(s): {face_builder.Error()}")
3671
3672 face = face_builder.Face()
3673
3674 sf_f = ShapeFix_Face(face)
3675 sf_f.FixOrientation()
3676 sf_f.Perform()
3677
3678 return cls(sf_f.Result())
3679
3680 @classmethod
3681 def makeSplineApprox(

Callers 15

keyMethod · 0.45
faceMethod · 0.45
circleMethod · 0.45
ellipseMethod · 0.45
fillet2DMethod · 0.45
chamfer2DMethod · 0.45
dprismMethod · 0.45
extrudeLinearMethod · 0.45
revolveMethod · 0.45
sortWiresByBuildOrderFunction · 0.45
wiresToFacesFunction · 0.45
add_shapeMethod · 0.45

Calls 2

IsClosedMethod · 0.80
makeCompoundMethod · 0.80

Tested by 9

testSplineMethod · 0.36
testMakeShellSolidMethod · 0.36
test2DfilletMethod · 0.36
test2DchamferMethod · 0.36
test_constraint_getPlnFunction · 0.36