pyboxbuilder.compartments.element

Compartment elements — individual game components nested inside a compartment.

A CompartmentElement is one physical piece (a worker meeple, a hero standee, a hex tile, a wooden marker) with its own silhouette, its own local (x, y) offset inside the owning compartment, its own rotation and its own depth. A compartment that carries elements is an element pack: the elements are positioned in a local frame and the pack’s bounding box is what the box-level layout engine sees, so the pack behaves exactly like one ordinary rectangular compartment (FR-004b).

Geometry generation delegates to pybosl2 and is only imported when a cutout is actually built, so the layout maths stays importable without PythonSCAD.

Classes

CompartmentElement

A physical game component nested inside a compartment's bounding box.

Functions

build_element

Build the cutout solid for one element, in the compartment's local frame.

build_element_pack

Union every element cutout in a pack.

build_element_pack_inserts

Build the coloured positive inserts of a pack, one per coloured element.

build_element_pack_pull_outs

Union every pull-out scoop in a pack, using area cutouts for thick groups and deep bays for thin tokens.

build_pull_out

Return the finger dish that lets a piece be lifted out of its slot.

centered

Return a CompartmentElement centered at the given coordinate.

centered_in_box

Return a CompartmentElement centered exactly in a box's interior frame.

distribute_2d_bounds

Compute per-box (dx, dy) shifts distributing disjoint bands across width x length.

distribute_linear_gap

Return (outer_margin, inner_gap) along one axis, or None if tight.

elements_bounding_box

Return (min_x, min_y, max_x, max_y) covering every element in the pack.

elements_footprint

Size of the rectangular compartment that holds this element pack (FR-004b).

elements_overlap

Return the pairs of elements whose bounding boxes intersect.

grid_pack

Repeat one element count times along a straight line (FR-004b).

normalize_elements

Shift a pack so its bounding box starts at (margin, margin).

pack_elements

Auto-pack loose CompartmentElement items into a compact 2D element pack.

pack_into_compartment

Auto-lay out elements inside a fixed-size compartment interior.

svg_solid

Extrude an SVG outline and scale it to fill width x length x depth.

union_all

Union a list of solids with a balanced fold.