Hacker Newsnew | past | comments | ask | show | jobs | submit | build123d's commentslogin

I'm no expert on self-reversing diamond thread but I think this generates what you're looking for. Are pictures allowed here?

    import copy
    from build123d import *
    from ocp_vscode import show_all

    od, p, n, d, e = 10 * MM, 12 * MM, 5, 1 * MM, 15 * MM

    with BuildPart() as thread_segment_builder:
        with BuildLine():
            path = Helix(p, 1.1 * p, od / 2 + 0.001)
        with BuildSketch(path ^ 0) as diamond:
            xsection = Polygon((0, d), (0, 0), (d, d / 2))
        track = sweep(is_frenet=True)
        # Trim the ends to align with Plane.XZ
        Box(2 * p, p, p / 2, align=(Align.MIN, Align.MAX, Align.MIN), mode=Mode.SUBTRACT)
        with Locations((0, 0, p)):
            Box(2 * p, p, p / 2, align=Align.MIN, mode=Mode.SUBTRACT)

    # Create the rod end with an extension beyond the threaded section
    with BuildPart() as threaded_rod_end_segment_builder:
        with Locations((0, 0, -e)):
            Cylinder(od / 2, p + e + d / 2, align=Align.NONE)
        add(thread_segment_builder.part, mode=Mode.SUBTRACT)
        add(mirror(thread_segment_builder.part, Plane.XZ), mode=Mode.SUBTRACT)


    # Position and trim the end and mid segments
    threaded_rod_end_segment = Pos(Z=-d / 2) * threaded_rod_end_segment_builder.part
    threaded_rod_mid_segment = split(threaded_rod_end_segment, Plane.XY)

    # Build the rod from copies which is very efficient
    threaded_rod = Compound(
        children=[Pos(Z=i * p) * copy.copy(threaded_rod_mid_segment) for i in range(n - 2)]
        + [
            Pos(Z=-p) * threaded_rod_end_segment,
            Pos(Z=p * (n - 1)) * (Rot(X=180) * copy.copy(threaded_rod_end_segment)),
        ]
    )

    show_all()

A valiant attempt! Unfortunately, there are a bunch of artifacts after export_step() - I don't use vscode and show_all() was sidestepped - which break the thread, see https://postimg.cc/3kkzW94T Specifically, the end of thread is a hard diamond shape with a chunk missing, and the diamond threads don't cross over at all apparently because segments of the rod have rendered on top of others. python 3.13 build123d-0.10.0 cadquery_ocp_proxy-7.9.3.1

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: