Hacker News new | ask | show | jobs
by Cargo4286 73 days ago
Ok here is my result, which matches up well with the examples I have found from McMaster Carr. Note that not all STEP importers are robust enough to deal with files from OCCT based CAD packages. As I mentioned previously there are transition arcs from the left to right hand helices on both ends which enable the automatic reversing behavior.

    from ocp_vscode import show_all
    from build123d import *

    od, p, n, d, e = 10 * MM, 12 * MM, 5, 1 * MM, 15 * MM
    base_helix = Helix(p, 2.2 * p, od / 2 + 0.001, center=(0, 0, -p))
    # retain a small piece below XY plane for orienting sketch
    trim_base_helix = base_helix.trim(0.4, 1)
    trim2_base_helix = trim_base_helix.trim(0, 0.72)

    p0 = trim2_base_helix @ 1
    t0 = (trim2_base_helix % 1).normalized()
    t1 = Vector(0, 1, 0).normalized()

    bisector = (t0 + t1).normalized()
    if bisector.length == 0:
        bisector = t0  # Fallback if tangents are perfectly opposite

    ray = Axis(p0, bisector)
    end_pt = ray.intersect(Plane.XZ)

    transition_arc = TangentArc(p0, end_pt, tangent=t0)

    rh_curve = Curve() + [trim2_base_helix, transition_arc]
    profile = (rh_curve ^ 0) * Rot(Z=99) * Circle(d)  # rotate seam out of the way
    rh_sweep = sweep(profile, rh_curve)
    splitter = Plane.XZ * Rectangle(10, 40, align=(Align.MIN, Align.CENTER)).face()
    rh_sweep = split(rh_sweep, bisect_by=splitter, keep=Keep.BOTH).solids()[1]
    lh_sweep = mirror(rh_sweep, about=Plane.XZ)

    both_sweeps = Part() + [rh_sweep, lh_sweep]

    cyl = Part() + Cylinder(od / 2, p + e + d / 2)
    cyl -= both_sweeps
    cyl = split(cyl, bisect_by=Plane.XY)
    cyl += mirror(cyl, about=Plane.XY)
    show_all()
I also tested the above in the online build123d-sandbox here, which worked great: https://jojain.github.io/build123d-sandbox
1 comments

This looks on the mark. Congratulations! You have succeeded where others failed.