pyboxbuilder.project.piece.Piece¶
-
class pyboxbuilder.project.piece.Piece(label: str, kind: str, size: tuple[float, float, float], position: tuple[float, float, float], _build: collections.abc.Callable[[], Any | None], builder: BoxBuilder | None =
None, _build_inserts: collections.abc.Callable[[], list[tuple[Any, Any]]] | None =None, rotation: bool =False)[source]¶ Bases:
objectOne printable piece of a project.
Both
show()andexport()consume these, so a piece previewed and the same piece printed are the same solid.The geometry is built on demand. Everything that identifies a piece — its label, its size, where it sits, and the description it would be built from — is known without building it, and that is what decides whether an export needs to write it at all (FR-031). Building eagerly meant a re-export with nothing changed still paid for every box: 15 of Emberleaf’s 21 seconds at draft precision, and minutes at the 256 facets an export actually uses, all spent on geometry the fingerprint was about to discard.
- property inserts : list[tuple[Any, Any]]¶
The piece’s coloured positive inserts, in its own local frame.
A lid’s label and frame are inserts; a body can carry icons at the bottom of its wells. Each entry is
(solid, colour). Empty when the piece has none.
- property packed_size : tuple[float, float, float]¶
Dimensions occupied inside the container frame after any 90° Z rotation.