Skip to content

armgit / bygga

Public Imported from GitHub
0

IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.

TypeScript

Draw KALLAX with inserts

Youssefc12958503b27
diff --git a/scripts/ikea/build.ts b/scripts/ikea/build.ts
index 9004713..6daf577 100644
--- a/scripts/ikea/build.ts
+++ b/scripts/ikea/build.ts
@@ -65,6 +65,8 @@ function baseMatch(name: string, draw: Draw): CatalogEntry | undefined {
const fam = fold(name);
const spec = specFor(draw.kind, name, "", draw.w, draw.h, draw.d, draw.x);
const g = draw.guessed;
+ // a cube shelf with inserts or on an underframe is more than the hand made shelf of the same size
+ if (draw.x.ins || draw.x.uf) return undefined;
for (const e of BASE) {
if (fold(e.name) !== fam) continue;
if (e.archetype !== spec.archetype && e.category !== spec.category) continue;
diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.ts
index 8a0f7c2..7c8baaa 100644
--- a/scripts/ikea/classify.ts
+++ b/scripts/ikea/classify.ts
@@ -259,6 +259,8 @@ const RULES: Rule[] = [
[/^(wall shelf unit|wall shelf|wall-mounted shelving unit|wall storage unit)$/, (m, c) => (c.sz.n.length === 3 && c.sz.n[2] >= 25) || (m[1] === "wall shelf unit" && c.sz.n.length >= 2) ? { kind: "wallshelf" } : "single shelf board"],
// KALLAX on an underframe 17 cm high, sold together: the shelf, then the frame screwed to its bottom
[/^shelving unit with underframe$/, (_m, c) => (c.f.name === "KALLAX" ? { kind: "cube", x: { uf: 17 } } : "shelving unit on an underframe")],
+ // KALLAX sold with inserts: drawn as inserts with a door, from the bottom row up
+ [/^shelving unit with (\d+) inserts$/, (m, c) => (c.f.name === "KALLAX" ? { kind: "cube", x: { ins: Number(m[1]) } } : "shelving unit with inserts")],
[/^(modular )?chest of (\d+) drawers$/, (m) => ({ kind: "chest", x: { rows: Number(m[2]) } })],
[/^(drawer unit|drawer unit on castors|chest of drawers|dresser)$/, () => ({ kind: "chest" })],
[/^(bedside table|nightstand|bedside table with (\d) drawers?)$/, (m) => ({ kind: "nightstand", x: m[2] ? { rows: Number(m[2]) } : {} })],
diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.json
index c35bce4..a49cc38 100644
--- a/scripts/ikea/slugs.json
+++ b/scripts/ikea/slugs.json
@@ -442,6 +442,14 @@
"JUTHOLMEN|Modular corner sofa 3-seat, outdoor": "jutholmen-modular-corner-sofa-3-seat-outdoor",
"JUTTERSBO|Trolley, 36 × 36 cm": "juttersbo-trolley-36-x-36",
"KALLAX|Desk, 111 × 39 cm": "kallax-desk-111-x-39",
+ "KALLAX|Shelving unit with 10 inserts, 182 × 182 cm": "kallax-shelving-unit-10-inserts-182-x-182",
+ "KALLAX|Shelving unit with 2 inserts, 147 × 42 cm": "kallax-shelving-unit-2-inserts-147-x-42",
+ "KALLAX|Shelving unit with 2 inserts, 77 × 147 cm": "kallax-shelving-unit-2-inserts-77-x-147",
+ "KALLAX|Shelving unit with 4 inserts, 147 × 112 cm": "kallax-shelving-unit-4-inserts-147-x-112",
+ "KALLAX|Shelving unit with 4 inserts, 147 × 147 cm": "kallax-shelving-unit-4-inserts-147-x-147",
+ "KALLAX|Shelving unit with 4 inserts, 147 × 77 cm": "kallax-shelving-unit-4-inserts-147-x-77",
+ "KALLAX|Shelving unit with 6 inserts, 112 × 147 cm": "kallax-shelving-unit-6-inserts-112-x-147",
+ "KALLAX|Shelving unit with 8 inserts, 147 × 147 cm": "kallax-shelving-unit-8-inserts-147-x-147",
"KALLAX|Shelving unit with underframe, 147 × 129 cm": "kallax-shelving-unit-underframe-147-x-129",
"KALLAX|Shelving unit with underframe, 147 × 164 cm": "kallax-shelving-unit-underframe-147-x-164",
"KALLAX|Shelving unit with underframe, 147 × 59 cm": "kallax-shelving-unit-underframe-147-x-59",
diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.ts
index 5b48559..dacd397 100644
--- a/src/data/ikea-items.ts
+++ b/src/data/ikea-items.ts
@@ -490,12 +490,20 @@ kallax-2x2|60324520 60275812 00477931 20653320 20275814 50305739 79552951 995529
kallax-2x4|00324518 20275885 40346924 10305741 90653326 80275887 39602509 19602505 99602506
kallax-4x4|30275861 10324513 10275862 80477932 20305745
kallax-desk-111-x-39|30582445 90585101 00582442
+kallax-shelving-unit-10-inserts-182-x-182|09278338 09197605 69278335
kallax-shelving-unit-112-x-147|10409932 20409936 40409935 70477937 60653323
kallax-shelving-unit-147-x-77|20604141 39552905 19552893 79552908
kallax-shelving-unit-182-x-182|70301537 90324509 90477936 70301542
+kallax-shelving-unit-2-inserts-147-x-42|39278290 79197584 79278293
+kallax-shelving-unit-2-inserts-77-x-147|99027227
+kallax-shelving-unit-4-inserts-147-x-112|79278250 49278256 19278253
+kallax-shelving-unit-4-inserts-147-x-147|19278328 19197596 79278325 59278331 89030584 39030591 39017486 49197420 09017483 29278323 69227671 09573198
+kallax-shelving-unit-4-inserts-147-x-77|29197572 29278304 89278301 59278307
kallax-shelving-unit-42-x-41|80395875 20301554 60477933 70309840
+kallax-shelving-unit-6-inserts-112-x-147|29278262 59278265 89278259
kallax-shelving-unit-77-x-112|50522417 70522421 90522420
kallax-shelving-unit-77-x-41|40395877 40311873 10477935 20395878 90301555
+kallax-shelving-unit-8-inserts-147-x-147|69017475
kallax-shelving-unit-underframe-147-x-129|79442694 99442711 39442691 19442710 99442706 79442707 19442692
kallax-shelving-unit-underframe-147-x-164|09442720 49442718 79442712 39442714 89442721 29442719 59442713
kallax-shelving-unit-underframe-147-x-59|29442663 39442672 99442674 39442667 19442668 09442664 59442666
diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.ts
index af1246e..548e080 100644
--- a/src/data/ikea-rows.ts
+++ b/src/data/ikea-rows.ts
@@ -446,12 +446,20 @@ KALLAX|cube|Shelving unit, 42 × 41 cm|42|41|39
KALLAX|cube|Shelving unit, 77 × 41 cm|77|41|39
KALLAX|cube|Shelving unit with underframe, 77 × 94 cm|77|94|39|uf=17
KALLAX|cube|Shelving unit, 77 × 112 cm|77|112|39
+KALLAX|cube|Shelving unit with 2 inserts, 77 × 147 cm|77|147|39|ins=2
KALLAX|cube|Shelving unit with underframe, 77 × 164 cm|77|164|39|uf=17
+KALLAX|cube|Shelving unit with 6 inserts, 112 × 147 cm|112|147|39|ins=6
KALLAX|cube|Shelving unit, 112 × 147 cm|112|147|39
+KALLAX|cube|Shelving unit with 2 inserts, 147 × 42 cm|147|42|39|ins=2
KALLAX|cube|Shelving unit with underframe, 147 × 59 cm|147|59|39|uf=17
+KALLAX|cube|Shelving unit with 4 inserts, 147 × 77 cm|147|77|39|ins=4
KALLAX|cube|Shelving unit with underframe, 147 × 94 cm|147|94|39|uf=17
+KALLAX|cube|Shelving unit with 4 inserts, 147 × 112 cm|147|112|39|ins=4
KALLAX|cube|Shelving unit with underframe, 147 × 129 cm|147|129|39|uf=17
+KALLAX|cube|Shelving unit with 4 inserts, 147 × 147 cm|147|147|39|ins=4
+KALLAX|cube|Shelving unit with 8 inserts, 147 × 147 cm|147|147|39|ins=8
KALLAX|cube|Shelving unit with underframe, 147 × 164 cm|147|164|39|uf=17
+KALLAX|cube|Shelving unit with 10 inserts, 182 × 182 cm|182|182|39|ins=10
KALLAX|cube|Shelving unit, 182 × 182 cm|182|182|39
KALLAX|desk|Desk, 111 × 39 cm|111|74|39
KALLSÖ|bench|Bench with shoe storage, 80 × 38 × 56 cm|80|56|38
diff --git a/src/lib/ikea.ts b/src/lib/ikea.ts
index eea13c1..9f98007 100644
--- a/src/lib/ikea.ts
+++ b/src/lib/ikea.ts
@@ -23,7 +23,7 @@ export interface IkeaRow {
slug?: string;
}
-const X_KEYS = ["rows", "cols", "knobs", "plinth", "doors", "shelves", "c", "m", "l", "f", "seats", "arms", "legs", "attach", "shelf", "min", "round", "seatH", "chaise", "corner", "open", "sd", "drawer", "leaves", "leaf", "under", "mats", "dtop", "rail", "slides", "n", "of", "hinge", "use", "z", "basin", "hung", "uf"] as const;
+const X_KEYS = ["rows", "cols", "knobs", "plinth", "doors", "shelves", "c", "m", "l", "f", "seats", "arms", "legs", "attach", "shelf", "min", "round", "seatH", "chaise", "corner", "open", "sd", "drawer", "leaves", "leaf", "under", "mats", "dtop", "rail", "slides", "n", "of", "hinge", "use", "z", "basin", "hung", "uf", "ins"] as const;
const FLAGS = new Set<string>(["plinth", "shelf", "round", "open", "drawer", "dtop", "rail", "hinge", "hung"]);
const WORDS = new Set<string>(["knobs", "arms", "legs", "attach", "chaise", "corner", "under", "of", "use", "z"]);
diff --git a/src/lib/plan/shelf.ts b/src/lib/plan/shelf.ts
index f2fe2b5..56e61bc 100644
--- a/src/lib/plan/shelf.ts
+++ b/src/lib/plan/shelf.ts
@@ -21,7 +21,7 @@ export function defaultsShelf(s: ProductSpec): ShelfParams {
export function buildShelf(b: PlanBuilder, s: ProductSpec) {
const p = defaultsShelf(s);
- if (p.style === "grid") return s.shelf?.underframe ? onUnderframe(b, s, p) : grid(b, s, p);
+ if (p.style === "grid") return s.shelf?.underframe ? onUnderframe(b, s, p) : s.shelf?.inserts ? withInserts(b, s, p) : grid(b, s, p);
return bookcase(b, s, p);
}
@@ -227,6 +227,124 @@ function grid(b: PlanBuilder, s: ProductSpec, p: ShelfParams, beforeAnchor?: ()
if (H >= 700) anchorStep(b, { W, D, top, y: H, backZ: -D / 2, severe: H > 1200 });
}
+/**
+ * A cube shelf sold with inserts (KALLAX): the shelf first, then each insert, a small box with a door, is put
+ * together, pushed into a cube and screwed in, from the bottom row up; last the doors go on their hinges.
+ */
+function withInserts(b: PlanBuilder, s: ProductSpec, p: ShelfParams) {
+ const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;
+ const T = p.outer, ti = p.inner;
+ const { cols, rows } = p;
+ const n = clamp(Math.round(s.shelf!.inserts!), 1, cols * rows);
+ const cellW = (W - 2 * T - (cols - 1) * ti) / cols;
+ const cellH = (H - 2 * T - (rows - 1) * ti) / rows;
+ const cx = (c: number) => -W / 2 + T + c * (cellW + ti) + cellW / 2;
+ const cy = (r: number) => T + r * (cellH + ti) + cellH / 2;
+ grid(b, s, p, () => {
+ const it = 12, dt = 16;
+ const bw = cellW - 2, bh = cellH - 2, bd = D - 20 - dt - 2;
+ const zb = -D / 2 + 20 + bd / 2; // the box sits back from the front, behind its door
+ const sideT = b.part("Insert side", [it, bh, bd]);
+ const flatT = b.part("Insert top and bottom", [bw - 2 * it, it, bd]);
+ const doorT = b.part("Door", [cellW - 4, cellH - 4, dt]);
+ const boxes = Array.from({ length: n }, (_, i) => {
+ const c = i % cols, r = Math.floor(i / cols);
+ const x = cx(c), y = cy(r);
+ return {
+ x,
+ y,
+ parts: [
+ b.place(sideT, [x - bw / 2 + it / 2, y, zb]),
+ b.place(sideT, [x + bw / 2 - it / 2, y, zb]),
+ b.place(flatT, [x, y - bh / 2 + it / 2, zb]),
+ b.place(flatT, [x, y + bh / 2 - it / 2, zb]),
+ ],
+ door: b.place(doorT, [x, y, D / 2 - dt / 2]),
+ };
+ });
+ const at = (k: string) => b.partItem(k).final.pos;
+ const b0 = boxes[0];
+ const rel = (k: string): Vec3 => [at(k)[0] - b0.x, at(k)[1] - b0.y + bh / 2, at(k)[2] - zb];
+ const corners = (bx: (typeof boxes)[number]): FitOpts[] =>
+ bx.parts.slice(0, 2).flatMap((sd, i) => {
+ const x = at(sd)[0] + (i === 0 ? -it / 2 : it / 2);
+ return [bx.y - bh / 2 + it / 2, bx.y + bh / 2 - it / 2].map((y) => ({ on: sd, at: [x, y, zb] as Vec3, dir: [i === 0 ? 1 : -1, 0, 0] as Vec3 }));
+ });
+ b.step(
+ {
+ title: n > 1 ? "Put the inserts together" : "Put the insert together",
+ detail: "Screw the top and bottom between the two sides.",
+ tools: ["screwdriver"],
+ scene: "insert",
+ repeat: n > 1 ? n : undefined,
+ kind: "screws",
+ warnings: ["floor"],
+ },
+ () => {
+ b.stagger(0.2);
+ b0.parts.forEach((k) => b.stage(k, rel(k), [0, 0, 0], [0, 160, 0]));
+ b.then(0.1);
+ b.fits(HW.screwM, corners(b0), 0.1);
+ },
+ );
+ b.step(
+ {
+ title: n > 1 ? "Push the inserts into the cubes" : "Push the insert into a cube",
+ detail: "From the bottom row up. Slide each one in until it meets the back edge, then screw it to the shelf under it.",
+ tools: ["screwdriver"],
+ kind: "join",
+ weight: 0.8 + 0.4 * n,
+ },
+ () => {
+ for (const [i, bx] of boxes.entries()) {
+ b.stagger(0);
+ bx.parts.forEach((k) => b.add(k, [0, 0, 420]));
+ if (i > 0) for (const o of corners(bx)) b.preset(HW.screwM, o);
+ b.wait(0.18);
+ }
+ b.then(0.1);
+ const list: FitOpts[] = boxes.flatMap((bx) => [-bw / 4, bw / 4].map((dx) => ({ on: bx.parts[2], at: [bx.x + dx, bx.y - bh / 2 + it, zb + bd / 4] as Vec3, dir: [0, -1, 0] as Vec3, hole: false })));
+ b.fits(HW.screwS, list, 0.06);
+ },
+ );
+ const hingeX = cellW / 2 - 22;
+ b.step(
+ {
+ title: n > 1 ? "Press the hinges into the doors" : "Press the hinges into the door",
+ detail: n > 1 ? "Two on each door, along its left edge." : "Two of them, along its left edge.",
+ tools: ["screwdriver"],
+ scene: "doors",
+ repeat: n > 1 ? n : undefined,
+ kind: "hinges",
+ warnings: ["floor"],
+ },
+ () => {
+ b.stage(b0.door, [0, dt / 2, 0], [Math.PI / 2, 0, 0], [0, 160, 0]);
+ b.then(0.1);
+ const list: FitOpts[] = [b0.y - cellH / 2 + 70, b0.y + cellH / 2 - 70].map((y) => ({ on: b0.door, at: [b0.x - hingeX, y, D / 2 - dt], dir: [0, 0, 1] as Vec3 }));
+ b.fits(HW.hinge, list, 0.12);
+ },
+ );
+ b.step(
+ {
+ title: n > 1 ? "Hang the doors" : "Hang the door",
+ detail: "Clip each hinge onto its plate inside the insert, then turn the screws until the gaps look even.",
+ tools: ["screwdriver"],
+ kind: "doors",
+ weight: 0.8 + 0.4 * n,
+ },
+ () => {
+ for (const [i, bx] of boxes.entries()) {
+ b.stagger(0);
+ b.add(bx.door, [0, 0, 360]);
+ if (i > 0) for (const y of [bx.y - cellH / 2 + 70, bx.y + cellH / 2 - 70]) b.preset(HW.hinge, { on: bx.door, at: [bx.x - hingeX, y, D / 2 - dt], dir: [0, 0, 1] });
+ b.wait(0.2);
+ }
+ },
+ );
+ });
+}
+
/**
* A cube shelf on an underframe (KALLAX): the shelf is built exactly as it is on its own, then laid on its back
* for the underframe to be screwed to its bottom, and stood up on it. Built with its bottom at zero, then lifted.
diff --git a/src/lib/products.ts b/src/lib/products.ts
index 84aa790..d72a985 100644
--- a/src/lib/products.ts
+++ b/src/lib/products.ts
@@ -93,6 +93,7 @@ export type X = {
basin?: number;
hung?: boolean;
uf?: number;
+ ins?: number;
};
export type Row = [name: string, kind: Kind, variant: string, w: number, h: number, d: number, x?: X, keywords?: string];
@@ -365,7 +366,11 @@ export function specFor(kind: Kind, name: string, variant: string, w: number, h:
};
switch (kind) {
case "cube":
- // x.uf: cm of an underframe the grid stands on
+ // x.uf: cm of an underframe the grid stands on; x.ins: inserts with a door in its cubes
+ if (x.ins) {
+ const cols = Math.max(1, Math.round((w - 6) / 35)), rows = Math.max(1, Math.round((h - 6) / 35));
+ return { ...base, minutes: x.min ?? 10 + 7 * cols * rows + 15 * x.ins, people: cols * rows > 4 ? 2 : 1, difficulty: 2, shelf: { style: "grid", cols, rows, outer: 40, inner: 16, back: false, inserts: x.ins } };
+ }
if (x.uf) {
const cols = Math.max(1, Math.round((w - 6) / 35)), rows = Math.max(1, Math.round((h - x.uf - 6) / 35));
return { ...base, minutes: x.min ?? 30 + 7 * cols * rows, people: cols * rows > 4 ? 2 : 1, shelf: { style: "grid", cols, rows, outer: 40, inner: 16, back: false, underframe: x.uf } };
diff --git a/src/lib/types.ts b/src/lib/types.ts
index a90816f..1be58f6 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -14,6 +14,7 @@ export interface ShelfParams {
inner: number; // mm thickness of inner shelves/dividers
wall?: boolean; // hangs on the wall instead of standing on the floor
underframe?: number; // cm: a cube grid standing on an underframe this tall (size.h takes it in)
+ inserts?: number; // a cube grid sold with this many inserts with a door, from the bottom row up
}
export interface DrawersParams {