Estimate N identical units, nesting all units together so offcuts carry across
units → realistic per-unit cost.
- build_cut_plan(quantity=N) / best_cut_plan(quantity=N) replicate CutItems
(not Parts) with a `unit` field; reoptimize infers the batch size from the
base plan and preserves it.
- project_estimate(quantity=N): materials from the N-unit plan; setup labor once
per batch, per-op time + consumables ×N; reports per-unit cost & price.
- BOM window: "Build units" spinner in the header drives the active plan; layout
labels pieces by unit ("U2 left leg"); cost tab shows total + per-unit.
- tests: replication + units, offcut sharing across units, per-unit estimate.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sanding never shrinks the design model; instead the cut plan distinguishes the
rough size you cut from the final size you sand to.
- CutItem gains final_length_in/final_width_in (+ final_len/final_wid/
has_allowance helpers); length_in/width_in are the ROUGH cut size.
- _cut_items(scene, settings): a finished (finish != raw) board is cut oversize
by sanding_allowance_in on dimensions actually CUT — length always, width only
for sheet goods. Dimensional lumber's section width is the stock as delivered,
not padded (Rob's point). note gains "sand to final".
- ShopSettings.sanding_allowance_in default 1/32"; serialization additive.
- BOM cut list shows "Cut … → final …" and a sanding-allowance footnote.
- tests: raw = no allowance, sanded lumber pads length only, plywood pads width
too, allowance roundtrips in plan JSON.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codex findings:
1. reoptimize sent unlocked plywood to fresh sheets whenever any sheet
placement was locked, instead of packing into free space on the locked
sheet — so locking one of two panels that share a sheet split them onto
two sheets. Added _free_rects_sheet (guillotine subtraction carving free
rectangles around locked panels) + _pack_plywood_seeded, and refactored
_pack_plywood_guillotine onto a shared _guillotine_pack core that accepts
seeded sheets. reoptimize now uses it for the plywood branch.
2. "Best of 100" only tried the ~6 STRATEGIES when locks existed. The locked
path now runs strategies + shuffle restarts up to 100 attempts via
reoptimize, matching the label.
Tests: plywood lock keeps both panels on one sheet; locked Best-of-100 stays valid.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
reoptimize(scene, base_plan, strategy) preserves locked placements where they sit
and re-packs the unlocked items around them: unlocked lumber goes into the free
segments beside locked pieces (then new sticks) via _pack_lumber_seeded +
_free_segments; unlocked plywood goes onto fresh sheets (locked sheets keep their
locked panels). The BOM window's "Find better layout" / "Try alternative" now call
reoptimize when any piece is locked (Find better tries all strategies and keeps the
best), so locks survive re-optimization instead of just blocking drags.
Tests: locked placement keeps its id/position, nothing is lost, plan stays valid.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- One active CutPlan: the BOM window holds self._plan; Cut List, Shopping,
Instructions, and Cut Layout all render from it (no more "shopping says 3 sticks
while the optimized layout uses 2"). _set_plan/_refresh_all keep them in sync.
- Unplaced/oversize parts now appear in the Shopping list ("Won't fit standard
stock — source/cut specially"), not just a layout warning.
- Process-stable shuffle ordering via hashlib (built-in hash() is salted per run).
- Kerf-gap validation: placement_fits/validate now reject pieces closer than a
kerf (not just overlap beyond a kerf).
- Manual edits: drop checks stock-type compatibility (no 2x4 onto a plywood
sheet); waste regions + score recompute after every move/rotate/lock; rotation
respects allow_plywood_rotation/grain and validate flags illegal rotation.
- Jig specificity: holes/mortises grouped by face + position + size (not just
cutter size), so a registration template is only suggested when the position
actually repeats.
125 tests pass; verified offscreen that Shopping tracks the optimized plan and
unplaced parts surface. Phase 1 noted as partial in SHOP_PACKET_PLAN.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cutplan.py gains deterministic editing helpers: find_placement, placement_fits
(bounds + kerf-aware overlap), snap_x (snap to stock edges / neighbour ±kerf),
relocate (move a placement to a stock piece / position), rotate_placement.
The BOM Cut Layout tab is now editable: it holds a persistent CutPlan; pieces are
draggable (_Piece) — on drop they snap, validate, and either commit or revert with
a status message; you can drag a piece onto another stick/sheet to reassign it,
double-click a panel to rotate it, and right-click to lock (locked pieces can't be
dragged). "Find better layout" / "Try alternative" regenerate the auto plan.
119 tests pass (snap, fits/overlap, relocate-between-sticks, rotate). Window +
drag/rotate handlers verified offscreen; interactive drag/print needs a display.
Known follow-up: lock-aware re-optimization (locked pieces currently protect against
drags but aren't yet preserved across a fresh auto-layout).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Lumber packing supports first-fit (FFD) and best-fit (BFD, tightest fit) via
a `fit` mode; strategy "bestfit" selects it.
- Plywood panels now rotate to fit (when allowed and grain isn't honored);
placements record `rotated`. Rotation-disabled oversize panels are flagged.
- best_cut_plan() tries decreasing/bestfit/increasing + shuffle restarts and
keeps the best by (stock_count, waste_area, -reusable_offcuts); marks it
"optimized". STRATEGIES drives "Try alternative".
- BOM Cut Layout tab: "Find better layout" (optimize) + "Try alternative"
(cycle strategies) buttons; the score line explains the result.
107 tests pass (rotation fits/!fits, optimizer no-worse-than-baseline).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>