cadquery
cadquery copied to clipboard
Wire.fillet with line+circle results in incorrect fillet direction
When adding a fillet to a (line + circle) connected edge, the fillet occasionally goes the wrong direction, resulting in a very awkward sharp angle.
The following code reproduces on cadquery-2.5.2 and cadquery-ocp-7.7.2:
def clearPendingWires(workplane):
workplane.ctx.pendingWires = []
return workplane
(
cq.Workplane("XY")
# Create the 2d shape.
.lineTo(1, 0)
.threePointArc((2, 0.75), (3.0, 0))
.lineTo(4, 0)
.lineTo(4, 2)
.threePointArc((2, 3), (0, 2))
.close()
.export("before_fillet.dxf")
.invoke(clearPendingWires)
# Perform a 2d fillet. This is where the issue occurs.
.map(lambda w: w.fillet(0.25))
.export("after_fillet.dxf")
)
before_fillet.dxf:
after_fillet.dxf:
You might try Sketch as a workaround.
from cadquery import Sketch
sk1 = (
Sketch()
.segment((0, 0), (1, 0))
.arc((2, 0.75), (3, 0))
.segment((4, 0))
.segment((4, 2))
.arc((2, 3), (0, 2))
.close()
.assemble()
)
sk1 = sk1.vertices().fillet(0.25)
# if you want only the wire from the sketch:
sk1.reset() # reset selection before selecting the wire
wire1 = sk1.wires().val()
or reusing the original Workplane code:
from cadquery import cq
from cadquery.func import face
wire1 = (
cq.Workplane("XY")
# Create the 2d shape.
.lineTo(1, 0)
.threePointArc((2, 0.75), (3.0, 0))
.lineTo(4, 0)
.lineTo(4, 2)
.threePointArc((2, 3), (0, 2))
.close()
.consolidateWires()
.val()
)
face1 = face(wire1)
face1 = face1.fillet2D(0.25, face1.vertices())
# to select the wire from the face
wire2 = face1.wires()
In both cases fillet applied to the face is working as expected.