Skip to content

Rectangle canister base

RectangleCanisterBase

RectangleCanisterBase(
    tube_width,
    tube_length,
    tube_ext_corner_radius,
    tube_thickness,
    caps_height=8,
    caps_outer_thickness=1,
    clearance=0.1,
    lid_shoulder=None,
)

Base class for all the rectangle canisters

Parameters:

Name Type Description Default
tube_width float

Tube width

required
tube_length float

Tube length

required
tube_ext_corner_radius float

External radius of the corners

required
tube_thickness float

Tube thickness

required
caps_height float

Height for the caps

8
caps_outer_thickness float

Thickness applied to the outside of the caps (and the bottom part)

1
clearance float

Clearance used in various parts of the assembly

0.1
lid_shoulder float | None

Lid shoulder to hide the lock. When None, value is based on cap_height

None
Source code in src/bd_tube_boxes/rectangle_canister_base.py
def __init__(
    self,
    tube_width: float,
    tube_length: float,
    tube_ext_corner_radius: float,
    tube_thickness: float,
    caps_height: float = 8,
    caps_outer_thickness: float = 1,
    clearance: float = 0.1,
    lid_shoulder: float | None = None,
):
    """
    Base class for all the rectangle canisters

    Args:
        tube_width (float): Tube width
        tube_length (float): Tube length
        tube_ext_corner_radius (float): External radius of the corners
        tube_thickness (float): Tube thickness
        caps_height (float): Height for the caps
        caps_outer_thickness (float): Thickness applied to the outside of the caps (and the bottom part)
        clearance (float): Clearance used in various parts of the assembly
        lid_shoulder (float|None): Lid shoulder to hide the lock. When `None`, value is based on `cap_height`
    """
    self.tube_width = tube_width
    self.tube_length = tube_length
    self.tube_ext_corner_radius = tube_ext_corner_radius
    self.tube_thickness = tube_thickness
    self.cap_height = caps_height
    self.cap_outer_thickness = caps_outer_thickness
    self.clearance = clearance

    self.lid_shoulder = lid_shoulder if lid_shoulder is not None else self.cap_height / 5

    self.cap_lid_hole_wall_thickness = self.cap_outer_thickness + self.lid_shoulder
    self.cap_lid_hole_radius = tube_width / 2 if tube_width < tube_length else tube_length / 2
    self.cap_lid_hole_radius -= self.cap_lid_hole_wall_thickness + self.lid_shoulder

cap_height instance-attribute

cap_height = caps_height

Input: caps height

cap_lid_hole_radius instance-attribute

cap_lid_hole_radius = (
    tube_width / 2
    if tube_width < tube_length
    else tube_length / 2
)

Radius of the lid hole in the cap. Includes clearance

cap_lid_hole_wall_thickness instance-attribute

cap_lid_hole_wall_thickness = (
    cap_outer_thickness + lid_shoulder
)

Thickness of the threaded part of the top cap

cap_outer_thickness instance-attribute

cap_outer_thickness = caps_outer_thickness

Input: caps outer thickness

clearance instance-attribute

clearance = clearance

Clearance on both sides of the tube

lid_shoulder instance-attribute

lid_shoulder = (
    lid_shoulder
    if lid_shoulder is not None
    else cap_height / 5
)

Lid shoulder to hide the lock

part_final_outer_radius instance-attribute

part_final_outer_radius

Radius for the inside of the tube

tube_ext_corner_radius instance-attribute

tube_ext_corner_radius = tube_ext_corner_radius

Input: external radius of the corners

tube_final_inner_radius instance-attribute

tube_final_inner_radius

External radius of the part

tube_final_outer_radius instance-attribute

tube_final_outer_radius

Radius for the outside of the tube

tube_length instance-attribute

tube_length = tube_length

Input: tube length

tube_thickness instance-attribute

tube_thickness = tube_thickness

Input: tube thickness

tube_width instance-attribute

tube_width = tube_width

Input: tube width

bottom

bottom(
    rotation=(0, 0, 0),
    align=(Align.CENTER, Align.CENTER, Align.MIN),
    mode=Mode.ADD,
)

Creates the bottom part

Source code in src/bd_tube_boxes/rectangle_canister_base.py
def bottom(
    self,
    rotation: RotationLike = (0, 0, 0),
    align: Align | tuple[Align, Align, Align] = (
        Align.CENTER,
        Align.CENTER,
        Align.MIN,
    ),
    mode: Mode = Mode.ADD,
):
    """
    Creates the bottom part
    """

    cap_base = self._cap_base(align=(Align.CENTER, Align.CENTER, Align.MIN))
    inset_loc = Location((0, 0, self.cap_outer_thickness))
    ext_tube = RectangleRounded(width=self.tube_width, height=self.tube_length, radius=self.tube_ext_corner_radius)
    inset = extrude(offset(ext_tube, -(self.tube_thickness + self.clearance + self.cap_outer_thickness)), self.cap_height)
    inset = inset_loc * inset

    solid = cap_base - inset

    return BasePartObject(part=solid, rotation=rotation, align=tuplify(align, 3), mode=mode)

lid

lid()

Creates the lid

Source code in src/bd_tube_boxes/rectangle_canister_base.py
def lid(self):
    """
    Creates the lid
    """
    raise NotImplementedError

top

top(
    rotation=(0, 0, 0),
    align=(Align.CENTER, Align.CENTER, Align.MAX),
    mode=Mode.ADD,
)

Creates the top part

Source code in src/bd_tube_boxes/rectangle_canister_base.py
def top(
    self,
    rotation: RotationLike = (0, 0, 0),
    align: Align | tuple[Align, Align, Align] = (
        Align.CENTER,
        Align.CENTER,
        Align.MAX,
    ),
    mode: Mode = Mode.ADD,
):
    """
    Creates the top part
    """

    solid = self._cap_base(align=(Align.CENTER, Align.CENTER, Align.MIN))

    thread = self._cap_lock()
    solid -= thread

    return BasePartObject(part=solid, rotation=rotation, align=tuplify(align, 3), mode=mode)