Woodworking and joinery
Model furniture the way it is built: buy stock by its name, join it with real
joints that cut the wood and place the parts, and get a cut list. This is the
cadbuildr-woodworking library, built on Foundation.
Prerequisites: pip install cadbuildr-woodworking (it installs
cadbuildr-foundation). Pocket screws use cadbuildr-stdlib for the screws.
Make a table
from cadbuildr.foundation import show
from cadbuildr.woodworking import TableFrame, cut_list, format_cut_list
table = TableFrame(length=1200, width=700, height=740)
print(format_cut_list(cut_list(table)))
show(table)# Qty Stock Material T W L Banding
1 1 Board - 25 760 1260 -
2 2 Board - 22 90 1137 -
3 4 Beam - 50 50 740 -
4 2 Board - 22 90 637 -Four legs, four aprons joined with mortise & tenon joints, and a top. The
fourth apron closes the loop back to the first leg, and the library checks
that it lands there: if the lengths don’t add up you get a ClosureError
instead of a gap.
Every project is configurable, with named presets:
| Project | Presets | Joints |
|---|---|---|
TableFrame(length, width, height, leg, apron_height, with_top) | Dining table, Coffee table, Side table, Stool | mortise & tenon |
Bookshelf(height, width, depth, shelves, thickness) | Tall bookcase, Low bookcase, Wall cubby | dados |
PictureFrame(outer_width, outer_height, moulding, depth) | A4 photo, Poster 50x70, Mirror | 45° miters |
FingerJointBox(length, width, height, thickness, fingers) | Keepsake box, Toolbox | box (finger) corners |
Stock
| Class | What it is |
|---|---|
Beam(width, height, length) | any rectangular section, length along +Z |
Board(width, thickness, length) | flat stock: top(), bottom(), edge() |
Lumber(size, length) | dimensional lumber by name: "2x4" is 38 × 89 mm, metric "45x95" |
Panel(width, length, thickness, material, edge_banding) | sheet goods: "18 mm", '3/4" ply', plywood, MDF, particleboard, OSB |
Dowel(diameter, length) | dowel pins, "6x30" to "12x60" |
A beam has two ends (beam.end("a") at z = 0, beam.end("b")) and four
long faces (beam.face("px" | "nx" | "py" | "ny")). A point on a face is
measured from an end: leg.face("px").at(650, from_="a").
Join parts with Joinery
Collect the joints, then build. The builder places every part from the grounded one, checks that no beam end is used twice, that two joints don’t cut the same wood, and that closed loops close.
from cadbuildr.foundation import show
from cadbuildr.woodworking import Board, DadoSpec, Joinery
left, right = Board(280, 18, 900), Board(280, 18, 900)
shelves = [Board(280, 18, 800 - 2 * 18 + 2 * 6) for _ in range(3)]
j = Joinery()
for shelf, height in zip(shelves, (60, 450, 870)):
j.dado(shelf.end("a"), left.face("py").at(height, from_="a"), DadoSpec(depth=6))
j.dado(shelf.end("b"), right.face("ny").at(height, from_="a"), DadoSpec(depth=6))
show(j.build(ground=left))| Joint | Method | Spec |
|---|---|---|
| Mortise & tenon | j.mortise_and_tenon(rail.end("b"), leg.face("px").at(650, from_="a")) | TenonSpec(width, thickness, length, shoulder, fit, through) |
| Dado (housing) | j.dado(shelf.end("a"), side.face("py").at(300, from_="a")) | DadoSpec(depth, fit) |
| Box (finger) corner | j.box_corner(a.end("b").inside("ny"), b.end("a").inside("ny")) | FingerSpec(count, fit) |
| Miter corner | j.miter(a.end("b").inside("ny"), b.end("a").inside("ny")) | MiterSpec(fit) |
Corners need .inside(face): which face of each board faces the inside of
the corner.
One-line joints
For a single joint between two parts, the one-liners cut and place in one
call: mortise_and_tenon, dado_joint, rabbet_joint, cross_lap,
end_lap, butt_joint, doweled_butt, mitered_butt, box_joint,
through_dovetail, sliding_dovetail, edge_joint, tongue_and_groove.
from cadbuildr.foundation import Assembly, show
from cadbuildr.woodworking import Beam, mortise_and_tenon
leg, rail = Beam(45, 45, 400), Beam(45, 45, 260)
assembly = Assembly()
assembly.add_component(leg)
mortise_and_tenon(assembly, rail, leg, face="px", at=280)
show(assembly)They cannot close loops. Use Joinery for anything with two or more joints.
Screws
screwed_overlap(assembly, slat, rail, ...)fastens a board flat on a rail with countersunk screws: decks, fences, slatted chairs.pocket_screw(assembly, rail, stile, face="px", at=300, end="a", screw_factory=...)butts a board’s end against another and drives angled screws from pockets in its hidden face: face frames and cabinets.pocket_screw_length(thickness)gives the usual screw length.
from cadbuildr.stdlib.fasteners import WoodScrew
from cadbuildr.woodworking import Board, pocket_screw, pocket_screw_length
from cadbuildr.foundation import Assembly, show
stile, rail = Board(50, 19, 600), Board(50, 19, 300)
assembly = Assembly()
assembly.add_component(stile)
pocket_screw(assembly, rail, stile, face="px", at=300, end="a",
screw_factory=lambda: WoodScrew("8", pocket_screw_length(19)))
show(assembly)Cut list and stock
cut_list(assembly) groups every piece of stock into rows of identical
pieces: section, length, material and edge banding for panels. Lengths are
the rough stock, tenons included.
optimize_lengths(rows, stock_length=2400, kerf=3, section=(50, 50)) packs
the pieces of one section onto stock boards and tells you how many to buy.
For the table above it fits the four 740 mm legs on two 2.4 m boards.
Errors
| Error | Fix |
|---|---|
JointCollisionError | two joints cut the same wood in one part: move one, or shorten the tenons |
ClosureError | a closed frame doesn’t close: the lengths around the loop don’t add up |
SiteConflictError | a beam end has two joints: each end hosts one |
Dado depth ... would pierce the wall | use a shallower DadoSpec(depth=...) |
pocket_screw: ... too thin | stock under 12 mm: use a dado, a biscuit or glue and pins |
CutListError | a piece is longer than the stock: buy longer boards or split it |
Next
- Frames and weldments: timber and steel frames from a skeleton.
- T-slot framing: aluminium extrusion frames.