Metadata-Version: 2.5
Name: cadbuildr-gridfinity
Version: 0.2.0
Summary: The Gridfinity modular storage system on CADbuildr: bins, baseplates (plain/magnet/weighted/screw, fit to a drawer), hex-bit / hole / cut-out inserts and lids, placed by connect
Project-URL: Homepage, https://github.com/cadbuildr/gridfinity
Author: CADbuildr Team
License-Expression: MIT
License-File: LICENSE
Requires-Python: <4.0.0,>=3.10.0
Requires-Dist: cadbuildr-foundation<0.4.0,>=0.3.0
Description-Content-Type: text/markdown

# cadbuildr-gridfinity

## Summary

The [Gridfinity](https://gridfinity.xyz/specification/) modular storage
system (Zack Freedman, 2022) as a CADbuildr library
(`pip install cadbuildr-gridfinity`, `import cadbuildr.gridfinity`): parametric
bins, baseplates for any drawer, tool-holder inserts and lids, all typed
`@part` / `@assembly` library items that stand on each other through a
`GridfinityFoot` / `GridfinitySocket` interface pair and `connect`.

Dimensions follow the community reference
[Gridfinity Rebuilt](https://github.com/kennetek/gridfinity-rebuilt-openscad)
(kennetek, MIT), modelled here from its published numbers (no code copied):
42 mm grid, 7 mm height unit, bin outer `42 n - 0.5` mm (0.25 mm clearance),
base profile 0.8 mm 45° / 1.8 mm vertical / 2.15 mm 45° (4.75 mm) plus a
2.25 mm bridge, baseplate pocket 0.7 / 1.8 / 2.15 mm on a 0.35 mm straight,
stacking lip 0.7 / 1.8 / 1.9 mm, Ø6.5 × 2.4 mm magnet holes and Ø3 mm M3
screw holes 8 mm from the cell edges. Every number, with its source, is in
[`cadbuildr/gridfinity/spec.py`](cadbuildr/gridfinity/spec.py).

A [Vite + React-Three-Fiber generator](github-io/) renders bins and
baseplates live in the browser through the CADbuildr SDK.

![A stocked desk organiser](docs/images/organiser.png)

## Quickstart

```bash
pip install cadbuildr-gridfinity      # pulls cadbuildr-foundation>=0.3.0,<0.4.0
```

```python
from cadbuildr.foundation import Assembly, show
from cadbuildr.gridfinity import (
    GridfinityBin, GridfinityDrawerBaseplate, GridfinityHexBitInsert, place_bin,
)

plate = GridfinityDrawerBaseplate(drawer_width=180, drawer_depth=130, style="magnet")  # 4 x 3, 6 / 2 mm padding
drawer = Assembly()
drawer.ground(plate)
place_bin(drawer, GridfinityBin(units_x=2, units_y=2, units_z=6, dividers_x=1), plate, 0, 0)
place_bin(drawer, GridfinityHexBitInsert(), plate, 2, 0)   # checked: on the plate, cells free, same pitch
assert [i for i in drawer.check() if i["severity"] == "error"] == []
show(drawer)
```

Or the ready-made demo (a 4 × 3 drawer with a mix of bins, inserts and a
stacked lid): `python examples/demo_drawer.py`, or in
[CADbuildr Prototype](https://cadbuildr.com/downloads) open the folder and
press Play on `examples/demo_drawer.py`.

```bash
python -m cadbuildr.foundation.library manifest cadbuildr.gridfinity
echo '{"item": "gridfinity:GridfinityBin", "inputs": {"units_x": 3, "dividers_x": 2}}' \
  | python -m cadbuildr.foundation.library eval
```

## Catalogue

| Item | What it is | Key inputs |
|---|---|---|
| `GridfinityBin` | Open bin: a foot per cell, walls, open stacking lip, dividers, a finger scoop and an angled label tab (GR 15.85 mm / 36°) per row, magnet and screw holes, vase-mode (solid) variant, 21 mm half grid | `units_x/y/z`, `dividers_x/y`, `label` (none/full/left/center/right), `scoop`, `stacking_lip`, `magnets`, `screws`, `holes_only_corners`, `wall`, `vase_mode`, `half_pitch` |
| `GridfinityBlock` | Solid bin (riser / spacer / blank), optional lip recess on top | `units_x/y/z`, `stacking_lip`, `magnets`, `screws` |
| `GridfinityBaseplate` | Pockets to the GR baseplate profile; styles `plain` (5 mm frame), `magnet` (3.4 mm floor), `weighted` (6.4 mm floor, 21.4 mm weight pockets + ribs), `screw` (6.75 mm floor, Ø3.35 mm cross holes) | `units_x/y`, `style`, `half_pitch`, `pad_*` |
| `GridfinityDrawerBaseplate` | Fills a drawer: `floor(W/42)` × `floor(D/42)` cells, padding split by `fit_x/y` (−1 / 0 / +1) | `drawer_width`, `drawer_depth`, `style`, `fit_x/y` |
| `GridfinityHexBitInsert` | Grid of hex sockets for ISO 1173 bits (1/4 in = 6.35 mm, or 4 mm) | `bit`, `depth`, `clearance`, `columns`, `rows` |
| `GridfinityHoleInsert` | Round holes of any diameters, packed in rows | `diameters` ("6, 8, 10"), `depth`, `clearance` |
| `GridfinityCutoutInsert` | Shadow-board pocket from a 2D outline | `outline` ("x,y; x,y; ..."), `depth` |
| `GridfinityLid` | Feet that seat in a bin's lip under a plate; `stackable` adds a baseplate frame on top | `units_x/y`, `stackable` |
| `GridfinityDrawer` | Drawer baseplate + items from a layout string (`"bin 2x2x6@0,0; hexbit 1x1x3@2,0"`) | `drawer_width/depth`, `style`, `layout` |
| `GridfinityDemoDrawer` | The 4 × 3 demo drawer | `style` |

Helpers: `place_bin`, `stack_on`, `parse_layout`, `tile_layout` (split a big
plate into printable tiles), `drawer_fit`, and `spec` (dimensions, profile
cross-sections, seat offsets, analytic volumes). `GridfinityBox` is an alias
of `GridfinityBin` (the cq-gridfinity name).

Interfaces: `GridfinitySocket` (female, +Z up) at every pocket floor
(`cell_<i>_<j>`, `i` along +X, `j` along +Y from the corner cell), on top of
every bin with a lip (`stack_<i>_<j>`, 0.35 mm below the body top where a
stacked base comes to rest) and on stackable lids; `GridfinityFoot` (male,
+Z down) under every bin's first cell (`foot`). The mate rule is rigid and
requires the same pitch.

## Tags

cad, python, library, gridfinity, storage, organizer, 3d-printing, parametric, open-source

## Status

yellow

## Guidelines

- Every dimension comes from `spec.py`, which cites Zack Freedman's spec or
  Gridfinity Rebuilt per constant; values the sources do not give are
  listed under *Estimated* there and in the docstrings. Model from the
  published numbers; never copy the reference's code.
- Bins stand on plates by `connect` (`place_bin` / `stack_on`), never by
  coordinates.
- Bad inputs raise a named `GridfinityError` subclass (`GridSizeError`,
  `OptionConflictError`, `FitError`, `OutlineError`, `LayoutError`), never a
  silent clamp. Findings that are not errors (thin walls, oversize plates)
  are issues from a `__checks__` hook; never override `check()`.
- Geometry tests check boxes, profiles and analytic volumes without a
  kernel; with `CADBUILDR_KERNEL_API_BASE_URL` set they also mesh the real
  solids and compare volumes.
- Keep `github-io/` working when the API moves (`buildPythonSource` in
  `github-io/src/main.tsx`), and rebuild the wheel it serves
  (`pnpm run sync-starter-wheel`).

## Dependencies

### Upstream

- `cadbuildr-foundation>=0.3.0,<0.4.0` (parts, library registry,
  interfaces and `connect`, `__checks__`)

### Downstream

- The [Gridfinity Generator](github-io/) site (Pyodide wheel in
  `github-io/public/local-starter/`)
- CADbuildr cloud / Prototype library catalogue (entry point
  `cadbuildr.libraries: gridfinity`)

## Develop

```bash
uv venv && uv pip install -e . pytest
uv run pytest -q                                   # analytic + operation-level geometry
CADBUILDR_KERNEL_API_BASE_URL=http://localhost:8087 uv run pytest -q   # + real solids
```

`eval/iou_eval.py` compares the base against an OpenSCAD render of Gridfinity
Rebuilt (needs OpenSCAD and a checkout of the reference).

## Deploy the GitHub Pages generator (optional)

The site uses the [CADbuildr SDK browser flow](https://docs.cadbuildr.com/sdk/auth)
— a short-lived session token is minted client-side using only the
**publishable half** of a partner key. See [`github-io/README.md`](github-io/README.md).

## License

MIT (see `LICENSE`). Gridfinity is Zack Freedman's open design; Gridfinity
Rebuilt is © kennetek, MIT.
