Metadata-Version: 2.5
Name: cadbuildr-flatpack
Version: 0.1.0
Summary: Laser-cut and CNC-routed sheet construction: panels, kerf-compensated joints, box generators, flat DXF/SVG export with nesting
Author: CADbuildr Team
License-File: LICENSE
Requires-Python: <4.0.0,>=3.10.0
Requires-Dist: cadbuildr-foundation<0.4.0,>=0.3.0
Requires-Dist: cadbuildr-stdlib>=0.4.0
Requires-Dist: numpy<3.0.0,>=2.2.6
Description-Content-Type: text/markdown

# cadbuildr-flatpack

## Summary

Laser-cut and CNC-routed sheet construction: panels cut from a sheet + machine profile, joints
that cut both panels (finger, slot-and-tab, cross halving, T-slot bolts with stdlib hardware,
living hinge), box / enclosure / grid generators, nested DXF / SVG export and cut validation.

## Tags

cad, python, library, laser-cutting, cnc, flat-pack, plywood, dxf, svg, nesting

## Status

yellow — P0 content shipped (panels, 6 joints, 4 generators, export, validation)

## Guidelines

- Every feature reads the panel's `Sheet` (measured thickness) and `Machine` (kerf, bit, clearance).
- Joints place panels with anchors + `RigidJoint` and cut both panels; never `translate`.
- 3D cuts and the 2D cut model come from the same edge features (3D == exported DXF).
- Fail loudly with named errors (`FitError`, `CornerConflict`, `TSlotError`...).
- Standard hardware comes from stdlib and connects by interface (`ScrewHole`, `NutSeat`).

## Dependencies

### Upstream

- `cadbuildr-foundation` (library configurables, anchors / joints, interfaces)
- `cadbuildr-stdlib` (DIN 912 screws, DIN 934 nuts for T-slot joints)
- `numpy`

### Downstream

- Prototype app demo videos (finger box, T-slot enclosure, egg crate)

## Usage

```python
from cadbuildr.foundation import show
from cadbuildr.flatpack import FingerBox, nest, to_dxf, to_svg, sheet_report, check_flatpack

box = FingerBox(length=240, width=160, height=110, sheet="Plywood 6 mm", thickness=5.8)
assert check_flatpack(box) == []          # webs, relief, fit, interface check
sheets = nest(box)                         # shelf-packed onto 600 x 400 sheets
open("box.dxf", "w").write(to_dxf(sheets)) # CUT / ENGRAVE / SHEET layers, kerf compensated
print(sheet_report(sheets))
show(box)
```

| Item | Kind | What it does |
|---|---|---|
| `Panel` | part | One flat part: `width`, `height`, `sheet`, measured `thickness`, `machine`, `label`; anchors `origin`, `face_out`, `face_in`, `edge_s/e/n/w` |
| `finger_joint` | operation | Finger corner between two equal edges, odd count, kerf / clearance / relief aware |
| `slot_and_tab` | operation | Tabs on one panel's edge through slots in another (T joint) |
| `cross_halving` | operation | Egg-crate crossing, slotted halfway from opposite edges |
| `tslot_joint` | operation | Butt joint + DIN 912 screws into T-slots with captive DIN 934 nuts (connected by interface) |
| `butt_joint` | operation | Plain butt (glue / brads), no cuts |
| `living_hinge` | operation | Kerf-bending lines across a band: straight, lattice (thirds) or zigzag |
| `FingerBox` | assembly | Open / closed / lift-off-lid finger-jointed box |
| `TSlotEnclosure` | assembly | Six-panel bolted case, walls inset so holes keep a web |
| `EggCrate` | assembly | Grid of cross-halving ribs |
| `HingeSample` | assembly | Living-hinge test coupon / sleeve |
| `ShapedPanel` | part | Any straight-sided outline (`"x,y x,y ..."`), edges `e0`, `e1`... take every joint |
| `KerfCoupon` | part | Comb of test slots (thickness + clearance) and a square kerf gauge, cut as drawn |
| `stack_joint` | operation | Lay one panel flat on another's face (laminates, lid plates, drawer fronts) |
| `dovetail_splice` | operation | Coplanar dovetail (puzzle) joint: parts longer than the bed |
| `DrawerUnit` | assembly | Open-front carcass + finger-jointed drawer + overlay front with pull hole |
| `PhoneStand` | assembly | Two shaped (mirrored) sides + two tabbed cross bars |

Outputs: `flatten`, `nest`, `to_svg`, `to_dxf`, `sheet_report` (incl. cut time + cost), `bom_rows`, `cut_time`.
Validation: `check_flatpack` (web, relief, fit, nut, plus `Assembly.check()`), `overlap_samples`.

```bash
python -m cadbuildr.foundation.library manifest cadbuildr.flatpack
uv run --frozen --no-sync python -m pytest packages/cadbuildr/flatpack -q
```

Conventions: a panel lies on `x = 0..width`, `y = 0..height`, `z = 0..t`; `z = 0` is the
outer face. Edges run counter-clockwise (`s`, `e`, `n`, `w`). Positions along an edge are
panel coordinates (x for `s`/`n`, y for `e`/`w`).
