pyboxbuilder.box.spec.BoxSpec

class pyboxbuilder.box.spec.BoxSpec(width: float, length: float, height: float, label: str = 'box', wall_thickness: float = 2.0, floor_thickness: float = 1.6, lid_thickness: float = 2.0, hollow: bool = True, path: tuple[tuple[float, float], ...] = (), interior_top: float | None = None, wall_tops: dict[~pyboxbuilder.enums.ScoopSide, float] = <factory>, open_sides: tuple[~pyboxbuilder.enums.ScoopSide, ...] = (), mid_wall_height_ratio: float | None = None, end_wall_length: float = 30.0, rounding: float | None = None, base_rounding: float | None = None, base_chamfer: float | bool | None = None, inner_rounding: float | None = None, rim_free: bool = False, rim_rounding: float | None = None, lid_corner_rounding: float | None = None, finger_holes: tuple[~typing.Any, ...] = (), auto_finger_holes: bool = True, size_spacing: float = 0.2, sliding_slack: float = 0.1, cap_slack: float = 0.2, slip_slack: float = 0.2, lid_slide_axis: str | None = None, dovetail: bool = True, lead_chamfer: float | None = None, catch_type: ~pyboxbuilder.enums.CatchType | str | None = None, catch_size: float | None = None, catch_radius: float | None = None, latch_radius: float = 1.2, fingernail_catch: bool = True, fingernail_radius: float | None = None, fingernail_depth: float | None = None, lid_border_margin_mm: float | None = None, cap_height: float | None = None, cap_finger_cutouts: bool = True, cap_finger_radius: float | None = None, cap_finger_length: float | None = None, cap_finger_height: float | None = None, foot: float = 2.0, slip: float = 1.6, slipover_gap: float | None = None, slipover_finger_height: float | None = None, inset: float = 1.0, hinge_count: int = 5, hinge_pin_diameter: float = 3.0, filament_diameter: float = 1.75, hinge_catch_type: ~pyboxbuilder.enums.HingeCatchType | None = None, magnet_type: ~pyboxbuilder.enums.MagnetType | None = None, magnet_size: tuple[float, float, float] | None = None, magnet_diameter: float = 6.0, magnet_height: float = 3.0, magnet_count_width: int = 2, magnet_count_length: int = 2, stackable: ~pyboxbuilder.enums.StackableMode | None = None, stackable_shape: ~pyboxbuilder.enums.StackableShape | None = None, stackable_pyramid_count: int | tuple[int, ...] | None = None, stackable_top_pyramid_count: int | tuple[int, ...] | None = None, stackable_bottom_pyramid_count: int | tuple[int, ...] | None = None, stackable_top: bool = True, stackable_bottom: bool = True, stackable_printer_safe: bool = True, stackable_pattern: ~pyboxbuilder.enums.PatternType | None = None, stackable_pattern_spacing: float | None = None, stackable_pattern_web: float | None = None, stackable_pattern_border: float | None = None, stackable_thickness: float | None = None, stackable_fit_offset: float = 0.15, stackable_foot_size: float | None = None, stackable_foot_height: float = 1.6, stackable_foot_inset: float | None = None, tilt_to_lift: bool = True, keystone: bool = False, ribbon_channel: bool = False, cantilever_thickness: float = 2.0, cantilever_width: float = 14.0, deflection_clearance: float = 0.25, detent_height: float = 0.8, latch_axis: ~pyboxbuilder.enums.LatchAxis = LatchAxis.X, lug_count: int = 4, turn_angle: float = 90.0, lug_height: float = 2.5, lug_depth: float = 1.2, bayonet_slack: float = 0.3, round_footprint: bool = False, thread_pitch: float = 3.0, thread_turns: float = 2.0, thread_clearance: float = 0.25, thread_depth: float = 1.0, chute_angle: float = 0.0, tile_angle: float | None = None, token_thickness: float = 3.0, dispense_slot_clearance: float = 0.8, sight_slot_width: float = 8.0, sight_slot_start: float | None = None, dispenser_mode: ~pyboxbuilder.enums.DispenserExtractionMode = DispenserExtractionMode.SCOOP, scoop_radius: float = 14.0, floor_scoop_depth: float = 12.0, floor_scoop_width: float = 24.0, tray_depth: float = 20.0, rear_push_width: float = 22.0, arch_height: float | None = None, draw_angle: float = 20.0, retaining_lip_height: float = 10.0, discard_well: bool = True, arena_wall_height: float = 28.0, felt_pocket_depth: float = 1.2, corner_deflectors: bool = True, push_hole_radius: float = 0.0, drawer_handle_style: ~pyboxbuilder.enums.DrawerHandleStyle = DrawerHandleStyle.HANDLE, drawer_handle_length: float = 4.0, drawer_pull_lip: float = 4.0, sleeve_slack: float = 0.25, sleeve_wall_thickness: float | None = None, spine_gap: float = 1.0, clamshell_hinge_radius: float = 2.5, closure_latch: bool = True, interlock_type: ~pyboxbuilder.enums.InterlockType | None = None, interlock_clearance: float = 0.15, interlock_size: float | tuple[float, ...] | None = None, interlock_sides: tuple[int | str, ...] | None = None, dovetail_clearance: float = 0.15, gridfinity_pitch: float = 42.0, polygon_sides: int | None = None, polygon_apothem: float | None = None, pip_radial_clearance: float = 0.35, pip_axial_clearance: float = 0.4, pip_cone_angle: float = 45.0, pip_hinge_radius: float = 3.0, pip_bridge_width: float = 0.4, pip_bridge_thickness: float = 0.4, pip_snap_catch: bool = True, pip_snap_width: float = 12.0, pip_snap_diameter: float = 3.0, pip_gap_mm: float = 1.0, inset_hinge_side_gap: float = 3.0, inset_hinge_tab_height: float = 6.0, slide_catch_style: str = 'front')[source]

Bases: object

Everything a box type needs to build its body and lid.

Frozen, so a type cannot reach back and change the description it was handed. Derive a variant with dataclasses.replace():

body_spec = replace(spec, height=spec.height - spec.lid_thickness)
default_wall_top() → float[source]

How high a wall stands when the box type says nothing about it.

The box’s own top face, less any band a lid occupies — so a cut merges into the surface a hand actually touches rather than into a plane buried under the lid.

Returns:

The z of the wall’s top.

interior() → Interior[source]

Return the usable volume inside this box.

Returns:

An Interior in the box’s own frame, inset by the wall on the sides and the floor below.

resolved_catch_size(default: float | None = None) → float[source]

Return the primary dimension for the catch (FR-099).

resolved_catch_type(default: CatchType = CatchType.NONE) → CatchType[source]

Return the resolved CatchType enum for this box (FR-099).

to_unresolved() → UnresolvedBoxSpec[source]

Convert this resolved spec into a mutable declaration spec (FR-091).

wall_top(side: ScoopSide) → float[source]

One wall’s top z (FR-070).

Parameters:
side: ScoopSide

Which wall.

Returns:

That wall’s top, or default_wall_top() if this spec carries no per-side map yet.

with_wall_tops(box: object) → BoxSpec[source]

Return this spec with each wall’s top resolved for a box type.

The four walls of a box do not have to end at the same height, and assuming they do is how a scoop ends up hanging in space: a sliding box’s exit wall stops a lid thickness below the others, because that is where its channel runs out through it.

Parameters:
box: object

The box type implementation, whose wall_tops hook may raise or lower individual sides.

Returns:

A copy carrying a complete wall_tops map.

auto_finger_holes : bool = True

Let a lidless box cut its own default pair of grips (FR-047/FR-047b).

base_chamfer : float | bool | None = None

Bottom chamfer in mm, or True for 3.0mm; None defaults to a rounded base.

base_rounding : float | None = None

Radius for this body’s base/bottom edges; None derives it from wall_thickness.

cap_finger_cutouts : bool = True

Cut the four corner finger recesses in a cap body (FR-002i).

cap_finger_height : float | None = None

Height of a corner cutout; None derives it from the skirt.

cap_finger_length : float | None = None

How far a corner cutout runs along each side; None derives it between 10mm and a sixth of the side (FR-002m).

cap_finger_radius : float | None = None

Corner cutout radius; None derives it from the height available.

cap_height : float | None = None

Skirt height of a cap lid; None derives it from the box height.

cap_slack : float = 0.2

Clearance between a cap lid’s skirt and the body band it grips.

catch_radius : float | None = None

Bump-catch radius; None is no catch, which is a plain sliding box’s default (FR-002e3).

catch_size : float | None = None

Primary dimension for the catch (bump radius, wedge depth, or loop size); None derives from wall thickness.

catch_type : CatchType | str | None = None

Lid retention mechanism — NONE, BUMP, LOOP, WEDGE, or None for type default (FR-099).

dovetail : bool = True

Cut the lid’s retaining dovetail; False leaves a plain channel.

end_wall_length : float = 30.0

Length in mm of the full-height wall sections at each end when stepped.

filament_diameter : float = 1.75

Diameter of the filament a living hinge is printed around.

finger_holes : tuple[Any, ...] = ()

Explicit exterior finger holes on this box’s walls.

fingernail_catch : bool = True

Cut the dish a nail starts a sliding lid with (FR-002e5).

On by default: a seated sliding lid is a flush plate with nothing to grip, so the dish is part of the type rather than an option. Only the sliding family reads this.

fingernail_depth : float | None = None

How deep it sinks; None uses half the lid’s thickness, which is also the cap — the dish must never pierce the plate.

fingernail_radius : float | None = None

Opening radius of that dish; None derives it from the lid’s narrow dimension.

floor_thickness : float = 1.6

Base thickness in mm.

foot : float = 2.0

Height of exposed base a slipover sleeve stops above (FR-002p).

height : float

Outer height (Z) in mm.

hinge_catch_type : HingeCatchType | None = None

Catch type for hinged boxes (FR-106); HingeCatchType.RIDGE, HingeCatchType.BUMP, or HingeCatchType.NONE.

hinge_count : int = 5

Number of knuckles along the hinge.

hinge_pin_diameter : float = 3.0

Diameter of the hinge pin, in mm.

hollow : bool = True

Hollow the whole interior. False where compartments define the cavities instead, or for a solid block.

inner_rounding : float | None = None

Radius where a partial lid grips the body; None uses half the outer radius (FR-044b).

inset : float = 1.0

Rabbet depth for an inset lid.

interior_top : float | None = None

Explicit z of the interior’s ceiling; None derives it as the box top less any band the lid occupies (FR-064).

keystone : bool = False

Make this the first-out box with extra clearance and a finger scoop.

label : str = 'box'

The box’s name, used for file naming and in error messages.

latch_axis : LatchAxis = 'x'

Axis on whose opposing walls the latches sit (FR-081, FR-106).

latch_radius : float = 1.2

Catch radius for the card-library type, which always carries one.

lead_chamfer : float | None = None

Chamfer on the lid’s leading end; None uses a quarter of the lid thickness (FR-002d).

length : float

Outer length (Y) in mm.

lid_border_margin_mm : float | None = None

Margin the label keeps clear of the lid edge; propagated from the lid builder.

lid_corner_rounding : float | None = None

Radius of a sliding lid’s vertical corners; None derives it from the wall, capped at the dovetail depth (FR-002e4).

lid_slide_axis : str | None = None

Sliding axis (‘x’ along width, ‘y’ along length, or None for default).

lid_thickness : float = 2.0

Lid plate thickness in mm; 0 for a lidless type.

magnet_count_length : int = 2

Magnets per wall on the length axis.

magnet_count_width : int = 2

Magnets per wall on the width axis.

magnet_diameter : float = 6.0

Round magnet diameter, in mm.

magnet_height : float = 3.0

Round magnet slot depth, in mm.

magnet_size : tuple[float, float, float] | None = None

Slot dimensions (diameter_or_width, length, depth).

magnet_type : MagnetType | None = None

Magnet slot shape; None means no magnets.

mid_wall_height_ratio : float | None = None

Optional fractional height (0 < r < 1) for the lowered middle span of side walls.

open_sides : tuple[ScoopSide, ...] = ()

Exterior walls omitted down to the floor on a no-lid tray/cradle.

path : tuple[tuple[float, float], ...] = ()

Closed polygon footprint for a path box; empty means the rectangle implied by width and length (FR-018).

ribbon_channel : bool = False

Cut bottom groove for lifting ribbon.

rim_free : bool = False

True when nothing mates with the top rim, so the rim rounds too (FR-043f).

rim_rounding : float | None = None

Radius for a top edge that stays exposed with the lid on — a sliding box’s rails (FR-043f1). None means none.

rounding : float | None = None

Radius for this body’s exposed edges; None uses half the wall.

size_spacing : float = 0.2

General clearance between two mating printed parts, in mm.

slide_catch_style : str = 'front'

Placement style for sliding hinge catch (‘front’ or ‘card_library’).

sliding_slack : float = 0.1

Clearance per side between a sliding lid and its groove (FR-002f).

slip : float = 1.6

Slipover sleeve wall thickness.

slip_slack : float = 0.2

Clearance between a slipover sleeve and the body it wraps.

slipover_finger_height : float | None = None

Height of the sleeve’s corner notches; None uses half the skirt, capped at 20mm (FR-002h).

slipover_gap : float | None = None

Band of body left showing below the sleeve; None derives it as a quarter of the covered height, held between 3mm and 6mm (FR-002p).

stackable : StackableMode | None = None

Interlocking rim mode; None means not stackable.

stackable_bottom : bool = True

Whether to cut bottom stacking sockets/grooves into the floor.

stackable_bottom_pyramid_count : int | tuple[int, ...] | None = None

Pyramid grid configuration for the bottom floor sockets; None falls back to stackable_pyramid_count.

stackable_fit_offset : float = 0.15

Clearance between a stacked box’s foot/rim and the one below it.

stackable_foot_height : float = 1.6

Height of protruding locator feet / depth of matching indents in mm.

stackable_foot_inset : float | None = None

Inset distance from perimeter in mm; None derives it from wall_thickness / 2.

stackable_foot_size : float | None = None

Width/diameter of locator feet in mm; None derives it from wall_thickness.

stackable_pattern : PatternType | None = None

Pattern type used for pattern-matched stacking; None derives from lid pattern or defaults to HEX.

stackable_pattern_border : float | None = None

Border margin in mm for pattern-matched stacking; None derives from lid pattern or LID_BORDER_MM.

stackable_pattern_spacing : float | None = None

Cell spacing in mm for pattern-matched stacking; None derives from lid pattern or footprint.

stackable_pattern_web : float | None = None

Rib web width in mm for pattern-matched stacking; None derives from lid pattern or DEFAULT_WEB_MM.

stackable_printer_safe : bool = True

Keep the box bottom flat on the print bed (z = 0) with recessed 45-degree sockets and top bosses.

stackable_pyramid_count : int | tuple[int, ...] | None = None

Pyramid grid config per corner pad (int N, 2-tuple (nx, ny), or 4-tuple (c_fl, c_fr, c_bl, c_br)).

stackable_shape : StackableShape | None = None

3D-printable geometry profile for feet/indents (PYRAMIDS, PYRAMID, CONE, PATTERN, FLAT).

stackable_thickness : float | None = None

Interlocking rim thickness; None derives it from the wall.

stackable_top : bool = True

Whether to generate top stacking bosses/ridges on the lid or top rim.

stackable_top_pyramid_count : int | tuple[int, ...] | None = None

Pyramid grid configuration for the top lid/rim; None falls back to stackable_pyramid_count.

tilt_to_lift : bool = True

Subtle bottom rounding (wall_thickness) to rock box up for easy extraction.

wall_thickness : float = 2.0

Side wall thickness in mm.

wall_tops : dict[ScoopSide, float]

The z of each wall’s top, per side (FR-070). Filled in by with_wall_tops(); empty until then.

width : float

Outer width (X) in mm.