@rulecad/cad 0.7.77 → 0.7.80

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.
package/lib/live.mjs CHANGED
@@ -103,10 +103,10 @@ function plot() {
103
103
  ys.forEach((v, k) => { const x = k / (n - 1) * w, y = h - 8 - (v - lo) / (hi - lo || 1) * (h - 28); k ? c.lineTo(x, y) : c.moveTo(x, y); });
104
104
  c.stroke();
105
105
  };
106
- line(history.compliance, false, '#6cf'); line(history.change, true, '#fc6');
106
+ line(history.compliance, false, '#6cf'); if (history.change.length) line(history.change, true, '#fc6');
107
107
  const x = shown / (n - 1) * w; c.strokeStyle = '#fff8'; c.lineWidth = 1; c.beginPath(); c.moveTo(x, 0); c.lineTo(x, h); c.stroke();
108
108
  c.font = '12px system-ui'; c.fillStyle = '#6cf'; c.fillText('compliance, N·mm: ' + fig(history.compliance[0]) + ' to ' + fig(history.compliance.at(-1)), 8, 14);
109
- c.fillStyle = '#fc6'; c.textAlign = 'right'; c.fillText('change (log scale): ' + fig(history.change[0]) + ' to ' + fig(history.change.at(-1)), w - 8, 14); c.textAlign = 'left';
109
+ if (history.change.length) { c.fillStyle = '#fc6'; c.textAlign = 'right'; c.fillText('change (log scale): ' + fig(history.change[0]) + ' to ' + fig(history.change.at(-1)), w - 8, 14); c.textAlign = 'left'; }
110
110
  }
111
111
  // The 3D view's step: remembered, so the 3D script picks it up when it loads (it loads after the first steps arrive)
112
112
  const want3d = (n, grid) => { window.wanted3d = [n, grid]; window.model3d?.(n, grid); };
@@ -189,6 +189,56 @@ window.model3d = (n, grid) => { if (!box.hidden && grid) load(n, grid); };
189
189
  if (window.wanted3d) window.model3d(...window.wanted3d);
190
190
  </script>`;
191
191
 
192
+ /**
193
+ * A run kept to watch again: each step's densities (as the live view draws them) and its numbers, recorded as the
194
+ * optimiser goes, then written as one page that needs no server: the live view's own page, its steps read from the
195
+ * file. A 3D run shows its three views (the turning surface needs the live view's server).
196
+ * @returns {{ step: (s: object) => void, steps: () => number, page: (title: string, done: string) => string }}
197
+ */
198
+ export function recorder() {
199
+ const frames = [], history = { compliance: [], change: [] }, t0 = Date.now(), times = [];
200
+ return {
201
+ step(s) {
202
+ const now = Date.now(); times.push(now);
203
+ const last = times.slice(-11), perStep = last.length > 1 ? (last.at(-1) - last[0]) / (last.length - 1) / 1000 : null, { nx, ny, nz, h } = s.grid;
204
+ frames.push({ index: frames.length, grid: { nx, ny, nz, h }, step: s.step, steps: s.steps, compliance: s.compliance, change: s.change, beta: s.beta, volume: s.volume, stress: s.stress, travel: s.travel,
205
+ elapsed: (now - t0) / 1000, perStep, views: views(s.density, s.grid).map((v) => ({ ...v, image: Buffer.from(v.image).toString('base64') })) });
206
+ history.compliance.push(s.compliance); history.change.push(s.change);
207
+ },
208
+ steps: () => frames.length,
209
+ page: (title, done) => replay(title, { history, frames, done }),
210
+ };
211
+ }
212
+
213
+ /**
214
+ * The page of a run that wasn't recorded step by step (made by a design's build, or before runs were kept): its end
215
+ * alone, with the compliance of each step where the result has it.
216
+ * @param {string} title @param {{ grid: object, density: ArrayLike<number>, history?: number[], steps: number, compliance: number }} r @param {string} done
217
+ */
218
+ export function endOnly(title, r, done) {
219
+ const { nx, ny, nz, h } = r.grid;
220
+ const frame = { index: Math.max(0, (r.history?.length || 1) - 1), grid: { nx, ny, nz, h }, step: r.steps, steps: r.steps, compliance: r.compliance, change: 0, beta: '', elapsed: r.seconds ?? null, perStep: null,
221
+ views: views(r.density, r.grid).map((v) => ({ ...v, image: Buffer.from(v.image).toString('base64') })) };
222
+ return replay(title, { history: { compliance: r.history?.length ? r.history : [r.compliance], change: [] }, frames: [frame], done });
223
+ }
224
+
225
+ // The live view's page with its server's two answers read from the run instead: the stream of steps (one message: the
226
+ // whole history, the last step and how it ended) and any step asked for (the nearest one kept at or before it). Long
227
+ // runs keep every few steps, so the page stays under about 8 MB.
228
+ function replay(title, { history, frames, done }) {
229
+ const size = frames.reduce((t, f) => t + f.views.reduce((u, v) => u + v.image.length, 0), 0), every = Math.max(1, Math.ceil(size / 8e6));
230
+ const kept = frames.filter((f, k) => k % every === 0 || k === frames.length - 1);
231
+ const run = JSON.stringify({ history, frames: kept, done }).replace(/</g, '\\u003c');
232
+ const shim = `<script>
233
+ const RUN = ${run};
234
+ window.EventSource = class { constructor() { setTimeout(() => this.onmessage?.({ data: JSON.stringify({ about: [['Recorded', 'a run kept to watch again: drag the slider or the chart to any step']], history: RUN.history, frame: RUN.frames.at(-1), done: RUN.done }) }), 0); } close() {} };
235
+ window.fetch = async (u) => { const k = Number(String(u).replace('frame/', '')); let f = RUN.frames[0]; for (const x of RUN.frames) if (x.index <= k) f = x; return { ok: false, json: async () => f }; };
236
+ </script>
237
+ <style>#model,#hint{display:none!important}#stop{display:none}</style>
238
+ `;
239
+ return page(title).split('<script type="importmap">')[0].replace('<script>', `${shim}<script>`);
240
+ }
241
+
192
242
  const THREE = path.dirname(createRequire(import.meta.url).resolve('three')); // three's build files, for the 3D view
193
243
 
194
244
  if (!isMainThread && workerData?.flag) {
package/lib/optimise.mjs CHANGED
@@ -7,12 +7,14 @@
7
7
  import fs from 'node:fs';
8
8
  import path from 'node:path';
9
9
  import crypto from 'node:crypto';
10
+ import { AsyncLocalStorage } from 'node:async_hooks';
10
11
  import { host, readJson } from './host.mjs';
11
12
  import { paths, printerOf } from './workspace.mjs';
12
13
  import { resolve, evaluate } from './rules.mjs';
13
14
  import { located } from './errors.mjs';
14
- import { discretise, optimise, outlines, surface, area, bounds, resultant, printable, refine, despike, undercuts, voids, grey } from '@rulecad/topopt';
15
+ import { discretise, optimise, outlines, surface, area, bounds, resultant, printable, refine, despike, reduce, undercuts, voids, grey } from '@rulecad/topopt';
15
16
  import { islands } from '@rulecad/printcheck';
17
+ import { turn } from '@rulecad/model-link';
16
18
  import { threadsBackend } from '@rulecad/fea/threads'; // the solver's products shared over the machine's cores
17
19
  import { grid as makeGrid, analyse, positions } from '@rulecad/fea';
18
20
 
@@ -25,6 +27,18 @@ export const hasProblem = (project, ref) => host.exists(problemFile(project, Str
25
27
  * @param {string} project @param {string} ref name, or name:variant
26
28
  */
27
29
  export async function readProblem(project, ref) {
30
+ // The problems being read above this one, each with the design it reads that is built from the next: a problem met
31
+ // again on that chain is refused by name, since each would need the other's result before its own could be made
32
+ const name = String(ref).split(':')[0], chain = reading.getStore() || [], key = `${project}/${name}`;
33
+ if (chain.some((c) => c.key === key)) {
34
+ const from = chain.slice(chain.findIndex((c) => c.key === key)), steps = from.map((c, i) => `${c.name} reads ${c.object}, built from ${(from[i + 1] || { name })?.name}`);
35
+ throw new Error(`${name}.json: problems read each other through designs built from them: ${steps.join(', then ')}. Fix one of them to a part or anchor of a design that is not made from the others`);
36
+ }
37
+ const link = { key, name, object: null };
38
+ return reading.run([...chain, link], () => readOne(project, ref, link));
39
+ }
40
+ const reading = new AsyncLocalStorage();
41
+ async function readOne(project, ref, link) {
28
42
  const [name, variant] = String(ref).split(':'), file = problemFile(project, name);
29
43
  if (!host.exists(file)) throw new Error(`no problem "${name}" (projects/${project}/problems/${name}.json)`);
30
44
  const p = readJson(file);
@@ -37,27 +51,67 @@ export async function readProblem(project, ref) {
37
51
  if (typeof v !== 'number') throw new Error(`${path.basename(file)}: "${n}" isn't a number here (variables: ${Object.keys(p.variables || {}).join(', ')})`);
38
52
  return v;
39
53
  };
40
- const ev = (x) => evaluate(x, lookup), pt = (a) => a.map(ev);
54
+ const ev = (x) => evaluate(x, lookup), pt = (a) => a.map(ev), flat = p.thickness != null;
55
+ // Another design in the project, built once with its defaults, for its parts and anchors. One whose default is built
56
+ // from this very problem is refused: it would need the result before the result could be made.
57
+ const designs = new Map();
58
+ const design = (object, what) => { // (the build kept as it starts: regions are read side by side)
59
+ if (!designs.has(object)) designs.set(object, (async () => {
60
+ const { build, locate, readObject } = await import('./design.mjs'), d = locate(`${project}/${object}`);
61
+ const own = Object.entries(readObject(d).variables || {}).find(([, v]) => v.type === 'problem' && String(v.value).split(':')[0] === name);
62
+ if (own) throw new Error(`${path.basename(file)}: ${what} is on ${object}, which is built from this problem (its variable ${own[0]}): name a part or anchor of what it is fixed to instead`);
63
+ const chain = reading.getStore(); // this problem's place on the chain names the design it reads
64
+ return reading.run([...chain.slice(0, -1), { ...link, object }], () => build(d));
65
+ })());
66
+ return designs.get(object);
67
+ };
41
68
  // A named part of another design in the project, as triangles (built with its defaults)
42
69
  const parts = new Map();
43
70
  const part = async (ref) => {
44
71
  if (!parts.has(ref)) {
45
- const [object, partName] = ref.split('.'), { build, locate } = await import('./design.mjs');
46
- const b = await build(locate(`${project}/${object}`)), found = partName ? b.parts.find((q) => q.name === partName) : b.parts.find((q) => q.role !== 'support');
72
+ const [object, partName] = ref.split('.'), b = await design(object, `the part "${ref}"`);
73
+ const found = partName ? b.parts.find((q) => q.name === partName) : b.parts.find((q) => q.role !== 'support');
47
74
  if (!found) throw new Error(`${path.basename(file)}: ${object} has no part "${partName}" (parts: ${b.parts.map((q) => q.name).join(', ')})`);
48
75
  parts.set(ref, found.triangles);
49
76
  }
50
77
  return parts.get(ref);
51
78
  };
79
+ // An anchor of another design (object.anchor): where it is and its axis, in that design's frame, worked out from its
80
+ // values as built. A region at an anchor follows the design: move the anchor, and the problem (and its result) moves.
81
+ const anchors = new Map();
82
+ const anchor = async (ref) => {
83
+ if (!anchors.has(ref)) {
84
+ const [object, a, ...more] = String(ref).split('.');
85
+ if (!object || !a || more.length) throw new Error(`${path.basename(file)}: name an anchor as <object>.<anchor> (got "${ref}")`);
86
+ const b = await design(object, `the anchor "${ref}"`), spec = b.object.anchors?.[a];
87
+ if (!spec) throw new Error(`${path.basename(file)}: ${object} has no anchor "${a}" (anchors: ${Object.keys(b.object.anchors || {}).join(', ') || 'none'})`);
88
+ const num = (x) => evaluate(x, (n) => {
89
+ const v = n.split('.').reduce((o, k) => (o == null ? o : o[k]), b.values);
90
+ if (typeof v !== 'number') throw new Error(`${path.basename(file)}: the anchor "${ref}" reads "${n}", which isn't one of ${object}'s numbers`);
91
+ return v;
92
+ });
93
+ // Its axis is its z, as an assembly reads it: turned by its rotate (degrees about x, then y, then z) where it has one
94
+ const m = spec.rotate && turn(spec.rotate.map(num)), axis = m ? [m[2], m[6], m[10]].map((c) => (Math.abs(c) < 1e-12 ? 0 : c)) : (spec.axis || [0, 0, 1]).map(num);
95
+ anchors.set(ref, { anchor: ref, at: (spec.at || [0, 0, 0]).map(num), axis });
96
+ }
97
+ return anchors.get(ref);
98
+ };
52
99
  // The build direction: a direction ('+z'), or a variable holding one
53
100
  const overhang = p.overhang ? (typeof values[p.overhang] === 'string' ? values[p.overhang] : p.overhang) : null;
54
101
  // A teardrop's point: a direction, or up or down the build direction (+z, as drawn, when it's free)
55
102
  const point = (t) => { const up = overhang && overhang !== 'none' ? overhang : '+z'; return t === 'up' ? up : t === 'down' ? (up[0] === '-' ? '+' : '-') + up[1] : t; };
56
103
  const region = async (r) => {
104
+ if (r.anchor) { // at an anchor: its place (x and y in a flat problem), and a cylinder along the anchor's axis unless it names one
105
+ if (r.at) throw new Error(`${path.basename(file)}: a region at an anchor ("${r.anchor}") takes no at: the anchor places it`);
106
+ const a = await anchor(r.anchor), along = a.axis.map((c) => Math.abs(c) > 1e-9);
107
+ if (r.length != null && !r.axis && along.filter(Boolean).length !== 1) throw new Error(`${path.basename(file)}: the anchor "${r.anchor}" points along [${a.axis.map((c) => round(c, 3)).join(', ')}], not along x, y or z: give the cylinder an axis`);
108
+ return region({ ...r, anchor: undefined, at: flat ? a.at.slice(0, 2) : a.at, ...(r.length != null && !r.axis ? { axis: 'xyz'[along.indexOf(true)] } : {}) });
109
+ }
57
110
  if (r.part) { // with where it is (its box's centre), for a load's or support's resultant
58
111
  const triangles = await part(r.part), lo = [Infinity, Infinity, Infinity], hi = [-Infinity, -Infinity, -Infinity];
59
112
  for (const t of triangles) for (const q of t) for (let a = 0; a < 3; a++) { lo[a] = Math.min(lo[a], q[a]); hi[a] = Math.max(hi[a], q[a]); }
60
- return { triangles, part: r.part, at: lo.map((x, a) => (x + hi[a]) / 2) };
113
+ const at = lo.map((x, a) => (x + hi[a]) / 2);
114
+ return flat ? { triangles, part: r.part, at: at.slice(0, 2), flat: true } : { triangles, part: r.part, at }; // flat: its section halfway up
61
115
  }
62
116
  if (r.points) return { points: r.points.map(pt) };
63
117
  if (r.size) return { at: pt(r.at), size: r.size.map(ev) };
@@ -67,14 +121,17 @@ export async function readProblem(project, ref) {
67
121
  const regions = (list) => Promise.all([list || []].flat().map(region));
68
122
  const m = values[p.material];
69
123
  if (typeof m?.modulus !== 'number' || typeof m?.poisson !== 'number') throw new Error(`material ${p.material}: its rule set needs modulus (MPa) and poisson`);
70
- const space = await regions(p.space), dim = space[0].triangles || space[0].length != null || (space[0].size || space[0].at)?.length === 3 ? 3 : 2;
124
+ // The filter's radius is about the thinnest member: a cell and a half unless the problem gives one, and never under two
125
+ // of the printer's lines, the thinnest wall it lays solid (so it only binds on cells under 0.56 mm on a 0.42 mm line)
126
+ const printer = printerOf(project), line = printer ? resolve({ uses: [printer] }).values[printer]?.line : null, lines = typeof line === 'number' ? 2 * line : 0;
127
+ const space = await regions(p.space), dim = flat ? 2 : space[0].triangles || space[0].length != null || (space[0].size || space[0].at)?.length === 3 ? 3 : 2;
71
128
  const problem = {
72
129
  space, keep: await regions(p.keep), avoid: await regions(p.avoid),
73
130
  supports: await Promise.all(p.supports.map(async (s) => ({ ...(await region(s)), fix: s.fix || 'xyz'.slice(0, dim) }))),
74
131
  loads: await Promise.all(p.loads.map(async (l) => ({ ...(await region(l)), force: pt(l.force), case: l.case || 'load' }))),
75
132
  cases: Object.fromEntries(Object.entries(p.cases || {}).map(([k, w]) => [k, ev(w)])),
76
- material: { E: m.modulus, nu: m.poisson }, ...(dim === 2 ? { thickness: ev(p.thickness) } : {}), cell: ev(p.cell), ...(p.volume != null ? { volume: ev(p.volume) } : {}), ...(p.stress != null ? { stress: ev(p.stress) } : {}),
77
- ...(p.filter != null ? { filter: ev(p.filter) } : {}), ...(p.penal != null ? { penal: ev(p.penal) } : {}),
133
+ material: { E: m.modulus, nu: m.poisson }, ...(dim === 2 ? { thickness: ev(p.thickness) } : {}), cell: ev(p.cell), ...(p.volume != null ? { volume: ev(p.volume) } : {}), ...(p.stress != null ? { stress: ev(p.stress) } : {}), ...(p.strain != null ? { strain: ev(p.strain) } : {}),
134
+ ...(p.filter != null ? { filter: ev(p.filter) } : lines > ev(p.cell) * 1.5 ? { filter: lines } : {}), ...(p.penal != null ? { penal: ev(p.penal) } : {}),
78
135
  ...(p.projection != null ? { projection: p.projection } : {}), ...(p.steps != null ? { steps: p.steps } : {}),
79
136
  ...(overhang && overhang !== 'none' ? { overhang } : {}),
80
137
  // How it's made other than printed: milled from a side, cast in a mould; symmetric, extruded (topopt's filters)
@@ -85,12 +142,17 @@ export async function readProblem(project, ref) {
85
142
  ...(p.input_spring != null ? { input_spring: ev(p.input_spring) } : {}),
86
143
  };
87
144
  if (dim === 2 && !(problem.thickness > 0)) throw new Error(`${path.basename(file)}: a flat (2D) problem needs a thickness`);
88
- const outline = { smooth: p.outline?.smooth ?? 4, minArea: p.outline?.min_area != null ? ev(p.outline.min_area) : problem.cell ** 2 * 2, fine: p.outline?.fine != null ? ev(p.outline.fine) : 1.25 }; // fine: the cells a printable solid is cleaned and drawn on, mm (its own cells if smaller)
145
+ const outline = { smooth: p.outline?.smooth ?? 4, minArea: p.outline?.min_area != null ? ev(p.outline.min_area) : problem.cell ** 2 * 2, fine: p.outline?.fine != null ? ev(p.outline.fine) : 1.25, ...(p.outline?.reduce != null ? { reduce: ev(p.outline.reduce) } : {}) }; // fine: the cells a printable solid is cleaned and drawn on, mm (its own cells if smaller)
89
146
  // A printable solid's surface is kept within the printer's overhang limit too (smoothing can tip faces past it)
90
147
  // (outline.tip: faces the smoothing left steeper than the limit are tipped back to it too; off unless asked, since
91
148
  // tipped corners leave dips that slice as islands, and the layers step out no further for it)
92
149
  if (dim === 3 && problem.overhang) { const n = printerOf(project), pr = resolve({ uses: [n] }).values[n]; outline.overhang = { up: problem.overhang, angle: pr?.overhang ?? 45, bridge: pr?.bridge ?? 5, layer: pr?.layer ?? 0.2, line: pr?.line ?? 0.42, ...(p.outline?.tip ? { tip: true } : {}) }; problem.bridge = outline.overhang.bridge; } // (the optimiser bridges half that)
93
- return { ref, name, variant, file, dim, title: p.title || name, material: { name: p.material, ...m }, problem, outline, critical: !!p.critical, voids: p.voids || 'allowed' };
150
+ // What the result is made from, for cad why: the rule sets, the problem's own values, the parts and anchors of other
151
+ // designs it reads, and where its filter came from
152
+ const inputs = { uses, variables: Object.fromEntries(Object.keys(p.variables || {}).map((k) => [k, values[k]])), ...(variant ? { set: p.variants[variant] } : {}),
153
+ parts: [...parts.keys()].sort(), anchors: [...anchors.values()].sort((a, b) => (a.anchor < b.anchor ? -1 : 1)).map(({ anchor: a, at }) => ({ anchor: a, at: at.map((c) => round(c, 4)) })),
154
+ filter: p.filter != null ? { value: problem.filter, from: `the problem: ${p.filter}` } : problem.filter ? { value: problem.filter, from: `two of ${printer}'s lines (2 × ${line} mm), more than a cell and a half` } : { value: round(problem.cell * 1.5), from: 'a cell and a half' } };
155
+ return { ref, name, variant, file, dim, title: p.title || name, material: { name: p.material, ...m }, problem, outline, critical: !!p.critical, inputs, voids: p.voids || 'allowed' };
94
156
  }
95
157
 
96
158
  /**
@@ -220,8 +282,14 @@ export async function optimised(project, ref, { onStep, onRun, fresh = false } =
220
282
  }
221
283
  }
222
284
  const anchors = [...r.problem.supports, ...r.problem.loads, ...(r.problem.keep || [])].map(bounds);
223
- const { vertices, faces, dropped } = anchored(best, anchors, (fine ?? { grid: spec.grid }).grid.h);
224
- return { mesh: { vertices: vertices.map((v) => v.map((c) => round(c, 3))), faces }, solid: meshVolume(vertices, faces), iso, ...(dropped.length ? { dropped } : {}), ...(emptied.get(iso) ? { emptied: emptied.get(iso) } : {}), ...(cleared ? { cleared } : {}) };
285
+ let { vertices, faces, dropped } = anchored(best, anchors, (fine ?? { grid: spec.grid }).grid.h), reduced = null;
286
+ // Fewer triangles, if asked: within outline.reduce mm of the surface as drawn, closed, and no more overhang or tips
287
+ if (r.outline.reduce != null) {
288
+ const { nx, ny, nz, h } = spec.grid, lo = spec.origin, hi = [lo[0] + nx * h, lo[1] + ny * h, lo[2] + nz * h], before = faces.length;
289
+ ({ vertices, faces } = reduce({ vertices, faces }, { tolerance: r.outline.reduce, lo, hi, ...(ov ? { overhang: { up: ov.up, angle: ov.angle } } : {}) }));
290
+ reduced = { before, after: faces.length, tolerance: r.outline.reduce };
291
+ }
292
+ return { mesh: { vertices: vertices.map((v) => v.map((c) => round(c, 3))), faces }, solid: meshVolume(vertices, faces), iso, ...(reduced ? { reduced } : {}), ...(dropped.length ? { dropped } : {}), ...(emptied.get(iso) ? { emptied: emptied.get(iso) } : {}), ...(cleared ? { cleared } : {}) };
225
293
  })();
226
294
  const result = {
227
295
  problem: ref, title: r.title, hash, dim: r.dim, material: r.material.name, ...(r.dim === 2 ? { thickness: r.problem.thickness } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/cad",
3
- "version": "0.7.77",
3
+ "version": "0.7.80",
4
4
  "description": "The cad command: JSCAD designs from traceable rules, checked for printing and fit, versioned by what fits, shared as links and exported as Bambu 3MF.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -58,18 +58,18 @@
58
58
  "url": "https://github.com/JoniBach/rulecad/issues"
59
59
  },
60
60
  "dependencies": {
61
- "@rulecad/variables": "^0.3.5",
61
+ "@rulecad/variables": "^0.3.6",
62
62
  "@rulecad/keyboard-layout": "^0.1.2",
63
63
  "@rulecad/printcheck": "^0.3.3",
64
64
  "@rulecad/fit": "^0.4.0",
65
65
  "@rulecad/model-link": "^0.3.2",
66
66
  "@rulecad/versions": "^0.1.6",
67
- "@rulecad/shapes": "^0.4.6",
68
- "@rulecad/rules": "^0.3.22",
67
+ "@rulecad/shapes": "^0.4.8",
68
+ "@rulecad/rules": "^0.3.23",
69
69
  "@jscad/modeling": "^2.12.0",
70
70
  "three": "^0.186.1",
71
- "@rulecad/fea": "^0.2.11",
72
- "@rulecad/topopt": "^0.3.4",
71
+ "@rulecad/fea": "^0.2.14",
72
+ "@rulecad/topopt": "^0.3.6",
73
73
  "@rulecad/flexures": "^0.5.4",
74
74
  "@rulecad/gears": "^0.3.4",
75
75
  "@rulecad/motors": "^0.1.6",
@@ -29,7 +29,7 @@
29
29
  "power": { "type": "object", "additionalProperties": false, "properties": { "margin": { "type": "number" } } },
30
30
  "wires": { "type": "array", "description": "Wires between anchors, their length measured through every pose", "items": { "type": "object", "required": ["from", "to"], "additionalProperties": false, "properties": { "id": { "type": "string" }, "from": { "type": "string" }, "to": { "type": "string" }, "via": { "type": "array", "items": { "anyOf": [{ "type": "string" }, { "type": "object", "required": ["along", "from", "to"], "additionalProperties": false, "description": "A run along a beam's slot: the wire follows the slot from one distance to another, held by printed cable clips at a pitch", "properties": { "along": { "type": "string", "description": "A beam's slotted face: rail.top" }, "from": { "$ref": "#/$defs/expr", "description": "mm from the beam's end a" }, "to": { "$ref": "#/$defs/expr" }, "pitch": { "$ref": "#/$defs/expr", "description": "The most between clips, mm (default 100)" }, "cable": { "$ref": "#/$defs/expr", "description": "The bundle the clips hold, mm (default 6)" } } }] }, "description": "Anchors, path joints or runs along a slot that the wire is routed by" }, "gauge": { "type": "string", "description": "awg22" }, "colour": { "type": "string" }, "conductors": { "type": "number" }, "connectors": { "type": "array", "items": { "type": "string" } }, "current": { "type": "number", "description": "A: else a motor's rated current at either end, or a signal's" }, "note": { "type": "string" } } } },
31
31
  "gravity": { "$ref": "#/$defs/vec3", "description": "Which way down is, for masses in loads (default [0, 0, -1])" },
32
- "frame": { "type": "object", "additionalProperties": false, "description": "The frame: what it is (a generator, kind with inside or outside, which expands into beams, joins and their ends before anything is built, as cad frame --expand writes out), and how its beams and joins are solved for frame.deflection, frame.stress, frame.buckling, frame.rack and frame.frequency, which beams could be printed (beam.printable), and how it is cut and heated for frame.square and frame.heat. Left out, it stands on its feet: the beam ends that carry a foot, a levelling foot, a castor plate or a stacking foot, or else the lowest beam ends, each held from moving (pinned)", "properties": {"kind": {"enum": ["box", "portal", "table", "gantry", "shelf"], "description": "A frame generated from a size: box (four posts and a ring of beams at the bottom and top), portal (two legs and a beam across: inside and outside are [width, height]; it lies in one plane and tips over on its feet alone, so it is refused until supports says its feet are held down, as z1.a and z2.a fixed), table (four legs and a ring at the top), gantry (a box without its top beams across, and a beam riding along the two top side beams on a sliding joint) or shelf (a box with rings between, shelves of them). Its beams are z1 .. (upright), x1 .. and y1 .. (along x and y, by ring from the bottom), g (a gantry's moving beam); its corner arrangement follows the join"}, "inside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The clear volume the frame encloses, [width (x), depth (y), height (z)] in mm (a portal: [width, height]); the beams go round it. Give inside or outside"}, "outside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The volume the whole frame must fit in, [width, depth, height] in mm (a portal: [width, height]); the beams go within it"}, "profile": {"type": "string", "description": "Every beam's profile, a square one (2020-misumi-hfs5, 3030-generic, 4040-item-8)"}, "join": {"description": "How the beams meet at each corner: a kind (blind, end-tap, bracket, gusset, hidden, anchor: the upright beams run through and the others butt against their faces, each shorter by the profile's width at each end; cube: every beam butts into a corner node, each as long as the inside), or { kind, fitting, screw } as a join takes them", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["kind"], "properties": {"kind": {"type": "string"}, "fitting": {"type": "string"}, "screw": {"type": "string"}}}]}, "feet": {"type": ["string", "null"], "description": "What stands under the upright beams' lower ends: foot, levelling, castor or stacking (printed), or a bought foot's set by name (fitting-motedis-foot-m6-d19); left out, an end cap"}, "caps": {"type": ["string", "boolean"], "description": "The ends no join covers: printed end caps (true, the default), a bought end cap's set by name, or false for none (join.end then names them)"}, "braces": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "The upright sides whose corners are stiffened against racking: each join in that side becomes a bracket join with a printed corner bracket in the corner, on drop-in nuts"}, "panels": {"type": "object", "additionalProperties": false, "required": ["sheet", "thickness"], "description": "Panels closing the upright sides, each cut to its bay with its clips (a box, a shelf, a gantry's two sides)", "properties": {"sheet": {"type": "string", "description": "The sheet's material: acrylic, polycarbonate, aluminium, plywood, mdf"}, "thickness": {"$ref": "#/$defs/expr", "description": "mm"}, "sides": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "Which sides (default every side that has a bay)"}}}, "shelves": {"type": "integer", "minimum": 1, "maximum": 20, "description": "A shelf: how many rings stand between the bottom and the top, spacing its height into equal clear bays (default 1)"}, "supports": {"type": "object", "description": "Where the frame is held, by beam end (\"z1.a\") or a place on a beam (\"x1.bottom@50%\"): pinned holds it from moving and lets it turn, fixed holds it from turning too, resting holds it from moving and from twisting about the beam's own length (a beam lying across a round bar, as the beam coupon does; for a beam along x, y or z). Given, these are the only supports", "additionalProperties": {"enum": ["pinned", "fixed", "resting"]}}, "limit": {"$ref": "#/$defs/expr", "description": "The sag allowed in every frame.deflection finding, in mm: at each load's point, each named point and along each guide whose rail gives no parallelism of its own (default: the task's accuracy, else the span of the beam it is on over 360)"}, "points": {"type": "array", "description": "Places on beams to report the sag at, beside each load's point and every guide (\"x1.top@50%\")", "items": {"type": "string"}}, "cut": {"type": "object", "additionalProperties": false, "description": "How the beams are cut in this workshop, where it differs from the profile's set and the kit's defaults: frame.square, frame.cut and the cut list read it", "properties": {"tolerance": {"$ref": "#/$defs/expr", "description": "How far a cut length may be from the length asked, either way, in mm (default: the profile's cut_tolerance, else 0.5)"}}}, "heat": {"type": "object", "additionalProperties": false, "description": "frame.heat: the temperatures the frame works at. The beams grow with the air in the enclosure; each printed fitting is held to its plastic's softening point", "properties": {"air": {"$ref": "#/$defs/expr", "description": "The air round the frame when it runs, in degrees C (inside its enclosure)"}, "built": {"$ref": "#/$defs/expr", "description": "The air it was built and squared in, in degrees C (default 20)"}, "heaters": {"type": "array", "description": "Hot things near the frame: what is within reach of one is taken at its temperature", "items": {"type": "object", "required": ["at", "temperature", "reach"], "additionalProperties": false, "properties": {"name": {"type": "string"}, "at": {"$ref": "#/$defs/vec3", "description": "Its middle, in the assembly's frame, mm"}, "temperature": {"$ref": "#/$defs/expr", "description": "Degrees C at its surface"}, "reach": {"$ref": "#/$defs/expr", "description": "How far from its middle a part is taken at that temperature, mm"}}}}}}, "printed": {"description": "beam.printable: each beam tried printed in this plastic (the kit's printable profile of its size, lying down or standing up), the frame solved again and held to its own limits: its sags, stress, buckling, creep and lowest mode; the beams that can be printed are listed, and printed together solved once more. A plastic's set by name (\"petg\"), or how it prints", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["material"], "properties": {"material": {"type": "string", "description": "The plastic's set: pla, petg"}, "walls": {"type": "integer", "minimum": 1, "description": "Walls round every outline, in lines (3)"}, "infill": {"type": "number", "minimum": 0, "maximum": 1, "description": "The share of the inside the infill fills (0.4)"}, "pose": {"enum": ["lying", "standing"], "description": "Only this way up (both are tried where left out)"}}}]}, "size": {"type": "object", "additionalProperties": false, "description": "frame.size: each group of beams that must match given the lightest profile from a list that meets the frame's own limits (the sag at each load, point and guide, each beam's stress and buckling with frame.margin to spare, and the lowest mode against the task's moves), solved in every pose; a table of each group's profile, the limit that set it and its margin, and cad frame --size --write writes the profiles in", "properties": {"profiles": {"type": "array", "minItems": 1, "items": {"type": "string"}, "description": "The profiles to choose from, by set (default MISUMI's HFS5, HFS6 and HFS8 series from 2020 to 4080). One that is not square is tried lying as drawn and turned a quarter. Choose one family whose joins fit each other: the join checks of the written frame say where they do not"}, "groups": {"type": "object", "description": "Beams that must take one profile, by group name (\"rails\": [\"x1\", \"x2\"]); the rest are grouped by themselves: one profile, one direction, lengths within 0.5 mm", "additionalProperties": {"type": "array", "minItems": 1, "items": {"type": "string"}}}, "limits": {"type": "object", "additionalProperties": false, "description": "Limits in place of the frame checks' own", "properties": {"deflection": {"$ref": "#/$defs/expr", "description": "The sag allowed at every load, named point and guide, mm"}, "stress": {"$ref": "#/$defs/expr", "description": "How many times under its alloy's strength each beam stays (default frame.margin, 2)"}, "buckling": {"$ref": "#/$defs/expr", "description": "How many times its load the frame, and each grouped beam by Euler's load, must carry before it buckles (default frame.margin, 2)"}, "frequency": {"$ref": "#/$defs/expr", "description": "The lowest mode's floor, Hz (default twice what the task's moves shake it at; none without a task)"}}}, "by": {"enum": ["mass", "cost"], "description": "What is made least (mass: no profile set in the kit gives a price per metre yet)"}}}, "rack": {"type": "object", "additionalProperties": false, "description": "frame.rack: the side push at the frame's top and the sway allowed", "properties": {"load": {"$ref": "#/$defs/expr", "description": "The side push in N, shared among the top corners (default 20, an estimate)"}, "limit": {"$ref": "#/$defs/expr", "description": "The sway allowed at the top, in mm (default: the task's accuracy, else the height over 400)"}}}} },
32
+ "frame": { "type": "object", "additionalProperties": false, "description": "The frame: what it is (a generator, kind with inside or outside, which expands into beams, joins and their ends before anything is built, as cad frame --expand writes out), and how its beams and joins are solved for frame.deflection, frame.stress, frame.buckling, frame.rack and frame.frequency, which beams could be printed (beam.printable), and how it is cut and heated for frame.square and frame.heat. Left out, it stands on its feet: the beam ends that carry a foot, a levelling foot, a castor plate or a stacking foot, or else the lowest beam ends, each held from moving (pinned)", "properties": {"kind": {"enum": ["box", "portal", "table", "gantry", "shelf"], "description": "A frame generated from a size: box (four posts and a ring of beams at the bottom and top), portal (two legs and a beam across: inside and outside are [width, height]; it lies in one plane and tips over on its feet alone, so it is refused until supports says its feet are held down, as z1.a and z2.a fixed), table (four legs and a ring at the top), gantry (a box without its top beams across, and a beam riding along the two top side beams on a sliding joint) or shelf (a box with rings between, shelves of them). Its beams are z1 .. (upright), x1 .. and y1 .. (along x and y, by ring from the bottom), g (a gantry's moving beam); its corner arrangement follows the join"}, "inside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The clear volume the frame encloses, [width (x), depth (y), height (z)] in mm (a portal: [width, height]); the beams go round it. Give inside or outside"}, "outside": {"type": "array", "minItems": 2, "maxItems": 3, "items": {"$ref": "#/$defs/expr"}, "description": "The volume the whole frame must fit in, [width, depth, height] in mm (a portal: [width, height]); the beams go within it"}, "profile": {"type": "string", "description": "Every beam's profile, a square one (2020-misumi-hfs5, 3030-generic, 4040-item-8)"}, "join": {"description": "How the beams meet at each corner: a kind (blind, end-tap, bracket, gusset, hidden, anchor: the upright beams run through and the others butt against their faces, each shorter by the profile's width at each end; cube: every beam butts into a corner node, each as long as the inside), or { kind, fitting, screw } as a join takes them", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["kind"], "properties": {"kind": {"type": "string"}, "fitting": {"type": "string"}, "screw": {"type": "string"}}}]}, "feet": {"type": ["string", "null"], "description": "What stands under the upright beams' lower ends: foot, levelling, castor or stacking (printed), or a bought foot's set by name (fitting-motedis-foot-m6-d19); left out, an end cap"}, "caps": {"type": ["string", "boolean"], "description": "The ends no join covers: printed end caps (true, the default), a bought end cap's set by name, or false for none (join.end then names them)"}, "braces": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "The upright sides whose corners are stiffened against racking: each join in that side becomes a bracket join with a printed corner bracket in the corner, on drop-in nuts"}, "panels": {"type": "object", "additionalProperties": false, "required": ["sheet", "thickness"], "description": "Panels closing the upright sides, each cut to its bay with its clips (a box, a shelf, a gantry's two sides)", "properties": {"sheet": {"type": "string", "description": "The sheet's material: acrylic, polycarbonate, aluminium, plywood, mdf"}, "thickness": {"$ref": "#/$defs/expr", "description": "mm"}, "sides": {"type": "array", "items": {"enum": ["front", "back", "left", "right"]}, "description": "Which sides (default every side that has a bay)"}}}, "shelves": {"type": "integer", "minimum": 1, "maximum": 20, "description": "A shelf: how many rings stand between the bottom and the top, spacing its height into equal clear bays (default 1)"}, "supports": {"type": "object", "description": "Where the frame is held, by beam end (\"z1.a\") or a place on a beam (\"x1.bottom@50%\"): pinned holds it from moving and lets it turn, fixed holds it from turning too, resting holds it from moving and from twisting about the beam's own length (a beam lying across a round bar, as the beam coupon does; for a beam along x, y or z). Given, these are the only supports, and at least one is named", "minProperties": 1, "additionalProperties": {"enum": ["pinned", "fixed", "resting"]}}, "limit": {"$ref": "#/$defs/expr", "description": "The sag allowed in every frame.deflection finding, in mm: at each load's point, each named point and along each guide whose rail gives no parallelism of its own (default: the task's accuracy, else the span of the beam it is on over 360)"}, "points": {"type": "array", "description": "Places on beams to report the sag at, beside each load's point and every guide (\"x1.top@50%\")", "items": {"type": "string"}}, "cut": {"type": "object", "additionalProperties": false, "description": "How the beams are cut in this workshop, where it differs from the profile's set and the kit's defaults: frame.square, frame.cut and the cut list read it", "properties": {"tolerance": {"$ref": "#/$defs/expr", "description": "How far a cut length may be from the length asked, either way, in mm (default: the profile's cut_tolerance, else 0.5)"}}}, "heat": {"type": "object", "additionalProperties": false, "description": "frame.heat: the temperatures the frame works at. The beams grow with the air in the enclosure; each printed fitting is held to its plastic's softening point", "properties": {"air": {"$ref": "#/$defs/expr", "description": "The air round the frame when it runs, in degrees C (inside its enclosure)"}, "built": {"$ref": "#/$defs/expr", "description": "The air it was built and squared in, in degrees C (default 20)"}, "heaters": {"type": "array", "description": "Hot things near the frame: what is within reach of one is taken at its temperature", "items": {"type": "object", "required": ["at", "temperature", "reach"], "additionalProperties": false, "properties": {"name": {"type": "string"}, "at": {"$ref": "#/$defs/vec3", "description": "Its middle, in the assembly's frame, mm"}, "temperature": {"$ref": "#/$defs/expr", "description": "Degrees C at its surface"}, "reach": {"$ref": "#/$defs/expr", "description": "How far from its middle a part is taken at that temperature, mm"}}}}}}, "printed": {"description": "beam.printable: each beam tried printed in this plastic (the kit's printable profile of its size, lying down or standing up), the frame solved again and held to its own limits: its sags, stress, buckling, creep and lowest mode; the beams that can be printed are listed, and printed together solved once more. A plastic's set by name (\"petg\"), or how it prints", "oneOf": [{"type": "string"},{"type": "object", "additionalProperties": false, "required": ["material"], "properties": {"material": {"type": "string", "description": "The plastic's set: pla, petg"}, "walls": {"type": "integer", "minimum": 1, "description": "Walls round every outline, in lines (3)"}, "infill": {"type": "number", "minimum": 0, "maximum": 1, "description": "The share of the inside the infill fills (0.4)"}, "pose": {"enum": ["lying", "standing"], "description": "Only this way up (both are tried where left out)"}}}]}, "size": {"type": "object", "additionalProperties": false, "description": "frame.size: each group of beams that must match given the lightest profile from a list that meets the frame's own limits (the sag at each load, point and guide, each beam's stress and buckling with frame.margin to spare, and the lowest mode against the task's moves), solved in every pose; a table of each group's profile, the limit that set it and its margin, and cad frame --size --write writes the profiles in", "properties": {"profiles": {"type": "array", "minItems": 1, "items": {"type": "string"}, "description": "The profiles to choose from, by set (default MISUMI's HFS5, HFS6 and HFS8 series from 2020 to 4080). One that is not square is tried lying as drawn and turned a quarter. A design is only tried where every join of a grouped beam still goes together (a blind join's screw and button head in the other beam's slot, an end-tap's cap head on its far face, a bought fitting on both profiles); the join checks of the written frame hold the rest"}, "groups": {"type": "object", "description": "Beams that must take one profile, by group name (\"rails\": [\"x1\", \"x2\"]); the rest are grouped by themselves: one profile, one direction, lengths within 0.5 mm", "additionalProperties": {"type": "array", "minItems": 1, "items": {"type": "string"}}}, "limits": {"type": "object", "additionalProperties": false, "description": "Limits in place of the frame checks' own", "properties": {"deflection": {"$ref": "#/$defs/expr", "description": "The sag allowed at every load, named point and guide, mm"}, "stress": {"$ref": "#/$defs/expr", "description": "How many times under its alloy's strength each beam stays (default frame.margin, 2)"}, "buckling": {"$ref": "#/$defs/expr", "description": "How many times its load the frame, and each grouped beam by Euler's load, must carry before it buckles (default frame.margin, 2)"}, "frequency": {"$ref": "#/$defs/expr", "description": "The lowest mode's floor, Hz (default twice what the task's moves shake it at; none without a task)"}, "rack": {"$ref": "#/$defs/expr", "description": "The sway allowed at the frame's top under frame.rack's side push alone, each way across, mm: racking as a limit (default frame.rack's own limit where the assembly gives frame.rack; none otherwise)"}}}, "by": {"enum": ["mass", "cost"], "description": "What is made least (mass: no profile set in the kit gives a price per metre yet)"}}}, "rack": {"type": "object", "additionalProperties": false, "description": "frame.rack: the side push at the frame's top and the sway allowed", "properties": {"load": {"$ref": "#/$defs/expr", "description": "The side push in N, shared among the top corners (default 20, an estimate)"}, "limit": {"$ref": "#/$defs/expr", "description": "The sway allowed at the top, in mm (default: the task's accuracy, else the height over 400)"}}}} },
33
33
  "loads": { "type": "array", "description": "What the assembly has to do: a torque (N m) or force (N) on a joint, or a mass (kg) carried at an anchor", "items": { "type": "object", "additionalProperties": false, "properties": { "joint": { "type": "string" }, "torque": { "$ref": "#/$defs/expr" }, "force": { "$ref": "#/$defs/expr" }, "mass": { "$ref": "#/$defs/expr" }, "at": { "$ref": "#/$defs/anchorRef" }, "note": { "type": "string" } } } },
34
34
  "poses": { "type": "object", "description": "Named sets of joint values ({ \"hinge\": 90 }), and of items' variables (\"action.travel\": 25: a flexure drawn bent in that pose, printed as drawn)", "additionalProperties": { "type": "object", "additionalProperties": { "$ref": "#/$defs/values" } } },
35
35
  "printInPlace": { "type": "array", "minItems": 2, "items": { "type": "string" }, "description": "Items printed together as one object printed in place (\"printInPlace\": true on it): they come off the bed together, so the assembly order never takes them apart from each other" },
@@ -58,11 +58,15 @@
58
58
  },
59
59
  "stress": {
60
60
  "$ref": "#/$defs/expr",
61
- "description": "A limit on von Mises stress (MPa), such as \"pla.strength / 3\": the lightest layout that keeps every cell under it (Senhora et al. 2020). Give this or a volume"
61
+ "description": "A limit on von Mises stress (MPa), such as \"pla.strength / 3\": the lightest layout that keeps every cell under it (Senhora et al. 2020). Give this or a volume. A mechanism (with output) fills its volume as before and is checked against the limit at its input force: its peak, and the input force and output travel that reach the limit"
62
+ },
63
+ "strain": {
64
+ "$ref": "#/$defs/expr",
65
+ "description": "A strain limit in place of stress, a share of the length (0.02 is 2%), such as \"pla.strength / pla.modulus / 2\": the stress limit is it times the material's modulus. Most use for a mechanism, whose hinges bend"
62
66
  },
63
67
  "filter": {
64
68
  "$ref": "#/$defs/expr",
65
- "description": "Filter radius, mm: about the thinnest member (default 1.5 cells)"
69
+ "description": "Filter radius, mm: about the thinnest member (default a cell and a half, and never under two of the printer's lines)"
66
70
  },
67
71
  "penal": {
68
72
  "$ref": "#/$defs/expr",
@@ -144,6 +148,10 @@
144
148
  "tip": {
145
149
  "type": "boolean",
146
150
  "description": "3D with an overhang direction: faces the smoothing left steeper than the printer's limit are tipped back to it as well (off by default: tipped corners can leave dips that slice as islands, and the sliced overhang is no smaller for it; the bracket example's 160 mm² of lean is the same either way)"
151
+ },
152
+ "reduce": {
153
+ "$ref": "#/$defs/expr",
154
+ "description": "3D: fewer triangles, the surface kept within this many mm of where it was drawn (0.1 is a quarter of a print line), closed, and no more overhang or tips than it had. Off unless given"
147
155
  }
148
156
  }
149
157
  },
@@ -197,7 +205,6 @@
197
205
  "type": "object",
198
206
  "additionalProperties": false,
199
207
  "required": [
200
- "at",
201
208
  "direction"
202
209
  ],
203
210
  "description": "A mechanism's output: where it should move, along one axis, against a spring. The first load is then the input.",
@@ -206,6 +213,11 @@
206
213
  "$ref": "#/$defs/point",
207
214
  "description": "The centre, mm"
208
215
  },
216
+ "anchor": {
217
+ "type": "string",
218
+ "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$",
219
+ "description": "In place of at: another design's anchor, object.anchor, where it is as that design is built (x and y of it in a flat problem). A cylinder lies along the anchor's axis unless it names one. Move the anchor and the problem moves with it. A design built from this problem can't be named: name what it's fixed to"
220
+ },
209
221
  "r": {
210
222
  "$ref": "#/$defs/expr"
211
223
  },
@@ -243,7 +255,19 @@
243
255
  "label": {
244
256
  "type": "string"
245
257
  }
246
- }
258
+ },
259
+ "anyOf": [
260
+ {
261
+ "required": [
262
+ "at"
263
+ ]
264
+ },
265
+ {
266
+ "required": [
267
+ "anchor"
268
+ ]
269
+ }
270
+ ]
247
271
  },
248
272
  "input_spring": {
249
273
  "$ref": "#/$defs/expr",
@@ -273,6 +297,11 @@
273
297
  "$ref": "#/$defs/point",
274
298
  "description": "The centre, mm: [x, y] in 2D, [x, y, z] in 3D"
275
299
  },
300
+ "anchor": {
301
+ "type": "string",
302
+ "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$",
303
+ "description": "In place of at: another design's anchor, object.anchor, where it is as that design is built (x and y of it in a flat problem). A cylinder lies along the anchor's axis unless it names one. Move the anchor and the problem moves with it. A design built from this problem can't be named: name what it's fixed to"
304
+ },
276
305
  "r": {
277
306
  "$ref": "#/$defs/expr",
278
307
  "description": "A circle's or ball's radius, or a cylinder's"
@@ -308,7 +337,7 @@
308
337
  },
309
338
  "part": {
310
339
  "type": "string",
311
- "description": "3D: a named part of another design in the project, as it's built: object.part"
340
+ "description": "A named part of another design in the project, as it's built: object.part. In a flat (2D) problem, its section halfway up (a plate's outline, its holes open)"
312
341
  },
313
342
  "label": {
314
343
  "type": "string"
@@ -337,6 +366,11 @@
337
366
  "$ref": "#/$defs/point",
338
367
  "description": "The centre, mm: [x, y] in 2D, [x, y, z] in 3D"
339
368
  },
369
+ "anchor": {
370
+ "type": "string",
371
+ "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$",
372
+ "description": "In place of at: another design's anchor, object.anchor, where it is as that design is built (x and y of it in a flat problem). A cylinder lies along the anchor's axis unless it names one. Move the anchor and the problem moves with it. A design built from this problem can't be named: name what it's fixed to"
373
+ },
340
374
  "r": {
341
375
  "$ref": "#/$defs/expr",
342
376
  "description": "A circle's or ball's radius, or a cylinder's"
@@ -372,7 +406,7 @@
372
406
  },
373
407
  "part": {
374
408
  "type": "string",
375
- "description": "3D: a named part of another design in the project, as it's built: object.part"
409
+ "description": "A named part of another design in the project, as it's built: object.part. In a flat (2D) problem, its section halfway up (a plate's outline, its holes open)"
376
410
  },
377
411
  "label": {
378
412
  "type": "string"
@@ -408,6 +442,11 @@
408
442
  "$ref": "#/$defs/point",
409
443
  "description": "The centre, mm: [x, y] in 2D, [x, y, z] in 3D"
410
444
  },
445
+ "anchor": {
446
+ "type": "string",
447
+ "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$",
448
+ "description": "In place of at: another design's anchor, object.anchor, where it is as that design is built (x and y of it in a flat problem). A cylinder lies along the anchor's axis unless it names one. Move the anchor and the problem moves with it. A design built from this problem can't be named: name what it's fixed to"
449
+ },
411
450
  "r": {
412
451
  "$ref": "#/$defs/expr",
413
452
  "description": "A circle's or ball's radius, or a cylinder's"
@@ -443,7 +482,7 @@
443
482
  },
444
483
  "part": {
445
484
  "type": "string",
446
- "description": "3D: a named part of another design in the project, as it's built: object.part"
485
+ "description": "A named part of another design in the project, as it's built: object.part. In a flat (2D) problem, its section halfway up (a plate's outline, its holes open)"
447
486
  },
448
487
  "label": {
449
488
  "type": "string"
@@ -482,6 +521,11 @@
482
521
  "required": [
483
522
  "stress"
484
523
  ]
524
+ },
525
+ {
526
+ "required": [
527
+ "strain"
528
+ ]
485
529
  }
486
530
  ]
487
531
  }
@@ -27,6 +27,8 @@
27
27
  "properties": {
28
28
  "value": { "type": ["number", "string", "array"], "minItems": 1, "items": { "type": ["number", "string"] }, "description": "A number, an expression, text, or a list of numbers or expressions in the rule's one unit (the lengths a screw is sold in)" },
29
29
  "unit": { "type": "string" },
30
+ "low": { "type": "number", "description": "The lowest it is found at, in the rule's unit (a printed plastic's, which varies with the printer and the spool): at most the value" },
31
+ "high": { "type": "number", "description": "The highest it is found at, in the rule's unit: at least the value" },
30
32
  "rule": { "type": "string" },
31
33
  "kind": { "type": "string", "description": "How far to trust it, most to least: measured, spec, community, default, derived, estimate" },
32
34
  "source": { "type": "string" },