import cadquery as cq

flange_r = 26.0
flange_t = 5.2
shank_r = 10.5
shank_len = 25.5
bore_r = 5.0
ch = 0.7

# Main material: broad seating flange above the XY plane and a centered
# sleeve extending downward from the underside.
flange = cq.Workplane("XY").circle(flange_r).extrude(flange_t)
shank = cq.Workplane("XY").circle(shank_r).extrude(-shank_len)
body = flange.union(shank)

# Continuous coaxial bore through the entire part. This is one Z-axis cutter;
# the top and bottom openings are the two exposed ends of the same hole.
bore_cutter = (
    cq.Workplane("XY")
    .workplane(offset=-shank_len - 2.0)
    .circle(bore_r)
    .extrude(shank_len + flange_t + 4.0)
)
body = body.cut(bore_cutter)

# Small circular edge softening for the flange rim, bore mouths, and sleeve end.
try:
    body = body.edges("%Circle").chamfer(ch)
except Exception:
    pass

primary_body = body
PARTS = {
    "primary_body": primary_body,
}

result = primary_body
r = result
