Metadata-Version: 2.4
Name: pyboxbuilder
Version: 0.2.0
Summary: Declarative 3D board game box and insert design library for PythonSCAD
Author: pinkfish
Maintainer: pinkfish
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/pinkfish/pythonscad_boxes
Project-URL: Documentation, https://pinkfish.github.io/pythonscad_boxes/stable/
Project-URL: Repository, https://github.com/pinkfish/pythonscad_boxes
Project-URL: Changelog, https://github.com/pinkfish/pythonscad_boxes/releases
Project-URL: Issues, https://github.com/pinkfish/pythonscad_boxes/issues
Keywords: 3d,3d-printing,board-games,board-game-inserts,organizer,openscad,pythonscad,pybosl2,cad,3mf
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Manufacturing
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Games/Entertainment :: Board Games
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
Classifier: Topic :: Scientific/Engineering
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pybosl2>=0.8.0
Requires-Dist: numpy
Provides-Extra: pdf
Requires-Dist: fpdf2; extra == "pdf"
Requires-Dist: pillow; extra == "pdf"
Provides-Extra: all
Requires-Dist: pythonscad>=1.2.0; extra == "all"
Requires-Dist: fpdf2; extra == "all"
Requires-Dist: pillow; extra == "all"
Requires-Dist: shapely; extra == "all"
Provides-Extra: scripts
Requires-Dist: pybosl2>=0.8.0; extra == "scripts"
Requires-Dist: lark; extra == "scripts"
Requires-Dist: fpdf2; extra == "scripts"
Requires-Dist: inkex; extra == "scripts"
Requires-Dist: numpy; extra == "scripts"
Requires-Dist: shapely; extra == "scripts"
Requires-Dist: svgelements; extra == "scripts"
Requires-Dist: simplepath; extra == "scripts"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-xdist; extra == "dev"
Requires-Dist: pytest-cov>=5; extra == "dev"
Requires-Dist: diff-cover; extra == "dev"
Requires-Dist: mypy==2.4.1; extra == "dev"
Requires-Dist: ruff==0.17.6; extra == "dev"
Requires-Dist: fpdf2; extra == "dev"
Requires-Dist: pillow; extra == "dev"
Requires-Dist: shapely; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx<9,>=7; extra == "docs"
Requires-Dist: sphinx-immaterial>=0.13; extra == "docs"
Requires-Dist: shapely; extra == "docs"
Dynamic: license-file

# pyboxbuilder

[![PyPI version](https://img.shields.io/pypi/v/pyboxbuilder.svg)](https://pypi.org/project/pyboxbuilder/)
[![Python versions](https://img.shields.io/pypi/pyversions/pyboxbuilder.svg)](https://pypi.org/project/pyboxbuilder/)
[![License](https://img.shields.io/pypi/l/pyboxbuilder.svg)](https://github.com/pinkfish/pythonscad_boxes/blob/main/LICENSE)
[![Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://pinkfish.github.io/pythonscad_boxes/stable/)

Declarative 3D board game box and insert design library for
[PythonSCAD](https://pythonscad.org/) and [`pybosl2`](https://pypi.org/project/pybosl2/).

`pyboxbuilder` turns a high-level description of what goes inside a board game
box — outer dimensions, non-printed boards, component inventory, sub-boxes, and
compartments — into printable multi-material 3MF/STL geometry and a color-coded
3D packing guide PDF.

The library's governing principle is **good defaults, not options**: describe
the storage you want and get printable files without tuning geometry you did not
ask about.

## Features

- **22 Box Types** — sliding lid, friction-fit cap, slipover, inset, snap-fit,
  threaded, bayonet, magnetic, print-in-place & filament hinges, clamshell,
  card shoe/library, dispenser, dice tray, sleeve drawer, modular interlock, and
  no-lid trays — each with matched body/lid mating geometry.
- **Smart Compartments & Finger Access** — absolute or proportional layouts,
  circular/hex/SVG-silhouette wells, smooth curved finger scoops, rolled wall
  holes, and automatic neighbor clearance.
- **3D Auto-Packing, Gap Absorption & Partial Boards** — auto-packs sub-boxes
  inside the game box, avoids non-printed `GameBoard` regions (folded boards,
  player screens, playmats), absorbs small vertical gaps (`<= 10 mm`) into box
  height, and fills remaining voids with hollow spacer trays.
- **Component Inventories & Packing Guide PDFs** — declare the game's piece
  inventory (`project.define_inventory(...)`) to verify 100% allocation across
  boxes, boards, and spacers, and generate a two-column color-coded packing
  guide PDF with a Box Summary, Master Component Checklist, and exploded 3D
  layer diagrams.
- **Thematic Lid Decoration** — auto-sized plaques, finials, SVG icons, custom
  fonts, cut-through patterns (hex, grid, Voronoi, Ammann-Beenker, tilings), and
  multi-color accent layers.
- **Export & Caching** — multi-color and single-color 3MF/STL export with
  content-based fingerprinting so unchanged parts are never rebuilt.

## Installation

Requires Python 3.11+ and [PythonSCAD](https://pythonscad.org/) (`pythonscad>=1.2.0`)
for 3D geometry export (layout and packing logic run in pure Python).

```sh
# Core library
pip install pyboxbuilder

# With packing guide PDF support (fpdf2 + Pillow)
pip install "pyboxbuilder[pdf]"

# Everything (PythonSCAD + PDF + Shapely)
pip install "pyboxbuilder[all]"
```

## Quick Example

```python
from pyboxbuilder import BoxType, Color, LabelMode, LidBuilder, Project

project = Project("CardGame", game_box_size=(200, 150, 90))
actions = project.define_cards("Action Cards", count=120, size=(63.5, 88.0), thickness=0.6)
tokens = project.define_piece("Victory Tokens", count=40, diameter=20.0, thickness=2.0, bulk=True)

cards_box = project.box(
    BoxType.SLIDING,
    "Cards",
    size=(70, 100, None),  # height follows from 120 × 0.6 mm cards
    lid=LidBuilder(
        label_mode=LabelMode.FRAMED,
        frame_color=Color("gold"),
    ).titled("Cards"),
)
cards_box.store(actions)

tokens_box = project.box(BoxType.CAP, "Tokens", size=(80, 70, 30))
tokens_box.store(tokens)

project.verify_inventory(strict=True)
project.export("output/")
```

Browse 39 complete board game inserts in the
[example catalog](https://github.com/pinkfish/pythonscad_boxes/tree/main/boxes)
and the [Quickstart guide](https://pinkfish.github.io/pythonscad_boxes/stable/quickstart.html).

## Documentation

- **Stable docs** — https://pinkfish.github.io/pythonscad_boxes/stable/
- **Dev docs** — https://pinkfish.github.io/pythonscad_boxes/dev/
- **Release notes** — https://github.com/pinkfish/pythonscad_boxes/releases

## Development

```sh
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pre-commit install

# Quality checks (blocking in CI)
ruff check pyboxbuilder/ boxes/
mypy pyboxbuilder/
PYTHONPATH=".:tests" pytest tests/test_pyboxbuilder/ --base-only --ignore=tests/test_pyboxbuilder/render -k "not export" -n auto -q
```

## License

[Apache-2.0](https://github.com/pinkfish/pythonscad_boxes/blob/main/LICENSE)
