pyboxbuilder.box.base.BoxTypeBase

class pyboxbuilder.box.base.BoxTypeBase[source]

Bases: object

Base for every box type implementation.

A subclass must provide build_body(), and build_lid() unless it is a lidless type. Everything else has a default that suits a plain box with a lid sitting on top of it.

build_body(spec: ResolvedBoxSpec) → Bosl2Solid[source]

Build the box body geometry.

Parameters:
spec: ResolvedBoxSpec

The box’s resolved description.

Returns:

The body solid, in the box’s own frame with its minimum corner at the origin.

Raises:

NotImplementedError – If the subclass does not provide one.

build_lid(spec: BoxSpec, decoration: object = None) → Bosl2Solid | None[source]

Build the lid geometry, in its seated position.

Parameters:
spec: BoxSpec

The box’s resolved description.

decoration: object = None

Unused by the geometry — decoration is applied by the exporter, once per colour mode.

Returns:

The lid solid, or None for a lidless type.

cut_fingernail_catch(lid: Bosl2Solid, spec: BoxSpec) → Bosl2Solid[source]

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

A seated sliding lid is a plate flush with the box’s top: its only exposed surfaces are an end face one lid thickness tall and a smooth top, so there is nothing to grip. The dish is what gets it moving. A lid that lifts off has its own way open and takes no dish.

Parameters:
lid: Bosl2Solid

The lid to cut.

spec: BoxSpec

The box’s resolved description.

Returns:

The lid, dished — or unchanged for a non-sliding type, a box that declines a catch, or a lid too small to carry one.

exterior_protrusions(spec: BoxSpec | UnresolvedBoxSpec) → tuple[float, float, float, float, float, float][source]

Return (neg_x, pos_x, neg_y, pos_y, neg_z, pos_z) protruding beyond [0..W, 0..L, 0..H].

Used by the container packer so features that intentionally stand proud of the nominal body — drawer handles, dispenser landing trays, or external stacking skirts — reserve clearance inside the game box.

interior(spec: BoxSpec) → Interior[source]

Return the volume inside this box.

Parameters:
spec: BoxSpec

The box’s resolved description.

Returns:

The interior frame. The default is the spec’s own — walls on four sides, floor below, lid above — which types that shorten the body for their lid override.

interior_mask(spec: BoxSpec) → Bosl2Solid | None[source]

Return the volume inside the box that contents may actually occupy.

Usually the whole interior, and a type only says otherwise when something of its own stands in there. A hinge box is the case that needs it: keeping the hinge inside the box’s outline puts the barrel and its leaf webs in the back of the interior, exactly where a compartment would go (FR-002s).

Parameters:
spec: BoxSpec

The box’s resolved description.

Returns:

A solid the contents must stay within, or None when the whole interior is available.

lid_keepouts(spec: BoxSpec) → list[tuple[float, float, float]][source]

Return circles on the lid that decoration must leave solid.

A type declares these when its lid carries a feature of its own that a pattern would otherwise cut into — a sliding lid’s fingernail dish is the case (FR-002e5): it is a thinned spot that gets pulled on, so it needs whole material around it to pull against. Corner stacking pads are likewise kept solid so through-hole lid patterns do not undercut the 4 corner locator pyramids/indents.

Parameters:
spec: BoxSpec

The box’s resolved description.

Returns:

(x, y, radius) in the lid’s own frame; empty when the type’s lid is a plain plate.

lid_rounded_edges(spec: BoxSpec) → list[Anchor][source]

Which of this box type’s lid edges may be rounded.

Parameters:
spec: BoxSpec

The box’s resolved description.

Returns:

A pybosl2 edges= selector. The default — four vertical corners and the top face — suits a lid that sits on top of the box, where all of that is on the outside. A lid that slides into the box overrides it (FR-044i).

outer_size_for_interior(spec: BoxSpec | UnresolvedBoxSpec, inner_w: float, inner_l: float, inner_h: float) → tuple[float, float, float][source]

Return the outer (width, length, height) needed to enclose an interior.

The inverse of interior(), used when deriving a box’s minimum envelope from its compartments so types with sleeves, clamshell halves, or no lid are sized accurately rather than assuming 2 * wall and a standard lid plate.

preferred_scoop_side(spec: BoxSpec) → ScoopSide | None[source]

Which wall this box type wants a finger scoop in.

A hook rather than a rule, because only the type knows: on a sliding box the cut has to be in the wall the lid leaves by — the other three carry the lid, two of them holding the grooves it rides in (FR-069).

Parameters:
spec: BoxSpec

The box’s resolved description.

Returns:

A ScoopSide, or None for “no preference”, which leaves the compartment’s own shape to decide.

slide_axis(spec: BoxSpec) → str | None[source]

Return which axis this type’s lid slides along, if it slides at all.

Parameters:
spec: BoxSpec

The box’s resolved description.

Returns:

"x" or "y", or None for a lid that lifts off rather than sliding. Everything that follows from sliding — the fingernail catch below — asks this rather than each type answering it again.

wall_tops(spec: BoxSpec) → dict[ScoopSide, float][source]

Return the sides whose walls do not end at this box’s default top.

Parameters:
spec: BoxSpec

The box’s resolved description.

Returns:

{ScoopSide: z} for the sides this type raises or lowers; empty when all four end level (FR-070/FR-071).