> How can I make the result symmetric in both X and Y axes?
Here is one method by creating an arc then mirroring the result.
import cadquery as cq
radius = 23
radius2 = radius + 3
# create ellipse arc path
path = cq.Workplane("XY").ellipseArc(radius, radius2, 0, 90).translate((radius, 0, 0))
# postions on path - where to create profiles
# 0 is start, 1 is end of path; add other pos as needed
ds = [0, 0.5, 1]
# width of profile at position index (height fixed at 10 below)
w_prof = [5, 2, 5]
# list of position and tangent vectors to define profile plane
positions = path.val().positions(ds)
tangents = [path.val().tangentAt(d) for d in ds]
# create the profiles
profs = []
for p, t, w in zip(positions, tangents, w_prof):
plane1 = cq.Plane(origin=p, normal=t)
wire1 = cq.Workplane(plane1).rect(w, 10)
profs.append(wire1.val())
# for visualization of all profiles only
vis_profs = cq.Workplane().add(profs)
# create ring shape with multisection sweep
result_sweep = (
cq.Workplane()
.add(profs)
.toPending()
.sweep(path.val(), multisection=True)
.mirror("XZ", union=True)
.mirror("YZ", union=True)
)
# example fillet inside edges
result_sweep2 = (
result_sweep.faces("|Z").edges(cq.selectors.LengthNthSelector(0)).fillet(0.2)
)
# example fillet top both edges
result_sweep3 = result_sweep.faces(">>Z").edges().fillet(0.2)
# compare with loft
result_loft = (
cq.Workplane()
.add(profs)
.toPending()
.loft()
# .loft(True) # also compare with ruled
.mirror("XZ", union=True)
.mirror("YZ", union=True)
)
Another example with Sketch:
import cadquery as cq
radius = 23
radius2 = radius + 3
th = 4 # thickness of ring
# ellipse ring
sk1 = cq.Sketch().ellipse(radius, radius2)
sk2 = cq.Sketch().ellipse(radius + th, radius2 + th)
# example: distribute shape along edge; replace mode
sk3 = sk1.copy().edges().distribute(8, 0, 1).circle(4, mode="r").reset()
# call reset when done with sketch selection
# combine sketches, extrude
result = cq.Workplane().placeSketch(sk2 - sk1 + sk3).extrude(10)
result = result.faces(">>Z").edges().fillet(0.2)