pyboxbuilder.compartments.element.pack_into_compartment

pyboxbuilder.compartments.element.pack_into_compartment(items: Sequence[CompartmentElement | Sequence[CompartmentElement]], compartment_size: tuple[float, float], *, spacing: float = 2.0, min_spacing: float = 1.5, margin: float | None = None, allow_rotate: bool = True, distribute: bool = True) → tuple[CompartmentElement, ...][source]

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

Preserves the compartment’s fixed dimensions (never altering the owning box’s size) while arranging piece slots with balanced margins, divider gaps and room for pull_out finger access.

Each entry in items may be either a standalone CompartmentElement or a sequence (primary, child1, ...) whose trailing child elements (e.g. floor inlays or stacked Z wells) stay centered on primary and rotate alongside it.