Skip to content

Threaded lid

ThreadedLid

ThreadedLid(
    cap_lid_hole_radius,
    cap_lid_hole_wall_thickness,
    cap_height,
    cap_outer_thickness,
    lid_shoulder,
    thread_pitch,
    clearance,
    rotation=(0, 0, 0),
    align=(Align.CENTER, Align.CENTER, Align.MAX),
    mode=Mode.ADD,
)

Bases: BasePartObject

Creates the screw for the top

Source code in src/bd_tube_boxes/threaded_lid.py
def __init__(
    self,
    cap_lid_hole_radius: float,
    cap_lid_hole_wall_thickness: float,
    cap_height: float,
    cap_outer_thickness: float,
    lid_shoulder: float,
    thread_pitch: float,
    clearance: float,
    rotation: RotationLike = (0, 0, 0),
    align: Align | tuple[Align, Align, Align] = (
        Align.CENTER,
        Align.CENTER,
        Align.MAX,
    ),
    mode: Mode = Mode.ADD,
):
    """
    Creates the screw for the top
    """

    screw_radius = cap_lid_hole_radius - clearance
    solid = Solid.make_cylinder(screw_radius, cap_height)
    solid += (
        Location((0, 0, cap_height - cap_outer_thickness)) *
        Solid.make_cylinder(screw_radius + lid_shoulder, cap_outer_thickness)
    )  # fmt: off
    grip_sk = Circle(cap_lid_hole_radius - cap_lid_hole_wall_thickness)
    grip_sk -= Rectangle(lid_shoulder * 2, cap_lid_hole_radius * 2 + 2)
    grip = extrude(grip_sk, cap_height)

    solid -= Location((0, 0, cap_lid_hole_wall_thickness)) * grip
    solid = chamfer(solid.edges().filter_by(GeomType.CIRCLE).sort_by(Axis.Z)[4], lid_shoulder - 0.01)

    thread = Location((0, 0, lid_shoulder)) * IsoThread(
        major_diameter=(cap_lid_hole_radius - clearance) * 2 + thread_pitch,
        pitch=thread_pitch,
        length=thread_pitch,
    )
    solid += thread

    # Bottom chamfer
    solid = chamfer(solid.edges().sort_by(Axis.Z)[0], lid_shoulder)
    # Grip chamfer
    solid = chamfer(solid.wires().filter_by(Plane.XY).sort_by(SortBy.LENGTH)[0:4].edges(), cap_outer_thickness / 2)

    return super().__init__(part=solid, rotation=rotation, align=tuplify(align, 3), mode=mode)