bambu-printer-mcp 1.1.91 → 1.1.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CONTRIBUTORS.md +2 -0
  2. package/README.md +8 -4
  3. package/dist/bambu-native.js +1 -1
  4. package/dist/cad/contracts.js +16 -7
  5. package/dist/cad/examples.d.ts +2 -1
  6. package/dist/cad/examples.js +13 -10
  7. package/dist/cad/serial.d.ts +1 -1
  8. package/dist/cad/serial.js +4 -6
  9. package/dist/cad-engine.js +17 -12
  10. package/dist/counterpart/info.d.ts +2 -0
  11. package/dist/counterpart/info.js +6 -1
  12. package/dist/counterpart/remote.js +1 -0
  13. package/dist/counterpart/schemas.d.ts +5 -0
  14. package/dist/counterpart/schemas.js +1 -0
  15. package/dist/counterpart/self-check.d.ts +79 -0
  16. package/dist/counterpart/self-check.js +163 -0
  17. package/dist/index.js +50 -24
  18. package/dist/printers/bambu.d.ts +6 -0
  19. package/dist/printers/bambu.js +59 -25
  20. package/dist/printers/report-merge.d.ts +12 -0
  21. package/dist/printers/report-merge.js +46 -0
  22. package/dist/safety/limits.d.ts +6 -0
  23. package/dist/safety/limits.js +8 -0
  24. package/dist/safety/print-file.js +2 -2
  25. package/dist/safety/printer-state.d.ts +4 -0
  26. package/dist/safety/printer-state.js +14 -1
  27. package/dist/stl/stl-manipulator.js +79 -20
  28. package/dist/studio-print-options.d.ts +9 -0
  29. package/dist/studio-print-options.js +34 -2
  30. package/dist/tool-annotations.js +1 -0
  31. package/package.json +6 -1
  32. package/src/bambu-native.ts +1 -1
  33. package/src/cad/contracts.ts +17 -7
  34. package/src/cad/examples/bag_clip.py +1 -0
  35. package/src/cad/examples/bistable_clicker.py +1 -0
  36. package/src/cad/examples/broom_grip.py +61 -0
  37. package/src/cad/examples/cable_clip.py +1 -0
  38. package/src/cad/examples/chainmail.py +1 -0
  39. package/src/cad/examples/desk_clamp_hook.py +91 -0
  40. package/src/cad/examples/desk_edge_cable_holder.py +55 -0
  41. package/src/cad/examples/drawer_divider.py +56 -0
  42. package/src/cad/examples/hinged_box.py +1 -0
  43. package/src/cad/examples/knurled_knob.py +1 -0
  44. package/src/cad/examples/loft_handle.py +1 -0
  45. package/src/cad/examples/organizer_tray.py +41 -0
  46. package/src/cad/examples/phone_stand.py +1 -0
  47. package/src/cad/examples/plant_pot.py +53 -0
  48. package/src/cad/examples/shelf_bracket.py +53 -0
  49. package/src/cad/examples/swept_hook.py +1 -0
  50. package/src/cad/examples/threaded_jar.py +1 -0
  51. package/src/cad/examples/trigger_capo.py +1 -0
  52. package/src/cad/examples/wall_hook.py +1 -0
  53. package/src/cad/examples.ts +13 -10
  54. package/src/cad/geometry.py +6 -0
  55. package/src/cad/serial.ts +4 -6
  56. package/src/cad-engine.ts +9 -3
  57. package/src/counterpart/info.ts +7 -1
  58. package/src/counterpart/remote.ts +1 -0
  59. package/src/counterpart/schemas.ts +3 -1
  60. package/src/counterpart/self-check.ts +164 -0
  61. package/src/index.ts +48 -20
  62. package/src/printers/bambu.ts +57 -24
  63. package/src/printers/report-merge.ts +48 -0
  64. package/src/safety/limits.ts +8 -0
  65. package/src/safety/print-file.ts +2 -2
  66. package/src/safety/printer-state.ts +13 -1
  67. package/src/stl/stl-manipulator.ts +75 -14
  68. package/src/studio-print-options.ts +33 -2
  69. package/src/tool-annotations.ts +1 -0
@@ -39,6 +39,14 @@ export function isDualNozzleModel(model) {
39
39
  const normalized = normalizeModel(model);
40
40
  return normalized !== undefined && DUAL_NOZZLE_MODELS.has(normalized);
41
41
  }
42
+ /** File models a printer accepts besides its own, keyed by the printer's observed model.
43
+ * A P1P with the enclosure upgrade kit still reports itself as a P1P, while its jobs are sliced with the P1S
44
+ * preset. Bambu Studio sends those jobs: resources/printers/C11.json (P1P) lists C12 (P1S) in compatible_machine.
45
+ * The two models have identical MACHINE_LIMITS, and the file is still checked against the printer's own limits. */
46
+ export const ACCEPTED_FILE_MODELS = { p1p: new Set(['p1s']) };
47
+ export function fileModelFitsPrinter(fileModel, printerModel) {
48
+ return fileModel === printerModel || ACCEPTED_FILE_MODELS[printerModel]?.has(fileModel) === true;
49
+ }
42
50
  export function normalizeModel(value) {
43
51
  if (typeof value !== 'string')
44
52
  return undefined;
@@ -1,7 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { readBoundedPrintFile, loadSafe3mfArchive } from './archive.js';
3
3
  import { projectFilaments } from "../ams-mapping.js";
4
- import { MACHINE_LIMITS, isDualNozzleModel, normalizeMaterial, normalizeModel, validateStartupPurgeTemperature, validateTemperature } from './limits.js';
4
+ import { MACHINE_LIMITS, fileModelFitsPrinter, isDualNozzleModel, normalizeMaterial, normalizeModel, validateStartupPurgeTemperature, validateTemperature } from './limits.js';
5
5
  const NUMBER = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
6
6
  const fail = (message) => { throw new Error(`Print safety: ${message}`); };
7
7
  function list(value) {
@@ -292,7 +292,7 @@ export async function inspectPrintFile(filePath, options) {
292
292
  const metadata = [project, ...headers];
293
293
  validateFffJob([...metadata, plate]);
294
294
  const declaredModel = consistent(metadataValues(metadata, ['printer_model']), normalizeModel, 'printer model');
295
- if (declaredModel !== model)
295
+ if (!fileModelFitsPrinter(declaredModel, model))
296
296
  return fail(`file model ${declaredModel} contradicts requested model ${model}`);
297
297
  const nozzleDiameters = consistent(metadataValues(metadata, ['nozzle_diameter']), value => {
298
298
  const values = list(value);
@@ -105,4 +105,8 @@ export type ExternalStorageState = "none" | "normal" | "abnormal" | "readonly";
105
105
  * (DevStorage.cpp, DeviceManager.cpp parse_home_flag and parse_new_info).
106
106
  */
107
107
  export declare function externalStorageState(raw: unknown): ExternalStorageState;
108
+ /** Studio DeviceManager.cpp at 926a7192574b: fun2 bit 0 advertises eMMC printing.
109
+ * Use only a fresh raw report at the caller. Reject malformed flags rather than
110
+ * stripping arbitrary characters as Studio's general-purpose parser does. */
111
+ export declare function internalPrintingSupported(raw: unknown): boolean;
108
112
  export {};
@@ -364,7 +364,7 @@ function trayRange(value, label) {
364
364
  /** Dual-nozzle printers report one virtual external slot per nozzle, numbered as Bambu
365
365
  * Studio does (VIRTUAL_TRAY_MAIN_ID 255 = right/main nozzle, VIRTUAL_TRAY_DEPUTY_ID 254 =
366
366
  * left/deputy nozzle), so the requested tray selects its slot. Single-nozzle printers keep
367
- * requiring exactly one slot 254 report, then the legacy vt_tray field. */
367
+ * requiring exactly one external slot report, then the legacy vt_tray field. */
368
368
  function externalTray(raw, trayIndex, model) {
369
369
  const slots = raw.vir_slot;
370
370
  const dualNozzle = isDualNozzleModel(model);
@@ -372,6 +372,10 @@ function externalTray(raw, trayIndex, model) {
372
372
  const selected = slots.filter((slot) => Number(slot?.id) === trayIndex);
373
373
  if (selected.length === 1 && (dualNozzle || slots.length === 1))
374
374
  return selected[0];
375
+ // X1C firmware 01.12 reports its single external slot as id 255 (ams_id 255, slot 0) while
376
+ // tray_now is 254. One external slot on a single-nozzle printer is unambiguous.
377
+ if (!dualNozzle && slots.length === 1 && [254, 255].includes(Number(slots[0]?.id)) && [254, 255].includes(trayIndex))
378
+ return slots[0];
375
379
  if (dualNozzle && selected.length === 0 && slots.length > 0)
376
380
  throw new Error(`External spool ${trayIndex} is not in the fresh per-nozzle report; cannot verify the selected material.`);
377
381
  if (slots.length > 0)
@@ -551,3 +555,12 @@ export function externalStorageState(raw) {
551
555
  }
552
556
  return state;
553
557
  }
558
+ /** Studio DeviceManager.cpp at 926a7192574b: fun2 bit 0 advertises eMMC printing.
559
+ * Use only a fresh raw report at the caller. Reject malformed flags rather than
560
+ * stripping arbitrary characters as Studio's general-purpose parser does. */
561
+ export function internalPrintingSupported(raw) {
562
+ if (!object(raw) || typeof raw.fun2 !== "string")
563
+ return false;
564
+ const flags = raw.fun2.trim().replace(/^0x/i, "");
565
+ return /^[0-9a-f]+$/i.test(flags) && (parseInt(flags.slice(-1), 16) & 1) === 1;
566
+ }
@@ -10,7 +10,7 @@ import path from 'path';
10
10
  import { promisify } from 'util';
11
11
  import { EventEmitter } from 'events';
12
12
  import * as crypto from 'crypto';
13
- import { execFile } from 'child_process';
13
+ import { spawn } from 'child_process';
14
14
  import { keepSlice, restoreSlice, sliceCacheKey } from '../slicer/slice-cache.js';
15
15
  import { listModelPlates } from '../counterpart/model-plates.js';
16
16
  import { flattenForCli, detectProfilesRoot, resolveBblMachineProfile } from '../slicer/profile-flatten.js';
@@ -169,6 +169,32 @@ function slicerResultText(result) {
169
169
  ...plates.map(plate => plate && typeof plate === "object" ? plate.warning_message : undefined),
170
170
  ].filter((text) => typeof text === "string" && text.trim() !== "").map(text => text.trim()).join("\n");
171
171
  }
172
+ /** The output kept from each stream, as execFile's default maxBuffer; the rest is dropped, not failed. */
173
+ const SLICER_OUTPUT_LIMIT = 1024 * 1024;
174
+ /**
175
+ * execFile for the slicer, with detached passed through (execFile drops it): on POSIX the slicer then leads its own
176
+ * process group, so a cancel can stop the helpers it starts too. The callback gets what execFile's would.
177
+ */
178
+ function execSlicer(file, args, env, detached, callback) {
179
+ // stdin is ignored, as execFile ends it: no slicer reads it.
180
+ const child = spawn(file, args, { ...(env ? { env } : {}), detached, stdio: ["ignore", "pipe", "pipe"] });
181
+ let stdout = "", stderr = "", settled = false;
182
+ const keep = (text, chunk) => text.length >= SLICER_OUTPUT_LIMIT ? text : (text + chunk.toString("utf8")).slice(0, SLICER_OUTPUT_LIMIT);
183
+ child.stdout?.on("data", (chunk) => { stdout = keep(stdout, chunk); });
184
+ child.stderr?.on("data", (chunk) => { stderr = keep(stderr, chunk); });
185
+ const finish = (error) => { if (!settled) {
186
+ settled = true;
187
+ callback(error, stdout, stderr);
188
+ } };
189
+ child.on("error", error => finish(Object.assign(error, { cmd: [file, ...args].join(" ") })));
190
+ child.on("close", (code, signal) => {
191
+ if (code === 0 && !signal)
192
+ return finish(null);
193
+ const cmd = [file, ...args].join(" ");
194
+ finish(Object.assign(new Error(`Command failed: ${cmd}\n${stderr}`), { code, signal, killed: child.killed, cmd }));
195
+ });
196
+ return child;
197
+ }
172
198
  function describeSlicerFailure(error, stdout, stderr, cli) {
173
199
  const status = typeof error.signal === "string" && error.signal
174
200
  ? `crashed with ${error.signal}`
@@ -1667,11 +1693,19 @@ export class STLManipulator extends EventEmitter {
1667
1693
  const launch = await prepareSlicerLaunch(slicerType, this.tempDir);
1668
1694
  const stallSeconds = launch.stallSeconds;
1669
1695
  let stalled = false;
1696
+ let cancelled = false;
1670
1697
  // Execute the slicer
1671
1698
  try {
1672
1699
  await new Promise((resolve, reject) => {
1673
- const process = execFile(slicerPath, args, launch.env ? { env: launch.env } : {}, (error, stdout, stderr) => {
1674
- if (stalled && error) {
1700
+ // POSIX: the slicer leads its own process group, so stopping it also stops the helpers it starts.
1701
+ const group = globalThis.process.platform !== 'win32';
1702
+ const process = execSlicer(slicerPath, args, launch.env, group, (error, stdout, stderr) => {
1703
+ if (cancelled) {
1704
+ // Settled once the slicer and every process sharing its output have gone, so its folder is removed after
1705
+ // nothing can write to it.
1706
+ reject(new Error("Slicing operation cancelled"));
1707
+ }
1708
+ else if (stalled && error) {
1675
1709
  reject(stalledSlicerError(slicerType, stallSeconds));
1676
1710
  }
1677
1711
  else if (error) {
@@ -1691,29 +1725,53 @@ export class STLManipulator extends EventEmitter {
1691
1725
  // Optional: Add listeners for stdout/stderr for real-time progress if slicer provides it
1692
1726
  // process.stdout?.on('data', (data) => { console.error(`Slicer stdout: ${data}`); });
1693
1727
  // process.stderr?.on('data', (data) => { console.error(`Slicer stderr: ${data}`); });
1694
- // Check for cancellation periodically
1728
+ // Stops the slicer and, on POSIX, its whole process group (a group already gone is not an error).
1729
+ const stop = (signal) => {
1730
+ try {
1731
+ if (group && process.pid !== undefined)
1732
+ globalThis.process.kill(-process.pid, signal);
1733
+ else
1734
+ process.kill(signal);
1735
+ }
1736
+ catch (killError) {
1737
+ if (killError.code !== 'ESRCH')
1738
+ console.error(`Could not send ${signal} to the slicer:`, killError);
1739
+ }
1740
+ };
1741
+ // Check for cancellation periodically: the slicer is stopped, and the call settles when it has gone.
1742
+ let forceKill;
1743
+ let abandon;
1695
1744
  const checkCancel = setInterval(() => {
1696
1745
  if (!this.activeOperations.get(operationId)) {
1697
1746
  clearInterval(checkCancel);
1698
- try {
1699
- process.kill(); // Attempt to kill the slicer process
1700
- reject(new Error("Slicing operation cancelled"));
1701
- }
1702
- catch (killError) {
1703
- console.error("Error attempting to kill slicer process:", killError);
1704
- reject(new Error("Slicing operation cancelled, but failed to kill process."));
1705
- }
1747
+ cancelled = true;
1748
+ stop('SIGTERM');
1749
+ // A slicer or helper that ignores SIGTERM is killed outright rather than waited on. A helper outside the
1750
+ // group (daemonized, or any helper on Windows) can still hold the output pipes, so 'close' never comes:
1751
+ // a second later the pipes are let go and the cancel settles.
1752
+ forceKill = setTimeout(() => {
1753
+ stop('SIGKILL');
1754
+ abandon = setTimeout(() => {
1755
+ process.stdout?.destroy();
1756
+ process.stderr?.destroy();
1757
+ reject(new Error("Slicing operation cancelled"));
1758
+ }, 1000);
1759
+ }, 5000);
1706
1760
  }
1707
1761
  }, 500);
1708
- process.on('exit', () => clearInterval(checkCancel));
1709
- process.on('error', () => clearInterval(checkCancel)); // Ensure interval cleared on process error too
1762
+ process.on('exit', () => {
1763
+ // Exit can precede a client cancel while a helper retains output pipes; polling runs until close.
1764
+ // A helper that outlived the slicer still holds its output; finish it so the call can settle.
1765
+ if (cancelled && group)
1766
+ stop('SIGKILL');
1767
+ });
1768
+ // The deadline runs until every process sharing the slicer's output has let go, not only the slicer.
1769
+ process.on('close', () => { clearInterval(checkCancel); clearTimeout(forceKill); clearTimeout(abandon); });
1770
+ process.on('error', () => { clearInterval(checkCancel); clearTimeout(forceKill); clearTimeout(abandon); });
1710
1771
  watchForStall(process, stallSeconds, () => {
1711
1772
  stalled = true;
1712
1773
  console.error(`${slicerType} used no CPU and wrote nothing for ${stallSeconds} s; stopping it as waiting on a dialog.`);
1713
- try {
1714
- process.kill('SIGKILL');
1715
- }
1716
- catch { /* its exit is reported through the callback */ }
1774
+ stop('SIGKILL');
1717
1775
  });
1718
1776
  });
1719
1777
  }
@@ -1753,8 +1811,9 @@ export class STLManipulator extends EventEmitter {
1753
1811
  catch (error) {
1754
1812
  console.error(`Slicing failed for ${stlFilePath}:`, error);
1755
1813
  // Nothing in a failed or cancelled slice's folder is handed back (its result.json is already in the error).
1756
- if (sliceDir)
1757
- await fs.promises.rm(sliceDir, { recursive: true, force: true }).catch(() => undefined);
1814
+ if (sliceDir) {
1815
+ await fs.promises.rm(sliceDir, { recursive: true, force: true }).then(() => console.error(`Removed the folder of the failed or cancelled slice: ${sliceDir}`), removeError => console.error(`Could not remove the folder of the failed or cancelled slice ${sliceDir}:`, removeError));
1816
+ }
1758
1817
  this.emit('operationError', {
1759
1818
  operationId,
1760
1819
  type: 'slice',
@@ -55,3 +55,12 @@ export declare function usedNozzleCount(inspection: {
55
55
  usedFilamentPositions: number[];
56
56
  filamentNozzleIndices?: Array<number | undefined>;
57
57
  }): number | undefined;
58
+ /** Report only verified direct-wire fields. A task boolean is not an SDK mode.
59
+ * null means this route does not transmit that option, not off/auto/unknown hardware state. */
60
+ export declare function directPrintOptionReport(caller: CallerPrintOptions, resolved: StudioPrintOptions, packet: Record<string, unknown>): {
61
+ warning?: string | undefined;
62
+ requested: CallerPrintOptions;
63
+ resolved: StudioPrintOptions;
64
+ transmitted: Record<string, number | boolean | null>;
65
+ unsupported: string[];
66
+ };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The print options Bambu Studio's Send dialog sends, resolved the way it
3
- * resolves them, so every print route sends what Bambu's own Print button
4
- * would. Source: Bambu Studio v02.08.02.61 (commit 926a7192574b), the version
3
+ * resolves them, for the vendor SDK. Direct routes report which options their verified
4
+ * wire format can carry; this does not establish SDK packet equivalence. Source: Bambu Studio v02.08.02.61 (commit 926a7192574b), the version
5
5
  * the hidden-HMS and stage tables are pinned to:
6
6
  *
7
7
  * - SelectMachine.cpp:3344-3356 `set_print_config(bed_type,
@@ -177,3 +177,35 @@ export function usedNozzleCount(inspection) {
177
177
  const nozzles = inspection.usedFilamentPositions.map(position => inspection.filamentNozzleIndices?.[position]).filter((value) => Number.isInteger(value));
178
178
  return nozzles.length === inspection.usedFilamentPositions.length && nozzles.length ? new Set(nozzles).size : undefined;
179
179
  }
180
+ /** Report only verified direct-wire fields. A task boolean is not an SDK mode.
181
+ * null means this route does not transmit that option, not off/auto/unknown hardware state. */
182
+ export function directPrintOptionReport(caller, resolved, packet) {
183
+ const fields = {
184
+ bedLeveling: ["task_bed_leveling", "bed_leveling"],
185
+ flowCalibration: ["task_flow_cali", "flow_cali"],
186
+ vibrationCalibration: ["task_vibration_cali", "vibration_cali"],
187
+ layerInspect: ["task_layer_inspect", "layer_inspect"],
188
+ autoBedLeveling: ["auto_bed_leveling", "auto_bed_leveling"],
189
+ autoFlowCali: ["auto_flow_cali", "auto_flow_cali"],
190
+ autoOffsetCali: ["auto_offset_cali", "nozzle_offset_cali"],
191
+ extruderCaliManualMode: ["extruder_cali_manual_mode", "extrude_cali_manual_mode"],
192
+ };
193
+ const requested = {};
194
+ const transmitted = {};
195
+ const unsupported = [];
196
+ for (const key of Object.keys(fields)) {
197
+ const [sdk, wire] = fields[key];
198
+ if (caller[key] !== undefined)
199
+ Object.assign(requested, { [key]: caller[key] });
200
+ const value = packet[wire];
201
+ transmitted[sdk] = typeof value === "boolean" || typeof value === "number" ? value : null;
202
+ if (caller[key] !== undefined && transmitted[sdk] === null)
203
+ unsupported.push(key);
204
+ }
205
+ const omitted = Object.keys(transmitted).filter(key => transmitted[key] === null);
206
+ const warning = omitted.length
207
+ ? `Direct print options not transmitted: ${omitted.join(", ")}. Task booleans are not equivalent to Studio integer modes.` +
208
+ (unsupported.length ? ` Requested overrides unsupported by this route: ${unsupported.join(", ")}. Use a vendor bridge/native route that supports these options if required.` : "")
209
+ : undefined;
210
+ return { requested, resolved, transmitted, unsupported, ...(warning ? { warning } : {}) };
211
+ }
@@ -44,6 +44,7 @@ export const TOOL_ANNOTATIONS = {
44
44
  list_templates: READ_LOCAL,
45
45
  get_slice_settings: LOCAL_OUTPUT, // a 3MF's settings are extracted to a fixed file in the temporary directory
46
46
  counterpart_printer_info: READ_LOCAL, // configuration and capabilities; sends nothing to the printer
47
+ counterpart_self_check: READ_LOCAL, // loads this install's own modules; sends nothing to the printer
47
48
  counterpart_setup_fields: READ_LOCAL, // the settings this server reads; no configured values
48
49
  // Local outputs in the server's temporary directory
49
50
  extend_stl_base: LOCAL_OUTPUT,
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "bambu-printer-mcp",
3
- "version": "1.1.91",
3
+ "version": "1.1.93",
4
4
  "description": "MCP server for Bambu Lab 3D printers with STL manipulation, slicing, and print management",
5
+ "counterpart": {
6
+ "contract": "counterpart/1",
7
+ "notes": "Adds installation self-checks and printer names with their makers, and clears stale progress until the new job reports its own.",
8
+ "autoUpdate": true
9
+ },
5
10
  "main": "dist/index.js",
6
11
  "repository": {
7
12
  "type": "git",
@@ -221,7 +221,7 @@ function isRegularFile(file: string): boolean {
221
221
  */
222
222
  function resolveNativeInstall(): NativeInstall {
223
223
  if (!isBambuNativePlatform()) {
224
- throw new Error("Bambu native X2D transport requires macOS or x86-64 Linux and Bambu's networking plug-in.");
224
+ throw new Error("Bambu native transport requires macOS or x86-64 Linux and Bambu's networking plug-in.");
225
225
  }
226
226
  const helper = resolveNativeHelper();
227
227
  if (process.platform !== "linux") return { helper, env: {} };
@@ -113,7 +113,7 @@ export const CAD_TOOLS = [
113
113
  {
114
114
  name: "cad_run",
115
115
  description:
116
- "Build parametric CAD headlessly in OS confinement. Read cad_design first: declare literal P = {...} and build() returning a build123d Shape. Supply script OR script_path; parameters overrides saved named values in one call before derived dimensions. Calls wait for the environment’s exclusive execution slot up to their own deadline and report queue_wait_ms. Each call creates a private immutable subfolder under allowed output_dir, never overwriting previous artifacts. The saved .py and .parameters.json are the recovery checkpoint even after cancellation. Returns independently measured geometry, STL/STEP, six orthographic renders, a perspective view and a contact sheet, the closest approach between every pair of solids (bodies), problems, and what was checked and not checked; valid means only that the exported geometry is sound, never that the part fits, holds, moves or prints.",
116
+ "Build parametric CAD headlessly in OS confinement. Read cad_design first: declare literal P = {...} and build() returning a build123d Shape. Supply script OR script_path; parameters overrides saved named values in one call before derived dimensions. Calls wait for the environment’s exclusive execution slot up to their own deadline and report queue_wait_ms. Each call creates a private immutable subfolder under allowed output_dir, never overwriting previous artifacts. The saved .py and .parameters.json are the recovery checkpoint even after cancellation. Returns independently measured geometry, STL/STEP, six orthographic renders, a perspective view and a contact sheet (with next: read the perspective view before the next change), the closest approach between every pair of solids (bodies), problems, what was checked and not checked, and printed: whatever the script wrote with print(), capped at 4000 characters, so a design can report a number it computed; valid means only that the exported geometry is sound, never that the part fits, holds, moves or prints.",
117
117
  inputSchema: {
118
118
  type: "object" as const,
119
119
  properties: {
@@ -225,6 +225,12 @@ export const CAD_TOOLS = [
225
225
  checked: { type: "array", items: { type: "string" } },
226
226
  not_checked: { type: "array", items: { type: "string" } },
227
227
  renders: { type: "object", additionalProperties: { type: "string" } },
228
+ next: { type: "string", description: "What to do before the next change: look at the perspective render." },
229
+ printed: {
230
+ type: "string",
231
+ description:
232
+ "The script's own print() output from this run, capped at 4000 characters (build.log keeps the rest). The script's words, not a measurement by the engine.",
233
+ },
228
234
  seconds: { type: "number" },
229
235
  },
230
236
  [
@@ -251,7 +257,7 @@ export const CAD_TOOLS = [
251
257
  {
252
258
  name: "cad_examples",
253
259
  description:
254
- "The code engine's cookbook: worked build123d designs from simple to complex, each modelled on the best bought version of the thing, with its concept, published sizes and script. Without arguments, lists them (name, title, the pattern each shows, the product it is modelled on). With name, returns that example's record and full script to adapt. Read-only; starts no process.",
260
+ "The code engine's cookbook: worked build123d designs from simple to complex, each modelled on the best bought version of the thing, with its concept, published sizes and script. Without arguments, lists them by purpose (name, title, use_for: the requests it suits, the pattern it shows, the product it is modelled on): choose by use_for before choosing a mechanism. With name, returns that example's record and full script to adapt. Read-only; starts no process.",
255
261
  inputSchema: {
256
262
  type: "object" as const,
257
263
  properties: {
@@ -271,15 +277,17 @@ export const CAD_TOOLS = [
271
277
  properties: {
272
278
  name: { type: "string" },
273
279
  title: { type: "string" },
280
+ use_for: { type: "string" },
274
281
  pattern: { type: "string" },
275
282
  modelled_on: { type: "string" },
276
283
  },
277
- required: ["name", "title", "pattern"],
284
+ required: ["name", "title", "use_for", "pattern"],
278
285
  },
279
286
  },
280
287
  usage: { type: "string" },
281
288
  name: { type: "string" },
282
289
  title: { type: "string" },
290
+ use_for: { type: "string" },
283
291
  pattern: { type: "string" },
284
292
  modelled_on: { type: "string" },
285
293
  published_sizes: { type: "string" },
@@ -293,7 +301,7 @@ export const CAD_TOOLS = [
293
301
  {
294
302
  name: "cad_check_fit",
295
303
  description:
296
- "Check two allowed watertight manifold STL meshes in millimetres. Applies only the explicit rigid transform to reference: XYZ rotation in degrees about the origin, then translation. Never silently scales a scan. Reports Boolean interference volume and minimum surface gap (zero on contact/intersection), plus a clearance verdict; intentional support contact also has zero gap. Fails rather than guessing for open meshes or excessive triangle workload.",
304
+ "Check two allowed watertight manifold STL meshes in millimetres. Applies only the explicit rigid transform to reference: XYZ rotation in degrees about the origin, then translation. Never silently scales a scan. Reports Boolean interference volume and minimum surface gap (zero on contact/intersection), plus a clearance verdict; intentional support contact also has zero gap. Like cad_run, a call waits for the environment's exclusive execution slot up to its timeout_ms and reports queue_wait_ms, so several checks may be sent at once. Fails rather than guessing for open meshes or excessive triangle workload.",
297
305
  inputSchema: {
298
306
  type: "object" as const,
299
307
  properties: {
@@ -341,6 +349,7 @@ export const CAD_TOOLS = [
341
349
  outputSchema: output(
342
350
  {
343
351
  units: { type: "string", const: "mm" },
352
+ queue_wait_ms: { type: "integer" },
344
353
  interference_volume_mm3: { type: "number" },
345
354
  minimum_gap_mm: { type: "number" },
346
355
  clearance_mm: { type: "number" },
@@ -365,9 +374,10 @@ export const CAD_DESIGN_PROMPT = {
365
374
  description:
366
375
  "MCP-owned rules for headless build123d designs and one-call parameter revisions.",
367
376
  text: `Use code-CAD for dimensioned functional designs and parameter edits. Build in millimetres with build123d 0.13.0; the MCP owns the Python environment, execution, export, validation and rendering. Check cad_status and use cad_setup with install: true when needed. No Blender, Fusion, network or printer access is available to your script.
368
- Form first: build the product's shape, not a profile pushed up. Before any geometry, write the concept in a few lines: the bought product you are following, its mechanism, the load path, the print orientation and why. build123d has loft (through sections of different shape), sweep (a section along a path or a Helix), revolve, fillet, chamfer, offset and shell as well as extrude; use the one the product's surface calls for: lofted where a hand closes round it, revolved where it turns, swept where it runs like a bent rod or a thread, filleted where two surfaces meet under load. Extrude a flat profile only for something that really is a plate or a lever, or for a print-in-place mechanism or spring that must lie in the layers, and say that reason in the result. Choose the print orientation after the form: split a part, turn it or accept a modest support before flattening its design.
369
- Worked examples: cad_examples lists this engine's cookbook (each modelled on a bought product, with its concept, published sizes and script) and returns one script by name. When the request works like one of these, read that example first and adapt its pattern, never its sizes:
377
+ A new design starts from the product, in this order. First, name two or three products a person would buy for this request (search when you are not sure what is sold) and say which one the design follows. Second, choose from the cookbook by purpose: the list below says what each example is for (cad_examples with no name returns it with each one's pattern and product). Read the example whose use is nearest the request, with cad_examples and its name, before deciding anything else, and adapt its form and pattern, never its sizes. Third, and only then, choose the mechanism (a clamp, screw, spring, hinge or snap) and read a second example for it if you need one. A mechanism chosen before the product gives a bracket with the mechanism bolted on.
378
+ The cookbook, by what each example is for:
370
379
  ${cadExampleLines()}
380
+ Form first: build the product's shape, not a profile pushed up. Before any geometry, write the concept as the script's opening docstring, the way every cookbook example does: what it is, then "Modelled on:" the bought product you named, its mechanism, the load path, the print orientation and why. A script whose header names no product was designed from the mechanism. build123d has loft (through sections of different shape), sweep (a section along a path or a Helix), revolve, fillet, chamfer, offset and shell as well as extrude; use the one the product's surface calls for: lofted where a hand closes round it, revolved where it turns, swept where it runs like a bent rod or a thread, filleted where two surfaces meet under load. Extrude a flat profile only for something that really is a plate or a lever, or for a print-in-place mechanism or spring that must lie in the layers, and say that reason in the result. Choose the print orientation after the form: split a part, turn it or accept a modest support before flattening its design.
371
381
  What the cookbook taught about this engine: return several bodies as Compound([a, b]); bodies that touch or overlap come back invalid, so leave a real gap (0.2 mm or more) or union them, and check that solid_count equals the bodies you intend (for a print-in-place mechanism that count is the first evidence nothing fused). fillet() often fails on the edges of an outline unioned from many curves, where chamfer() usually succeeds: fillet or chamfer simple bodies before the booleans that complicate them, and when a chamfer fails too, apply it to the plain body and union the details on afterwards. Do not round a sketch by growing and shrinking it with offset(): the solid looks right and its STEP comes back with no solids (the step_solids check fails). A whole Sphere() exports open at its poles: trim them (Sphere(r) & Box(2 * r, 2 * r, 2 * r - 0.1)). One fillet of the same radius over every edge of a box can export open: fillet in two passes with different radii. A model with moving parts takes a pose parameter: the assembled pose to judge it, the print plate to make it.
372
382
  Declare exactly one top-level P = {...} dictionary of JSON-compatible literal named parameters. Put every functional dimension in P; derive geometry from P. Define build() to return a build123d Shape or Compound of disjoint solid parts. When a design has separate bodies (print-in-place parts, a captive wheel, links of a fabric), return Compound(children=[...]) with a label on each body: cad_run then checks that each labelled body is exactly one solid, so a piece cut off one body cannot hide behind two bodies fused into one. Near pairs of solids are screened and, where the screen cannot clear them, measured exactly against P["print_in_place_clearance_mm"] when you declare it, else 0.3 mm. If the bodies are shown assembled rather than printed in place (a shaft in its hole at a fit clearance), set P["print_in_place"] = False: only touching or overlap is then a problem. Export in print orientation with the plate at Z = 0: a solid below it, or above it with nothing under it that reaches it, is a problem. Do not put construction or exports in a __main__ block: cad_run calls build() and exports the result. Imports, functions and derived P entries are fine. Parameters are applied to the literal defaults before derived expressions execute. For solid designs without inputs, the script and parameters file alone reconstruct it. For input-dependent designs, declare inputs as an array of {name, path} files: cad_run snapshots only those allowed files, exposes INPUTS[alias] to your script, and saves an inputs manifest. Retain the snapshots too for recovery; subsequent script_path edits reuse them unless inputs is explicitly supplied. No other personal files are readable. For a mesh-only experiment use mode: "mesh" and return a trimesh.Trimesh from build(); it exports and checks STL plus the same renders, with step: null and an explicit reason. It does not manufacture a fake parametric STEP or promise scan-cleanup capability.
373
383
  Call cad_run with script, output_dir and a plain name. It saves <name>.py and <name>.parameters.json before running, then exports <name>.stl and <name>.step in a fresh subfolder. For an edit, one cad_run with script_path pointing to the earlier .py, parameters containing just the changed dimension, output_dir and name regenerates it without resending the script. Existing parameter values are retained; unknown names and type changes are refused. A killed run can be retried from its checkpoint in a new workspace; mutations are never replayed automatically.
@@ -376,7 +386,7 @@ Fit reference workflow: return load_scan("scan", source_units="m", up_axis="y")
376
386
  Result selection and edits: set final: true only on the result you select. cad-result.json in each immediate run folder is protected from script writes and retains final, completed_at, lineage_id (source hash), full checks and artifact paths; clients can discover the latest completed final record after restart without rebuilding. Final is a selection marker, not a replacement for valid/checks. Queued calls may expire with cad-queue-timeout before dispatch; do not automatically replay. Unchanged declared files reuse a read-only content-addressed bundle under output_dir/.cad-inputs, preserving filenames and restricting reads to that bundle. Keep this shared cache with the saved runs.
377
387
  Mesh cleanup workflow: return a trimesh.Trimesh in mode: "mesh". Load the prepared mesh, fit needed geometry with NumPy/SciPy, rebuild regular sections/features with build123d or manifold3d CrossSection/extrusion/revolve, and combine meshes with manifold3d booleans. scikit-image supplies marching cubes for voxel/SDF work; Shapely supplies planar operations; Pillow supplies image/texture reads. Keep numeric choices in P and regenerate from declared inputs. Validate closure, winding, manifold status, dimensions and all six views using cad_run. What to regularise, infer, preserve or label comes from the caller's cleanup rules, not this engine prompt.
378
388
  Captured scan touch-up: t = scan_touchup(load_scan("scan", source_units="m", up_axis="y", ground=False), colour="colour", normal="normal", edge_mm=0.4) takes a textured capture (declare its OBJ, MTL and colour and normal map PNGs as inputs; pass the map aliases). It removes loose pieces and spikes, closes holes and refines to edge_mm without shrinking the body. t.regions() prints the colour regions (id, colour, area, size, flatness; 0 is the body) to build.log and saves regions.png in the run folder: read both, then name regions by id in the same scan and edge_mm. t.flatten(ids, shape="plane" or "curved"), t.bead(id, diameter_mm, proud_mm), t.cord(id, diameter_mm, proud_mm) (a cord follows its region's own curve) and t.seat(height_mm) record steps; return t.mesh(relief_gain=1.0), which adds the normal map's measured relief, applies the steps with manifold3d and prints its changes. Keep relief_gain at 1: a larger gain amplifies the map's noise, not stitches. When the caller's rules call for a textile's relief the scan missed (fabric, knit, crochet the photos show raised), t.texture_relief(height_mm, regions=None) raises its stitch pattern from the colour texture on the textile only (never flattened, beaded or corded regions); about 0.6 to 1.0 mm peak to peak prints visibly. It is off unless called: never for hard objects, printed graphics or labels.
379
- The result includes paths, millimetre bounds/size, mesh and STEP volumes, solid count, watertight/manifold/winding/STEP checks, bodies (closest approach between solids, contact with the print plate at Z = 0, labelled bodies that are not one solid), problems, checked and not_checked, six orthographic renders (front, back, left, right, top, bottom), a perspective view from the front right and above, and a contact sheet with the perspective view large beside the six. Fix every entry in problems before selecting a result; an empty problems list proves nothing listed in not_checked. Judge the form from the perspective view first: would a person recognise the product and want it? Then inspect all six; revise visible defects. A valid mesh or nominal parameter does not prove the requested dimension: measure the actual exported interfaces. Use cad_check_fit on a model and reference STL with an explicit rigid transform; report raw-scan interference and minimum gap. Calipers are authoritative but disagreement with a scan is unresolved measurement evidence, not permission to silently rescale it. Check assembly/insertion paths and actual articulated poses, not sums of local joint limits or reference points alone. Printing, clearance under load, supports and motion need separate evidence.
389
+ The result includes paths, millimetre bounds/size, mesh and STEP volumes, solid count, watertight/manifold/winding/STEP checks, bodies (closest approach between solids, contact with the print plate at Z = 0, labelled bodies that are not one solid), problems, checked and not_checked, six orthographic renders (front, back, left, right, top, bottom), a perspective view from the front right and above, and a contact sheet with the perspective view large beside the six. Fix every entry in problems before selecting a result; an empty problems list proves nothing listed in not_checked. After every cad_run, Read its perspective view (renders.perspective, as the result's next says) before the next cad_run or any other change: a run you have not looked at tells you nothing about the form. Judge the form from the perspective view first: would a person recognise the product and want it? Then inspect all six; revise visible defects. Before the final run, list what the views show is wrong against the bought product you named (for a scan, the object in its photos), and fix each one or report it. To get a number out of a design (a spring force, a strain, a clearance you derived), print() it in the script: the result returns it as printed, with no need to make a run fail. A valid mesh or nominal parameter does not prove the requested dimension: measure the actual exported interfaces. Use cad_check_fit on a model and reference STL with an explicit rigid transform; report raw-scan interference and minimum gap. Calipers are authoritative but disagreement with a scan is unresolved measurement evidence, not permission to silently rescale it. Check assembly/insertion paths and actual articulated poses, not sums of local joint limits or reference points alone. Printing, clearance under load, supports and motion need separate evidence.
380
390
  Fit, flexure and thread parameters: put each interface's nominal size, its source (measured, published, or assumed), the print correction, and the design fit in P as separate named values, so a fit report revises one number without resending the script. Model every dimension you claim: a parameter the geometry never uses (a wallet or case width that no cut or wall reads) is a defect; use it or remove it. Shape flexures so their bending lies in the layer plane of the exported print orientation, with the stroke, preload, and hard-stop gap as P values; build the stopped pose as well as the rest pose when checking. Model printed threads as explicit coarse geometry with the same pitch on both sides and clearance as a radial P offset; never scale a screw to clear its hole.
381
391
  Check insertion and articulated poses with cad_check_fit against each object state that matters (the bare product, the product in its case, and the case with its attachment as its own reference envelope), including the widest section on the way in. Report interference and minimum gap per state. In your summary, attach each "fits", "holds", and "prints without supports" claim to the check or slice number that shows it; a valid flag alone shows none of them. Apply fdm_design and fdm_slicing too. When a part meets a real object apply fdm_fit, and when it flexes, grips, snaps or springs apply fdm_flexures: if they were not attached, read them with the design_guidance tool before choosing that fit or spring. Never invoke a printer as part of constructing CAD.`,
382
392
  };
@@ -1,4 +1,5 @@
1
1
  """Bag-sealing clip: two hinged bars, ridge into groove, snap latch, printed in place
2
+ Use for: closing a bag of food or sealing film; any clip with two hinged bars and a latch
2
3
  Pattern: bar cross-section drawn in YZ and extruded along the bar; revolved waisted pin in a C-socket; ridge and its offset as the groove; modelled SHUT, then one bar swung open for printing
3
4
  Modelled on: Linden Sweden Twixit! bag clip (https://www.webstaurantstore.com/linden-sweden-411-8-twixit-blue-4-1-4-pastry-bag-clips-pack/534411.8.html); mechanism as in the hinged-bar clip patent US 4656697, Naslund (https://patents.google.com/patent/US4656697)
4
5
  Published sizes used: 108 mm (4 1/4 in) = overall length (retailer, https://www.webstaurantstore.com/linden-sweden-411-8-twixit-blue-4-1-4-pastry-bag-clips-pack/534411.8.html); nothing else is published, the other sizes are design choices
@@ -1,4 +1,5 @@
1
1
  """Pocket clicker: a bistable double curved beam in a closed frame
2
+ Use for: a fidget or clicker; any part that must snap between two stable positions
2
3
  Pattern: a computed 2D curve (cosine beam from a formula) made into a face, extruded flat with a filleted frame round it
3
4
  Modelled on: the double curved-beam bistable mechanism of Qiu, Lang and Slocum, "A curved-beam bistable mechanism", J. Microelectromechanical Systems 13(2), 2004, pp. 137-146 (https://manuscript.isc.ac/Inventory/49/950908.htm)
4
5
  Published sizes used: bistability ratio rise / thickness must exceed about 2.31 for a cosine beam clamped at both ends with its twisting mode blocked (Qiu, Lang and Slocum 2004, URL above); here rise / thickness = 3.0. All other sizes are design choices.
@@ -0,0 +1,61 @@
1
+ """Wall-mounted spring grip for a broom or mop handle (one screw, snap-in C with flared lips)
2
+ Use for: storing a broom, mop, rake, torch or any round handle or pipe 19 to 29 mm thick on a wall or inside a cupboard door; any snap-in spring clip that grips a round bar
3
+ Pattern: sweep one rounded section round the handle's axis for the C ring; pad and lip beads as simple bodies chamfered before they are joined; one countersunk screw through the seat, reached through the mouth
4
+ Modelled on: National Hardware spring grip clips for handles (https://www.doitbest.com/product/222143/national-rust-resistant-spring-grip-clip-hook-222143/); screw is SPAX 4.0 mm flat countersunk (https://www.ahlsell.se/en/products/mounting/wood-screw/wood-screw-spax/71333788---traskruv-tft-spax-svart-4.0x25h-200fp-eta-120114)
5
+ Published sizes used: 3/4 to 1 1/8 in (19 to 28.6 mm) = handle diameters the bought steel clip takes (retailer listing, first URL); 4.0 mm = screw thread, 8.0 mm = head diameter, 2.4 mm = head height (SPAX listing, second URL); ring, wall and mouth sizes are design choices
6
+ Concept: A clip on the wall that a broom handle is pushed into and pulled out of with one hand. Frame: the wall is the plane y = 0 and the mouth faces away from it, towards -y (the front view). The handle spreads two arms as it passes the mouth and they close behind it; the ring is made 1 mm smaller than the handle so it keeps squeezing and the broom does not slide down. The bought clip is spring steel; plastic arms must be longer and thicker to do the same job, so the ring wraps 230 degrees and the arms are 4 lines (1.68 mm) thick: opening the 20 mm mouth to a 25 mm handle strains them about 2 percent, and the script prints that figure for whatever sizes it is given. Round beads on the lips guide the handle in and are kind to its paint. The screw sits in the seat, where the handle covers it, and pulls the pad flat to the wall. It is printed with the C outline on the bed, the handle's axis upright, so the arms bend within their layers; printed lying on the pad they would split along a layer the first time. No supports. PETG (PLA arms creep open in a warm cupboard), 4 walls.
7
+ What makes this good: it is sized as a spring, not as a bracket, with the strain worked out in the script, and the one screw is hidden under the handle.
8
+ """
9
+ from math import acos, asin, degrees, radians
10
+
11
+ from build123d import *
12
+
13
+ P = {
14
+ "handle_d": 25.0, # the handle it grips (inside the published 19 to 28.6 mm range)
15
+ "squeeze": 1.0, # ring is this much smaller than the handle, so it grips
16
+ "mouth": 20.0, # gap between the beads, 80% of the handle
17
+ "arm_t": 1.68, # ring wall: 4 lines of 0.42, thin enough to spring
18
+ "bead_r": 1.6, # round bead on the end of each arm: lead-in outside, retaining bump inside
19
+ "pad_over": 1.0, # the pad stands this far above the seat; lower leaves more arm free to bend
20
+ "height": 22.0, # along the handle = height off the bed as printed
21
+ "pad_w": 34.0, # wall pad width
22
+ "pad_t": 5.0, # wall to the seat; leaves 2.6 mm under the screw head
23
+ "screw_d": 4.0, # screw thread diameter (published)
24
+ "screw_head_d": 8.0, # head diameter (published)
25
+ "screw_head_h": 2.4, # head height (published)
26
+ "screw_clear": 0.5,
27
+ "edge": 0.8, # softening of the ring's, beads' and pad's edges
28
+ }
29
+
30
+
31
+ def build():
32
+ h, e = P["height"], P["edge"]
33
+ r_in = (P["handle_d"] - P["squeeze"]) / 2
34
+ r_mid = r_in + P["arm_t"] / 2
35
+ yc = P["pad_t"] + r_in # ring centre: the seat is pad_t from the wall
36
+ half = degrees(asin((P["mouth"] / 2 + P["bead_r"]) / r_mid)) # half the mouth angle: the beads end up `mouth` apart
37
+ up = (Align.CENTER, Align.CENTER, Align.MIN)
38
+
39
+ # each piece is a simple body with its own softened edges, then they are joined: an outline chamfered after the
40
+ # union fails here. The ring is one section swept round the handle's axis, open at the mouth.
41
+ arc = Pos(0, yc, h / 2) * CenterArc((0, 0), r_mid, 90 + half, 360 - 2 * half)
42
+ ring = sweep(Plane(arc @ 0, x_dir=(0, 0, 1), z_dir=arc % 0) * RectangleRounded(h, P["arm_t"], e), path=arc)
43
+ bead = Cylinder(P["bead_r"], h, align=up)
44
+ bead = chamfer(bead.edges(), e) # lead-in outside the arm, retaining bump inside it
45
+ pad_y = P["pad_t"] + P["pad_over"]
46
+ pad = Pos(0, pad_y / 2, 0) * Box(P["pad_w"], pad_y, h, align=up)
47
+ pad = fillet(pad.edges().filter_by(Axis.Z).filter_by_position(Axis.Y, 1, 99), 3.0) # round the two front corners in plan
48
+ pad = chamfer(pad.edges().group_by(Axis.Z)[0] + pad.edges().group_by(Axis.Z)[-1], e)
49
+ grip = ring + pad + [Pos(arc @ u) * Pos(0, 0, -h / 2) * bead for u in (0, 1)]
50
+ grip -= Pos(0, yc, 0) * Cylinder(r_in, h, align=up) # the seat, cleared through the pad
51
+
52
+ # the spring, worked out: each arm is a cantilever from where the ring leaves the pad round to its bead,
53
+ # and the handle pushes each bead out by half of (handle - mouth)
54
+ free = radians(180 - half) - acos((r_in - P["pad_over"]) / (r_in + P["arm_t"]))
55
+ strain = 1.5 * P["arm_t"] * (P["handle_d"] - P["mouth"]) / 2 / (r_mid * free) ** 2
56
+ print(f"arm strain while the handle passes the mouth: {100 * strain:.1f} % (keep to about 2 % for PETG)")
57
+
58
+ hole_r, head_r = (P["screw_d"] + P["screw_clear"]) / 2, (P["screw_head_d"] + P["screw_clear"]) / 2
59
+ screw = Cylinder(hole_r, 4 * P["pad_t"]) + Cone(hole_r, head_r, P["screw_head_h"], align=(Align.CENTER, Align.CENTER, Align.MAX)) \
60
+ + Cylinder(head_r, 6, align=(Align.CENTER, Align.CENTER, Align.MIN)) # head recess clear up into the seat
61
+ return Rot(0, 0, 180) * (grip - Pos(0, P["pad_t"], h / 2) * Rot(-90, 0, 0) * screw) # mouth towards the front view
@@ -1,4 +1,5 @@
1
1
  """Adhesive desk cable clip (single cable, snap-in C channel on a taped pad)
2
+ Use for: holding one cable, cord or charger lead on a desk, wall or bedside; any small stick-on snap-in clip
2
3
  Pattern: sweep a rounded (slot) section along an arc for the C ring + loft the pad up into it, fillet the lip tips
3
4
  Modelled on: 3M Command Clear Round Cord Clips 17017CLR (https://argo.webstaurantstore.com/3m-command-8482-7100027385-clear-round-cord-clips-pack/39917017CLRES.html)
4
5
  Published sizes used: 13/16 in (20.6 mm) = clip width, 1/2 in (12.7 mm) = clip depth (retailer, URL above); cable diameter, mouth and wall are design choices
@@ -1,4 +1,5 @@
1
1
  """Chainmail patch: rigid square links that pass through each other, printed in place
2
+ Use for: flexible printed fabric, a strap or a mat made of linked rigid pieces
2
3
  Pattern: one link made from a rounded ring with two box cuts (two bars stay on the bed, two become bridges), then copied on a grid as a Compound of separate solids
3
4
  Modelled on: NASA/JPL "space fabric" (https://www.jpl.nasa.gov/news/space-fabric-links-fashion-and-engineering) and Ed Nisley's printable chain mail (https://softsolder.com/2014/12/04/3d-printed-chain-mail-armor-cosplay-edition/)
4
5
  Published sizes used: 2.4 mm = bar width, 6 threads of 0.40 mm (maker, https://softsolder.com/2014/12/04/3d-printed-chain-mail-armor-cosplay-edition/); JPL publishes no sizes; the other sizes are design choices