Skip to content

Preview helpers

Set of preview helpers used during development.

They are not meant to be part of the public API.

assemble

assemble(tube_height, tube, model)
Source code in src/bd_tube_boxes/preview_helpers.py
def assemble(tube_height, tube, model):
    return dict(
        tube=tube,
        bottom=Location((0, 0, -tube_height / 2 - model.cap_outer_thickness)) * model.bottom(),
        top=(
            Location((0, 0, tube_height / 2 - model.cap_height + model.cap_outer_thickness))
            * Rotation(X=180.0, Y=0.0, Z=0.0)
            * model.top()
        ),
        lid=Location((0, 0, tube_height / 2 + model.cap_outer_thickness)) * Rotation(X=0.0, Y=0.0, Z=120.0) * model.lid(),
    )

clip

clip()

Cuts the view along XZ

Source code in src/bd_tube_boxes/preview_helpers.py
def clip():
    """Cuts the view along XZ"""
    set_viewer_config(tab="clip", clip_slider_1=0, clip_object_colors=True)

rectangle_canister_assembly

rectangle_canister_assembly(tube_height, model)

Creates all parts placed in the right location and returns them as a dict.

This is only interesting for generating previews as the tube, positions and rotations are not interesting for printing.

Parameters:

Name Type Description Default
tube_height float

Tube height

required
model RectangleCanisterBase

Rectangle canister variant

required

Returns:

Type Description
dict[str, Any]

dict[str, Any]: A dict with the Canister object, tube, top cap, bottom cap and lid

Source code in src/bd_tube_boxes/preview_helpers.py
def rectangle_canister_assembly(
    tube_height: float,
    model: RectangleCanisterBase,
) -> dict[str, Any]:
    """
    Creates all parts placed in the right location and returns them as a dict.

    This is only interesting for generating previews as the tube, positions and rotations are not interesting
    for printing.

    Args:
        tube_height (float): Tube height
        model (RectangleCanisterBase): Rectangle canister variant

    Returns:
        dict[str, Any]: A dict with the Canister object, tube, top cap, bottom cap and lid
    """

    tube = Location((0, 0, -tube_height / 2)) * extrude(
        RectangleRounded(model.tube_width, model.tube_length, model.tube_ext_corner_radius)
        - RectangleRounded(
            model.tube_width - model.tube_thickness * 2,
            model.tube_length - model.tube_thickness * 2,
            model.tube_ext_corner_radius - model.tube_thickness,
        ),
        tube_height,
    )

    return assemble(tube_height, tube, model)

rounded_canister_assembly

rounded_canister_assembly(tube_height, model)

Creates all parts placed in the right location and returns them as a dict.

This is only interesting for generating previews as the tube, positions and rotations are not interesting for printing.

Parameters:

Name Type Description Default
tube_height (float) Tube height
required
model RoundedCanisterBase

Rounded canister variant

required

Returns:

Type Description
dict[str, Any]

dict[str, Any]: A dict with the tube, top cap, bottom cap and lid

Source code in src/bd_tube_boxes/preview_helpers.py
def rounded_canister_assembly(
    tube_height: float,
    model: RoundedCanisterBase,
) -> dict[str, Any]:
    """
    Creates all parts placed in the right location and returns them as a dict.

    This is only interesting for generating previews as the tube, positions and rotations are not interesting
    for printing.

    Args:
        tube_height (float) Tube height:
        model (RoundedCanisterBase): Rounded canister variant

    Returns:
        dict[str, Any]: A dict with the tube, top cap, bottom cap and lid
    """
    tube = Cylinder(model.tube_ext_diam / 2, tube_height) - Cylinder(model.tube_ext_diam / 2 - model.tube_thickness, tube_height)

    return assemble(tube_height, tube, model)