Laser and CNC sheet parts (flatpack)
Design boxes, enclosures and grids cut flat from plywood, MDF or acrylic and
slotted or bolted together. Every joint is cut for the sheet’s measured
thickness and your machine’s kerf, bit and clearance, and the same cuts are
exported as a nested DXF or SVG for the cutter. This is the
cadbuildr-flatpack library, built on Foundation.
Prerequisites: pip install cadbuildr-flatpack (it installs
cadbuildr-foundation and cadbuildr-stdlib).
Make a finger-jointed box
from cadbuildr.foundation import show
from cadbuildr.flatpack import FingerBox, check_flatpack
box = FingerBox(length=240, width=160, height=110, sheet="Plywood 6 mm", top="closed")
print(check_flatpack(box)) # [] when every joint can be cut and fits
show(box)FingerBox is an Assembly of Panel parts (box.panels). The bottom is
fixed; every other panel is placed by the finger joint that cuts it, and the
joints that close the box are checked by Foundation.
Sheet and machine
Two inputs drive every cut:
| Input | What it sets | Examples |
|---|---|---|
sheet | material, nominal and measured thickness, sheet size, minimum web | "Plywood 3 mm", "MDF 6 mm", "Acrylic 3 mm" |
thickness | your caliper reading (0 keeps the table’s measured value) | 5.8 |
machine | kerf, router bit, corner relief, default clearance | "Laser CO2", "Laser CO2 press fit", "CNC 6 mm bit dogbone" |
Change thickness and every notch is re-cut to the new depth. Pick a CNC
machine and every inside corner gets a dogbone (or T-bone) so a round bit can
cut it.
Join panels yourself
from cadbuildr.foundation import Assembly, show
from cadbuildr.flatpack import Panel, finger_joint, slot_and_tab
shelf = Assembly()
base = Panel(300, 200, label="base")
divider = Panel(200, 80, label="divider")
side = Panel(200, 80, label="side")
shelf.ground(base)
slot_and_tab(shelf, divider, "s", base, at=150, along="y", tabs=3)
finger_joint(shelf, side, "s", base, "w")
show(shelf)A panel lies on x = 0..width, y = 0..height; z = 0 is its outer face.
Edges are named s (bottom), e (right), n (top), w (left).
| Joint | Use |
|---|---|
finger_joint | box corners, outer faces flush |
slot_and_tab | a panel standing on another (shelves, dividers) |
cross_halving | egg-crate grids |
tslot_joint | bolted butt joint with stdlib M3/M4 screws and captive nuts |
butt_joint | glued butt joint, no cuts |
living_hinge | a band of kerf-bending lines so the panel flexes |
Bolted enclosure
from cadbuildr.flatpack import TSlotEnclosure
case = TSlotEnclosure(length=180, width=120, height=70, size="M3", bolts=2)
print(case.check()) # screws and nuts connect by interface: [] when they fitEach of the 12 joints holds two DIN 912 socket screws and DIN 934 nuts from
cadbuildr-stdlib. The walls sit slightly in from the panel edges so every
screw hole keeps enough material around it.
Export for the cutter
from cadbuildr.flatpack import nest, to_dxf, to_svg, sheet_report, bom_rows
sheets = nest(box) # packed onto stock sheets
open("box.dxf", "w").write(to_dxf(sheets)) # layers CUT, ENGRAVE, SHEET (mm)
open("box.svg", "w").write(to_svg(sheets)) # red cut, blue engrave
print(sheet_report(sheets)) # sheets, utilisation, cut length, weight
print(bom_rows(sheets)) # what to buyLaser exports are offset by half the kerf, so the parts come out at their nominal size. Router exports stay nominal (your CAM offsets the tool).
Check before you cut
check_flatpack(obj) lists problems as {severity, code, panel, message, fix}:
web: material thinner than the sheet’s minimum web (fingers too narrow, a hole too close to an edge);relief: an inside corner too small for the router bit;fit: a press fit tighter than the material takes;nut: (info) the nut is wider than the sheet and shows on both faces.
Impossible requests fail straight away with a named error that says what to
change, for example TSlotError: M3x8 is too short ... use length >= 12.