pyboxbuilder.compartments.element.CompartmentElement

class pyboxbuilder.compartments.element.CompartmentElement(shape_file: str | None = None, offset: tuple[float, float] = (0.0, 0.0), rotation: float = 0.0, size: tuple[float, float] | None = None, shape: ElementShape = ElementShape.SVG, depth: float | None = None, z_offset: float | None = None, corner_radius: float = 2.0, corner_rounding: float = 0.5, bottom_rounding: float = 0.0, label: str | None = None, pull_out: bool = True, pull_out_depth: float | None = None, pull_out_width: float | None = None, color: str | None = None, count: int | None = None, component: str | None = None)[source]

Bases: object

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

bounds() → tuple[float, float, float, float][source]

Axis-aligned bounds (min_x, min_y, max_x, max_y) in the pack frame.

translated(dx: float, dy: float) → CompartmentElement[source]

Return a copy shifted by (dx, dy) in the pack frame.

property base_footprint : tuple[float, float]

Axis-aligned (width, length) of the silhouette before rotation.

For most shapes this is just size. A hexagon is the exception: size[0] is its flat-to-flat width, exactly as RegularPolygon(width=…) reads it in the original toolkit, so it measures width / cos(30°) point-to-point across the other axis.

bottom_rounding : float = 0.0

Bottom corner fillet radius in mm.

color : str | None = None

When set, this element is a positive coloured insert — a thin icon pressed into the bottom of its well — instead of a cutout. The value is a web colour name, applied as the insert’s own material in mmu mode.

component : str | None = None

Optional declared inventory component name allocated by this element well.

corner_radius : float = 2.0

Corner radius for ElementShape.ROUNDED_RECT.

corner_rounding : float = 0.5

Corner rounding radius for ElementShape.RECT (default 0.5mm, 0 for sharp).

count : int | None = None

Optional explicit count of game pieces stored in this element well. None counts as 1 for piece wells (and 0 for helper finger-bite / grab-shelf cutouts).

depth : float | None = None

Cutout depth in mm. None inherits the owning compartment’s depth.

property footprint : tuple[float, float]

Axis-aligned (width, length) after rotation is applied.

label : str | None = None

Optional identifier, handy for tests and layout diagnostics.

offset : tuple[float, float] = (0.0, 0.0)

2D offset (x, y) in mm of the element’s lower-left corner, relative to the compartment’s bottom-left origin.

pull_out : bool = True

Cut a finger pull-out over this slot so the piece can be lifted out.

A silhouette slot holds its piece snugly by design — that is the point of cutting to the outline — which also means there is nowhere to get a fingertip. The pull-out is a dish across the slot, curved in from the surrounding floor so a finger slides down it and under the piece.

pull_out_depth : float | None = None

How deep the pull-out dish goes below the slot’s own floor.

None takes half the piece’s depth, which is enough to get under a piece without letting it drop into the dish and sit crooked.

pull_out_width : float | None = None

Width of the pull-out across the slot. None uses a fingertip width.

rotation : float = 0.0

Rotation of the component in degrees, about the centre of its footprint.

shape : ElementShape = 'svg'

Silhouette kind. Defaults to SVG, which requires shape_file.

shape_file : str | None = None

Path to the SVG outline representing the component (ElementShape.SVG only).

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

Bounding dimensions (width, length) of the component in mm.

z_offset : float | None = None

Extra lift of the cutout floor above the compartment floor, in mm. If None, the pocket automatically aligns flush with the top of the box. Used for pieces that sit on top of other pieces (e.g. a tile over a token).