@rulecad/cad 0.7.56 → 0.7.57
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/AGENTS.md +57 -0
- package/CHANGELOG.md +41 -0
- package/EXAMPLES.md +363 -1
- package/README.md +336 -5
- package/TUTORIAL.md +2 -0
- package/bin/cad.mjs +35 -11
- package/lib/assembly.mjs +69 -16
- package/lib/beams.mjs +2 -2
- package/lib/bought.mjs +41 -5
- package/lib/buildpage.mjs +8 -3
- package/lib/edit.mjs +10 -4
- package/lib/fasten.mjs +255 -45
- package/lib/fittings.mjs +271 -0
- package/lib/framebuild.mjs +407 -0
- package/lib/frames.mjs +4 -3
- package/lib/guides.mjs +354 -0
- package/lib/jigs.mjs +237 -0
- package/lib/joins.mjs +259 -0
- package/lib/list.mjs +22 -6
- package/lib/loads.mjs +9 -2
- package/lib/measured.mjs +64 -17
- package/lib/motors.mjs +7 -3
- package/lib/order.mjs +19 -11
- package/lib/panels.mjs +220 -0
- package/lib/plates.mjs +11 -4
- package/lib/services.mjs +132 -0
- package/lib/slotnuts.mjs +159 -0
- package/lib/task.mjs +4 -2
- package/lib/wires.mjs +2 -1
- package/package.json +4 -4
- package/schemas/assembly.schema.json +27 -5
package/lib/services.mjs
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// A machine's services on its frame (@rulecad/frames' services.mjs): a bought board or supply with "mount" sits on a
|
|
2
|
+
// printed mount at an address on a beam's slotted face, its holes read from its own rule set,
|
|
3
|
+
// { "id": "psu", "bought": "supply-24v", "variant": "LRS-50-24", "mount": { "on": "rail.top@200" } }
|
|
4
|
+
// and a wire may run along a beam's slot, held by printed cable clips at a pitch,
|
|
5
|
+
// "via": [{ "along": "rail.top", "from": 20, "to": 380, "pitch": 100 }]
|
|
6
|
+
// Before the items are built, each mount is added as a fitting item with its fastens (into the slot, and into or
|
|
7
|
+
// through the device) and the device placed on it; each run's clips are added at their places along the slot and the
|
|
8
|
+
// wire routed through them, so its length follows the beam. Units: mm.
|
|
9
|
+
import { beamAnchor, runClips, SERVICE_DEFAULTS } from '@rulecad/frames';
|
|
10
|
+
import { beamOf, framesContext } from './beams.mjs';
|
|
11
|
+
import { fittingModel } from './fittings.mjs';
|
|
12
|
+
import { boughtSets } from './bought.mjs';
|
|
13
|
+
|
|
14
|
+
const MOUNT_KEYS = ['on', 'turn', 'offset', 'standoff', 'load', 'nut', 'head', 'screw'];
|
|
15
|
+
const RUN_KEYS = ['along', 'from', 'to', 'pitch', 'cable'];
|
|
16
|
+
const shown = (v) => (v === undefined ? 'nothing' : JSON.stringify(v));
|
|
17
|
+
const mm = (x) => String(+Number(x).toFixed(2)), r3 = (x) => +x.toFixed(3);
|
|
18
|
+
|
|
19
|
+
// a slotted place on a beam by its face's name (top, top.2) and the beam's model, refused by name
|
|
20
|
+
function slotPlace(what, id, B, name) {
|
|
21
|
+
const q = B.places.find((x) => x.name === name || (x.face === name && x.index === 1));
|
|
22
|
+
if (!q) throw new Error(`${what}: ${id} has no face "${name}": it has ${[...new Set(B.places.map((x) => x.face))].join(', ')}`);
|
|
23
|
+
if (!q.slot) throw new Error(`${what}: ${id}'s ${name} face is closed: a mount or a clip goes into a slot`);
|
|
24
|
+
return q;
|
|
25
|
+
}
|
|
26
|
+
// the face a fitting is drawn for: top, or top.2 where the face has two slots
|
|
27
|
+
const faceOf = (B, q) => (B.places.filter((x) => x.face === q.face).length > 1 ? q.name : q.face);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An assembly's mounts and slot runs worked out before its items are built: each bought item with "mount" placed on a
|
|
31
|
+
* printed device mount at its address, the mount's screws into the slot and the device's screws as fastens; each wire's
|
|
32
|
+
* run along a slot as cable clips at a pitch, the wire routed through them. Refused by name: a mount on what is not a
|
|
33
|
+
* bought board or supply, an item with both at and mount, an address that is not on a slotted face of a beam, a run past
|
|
34
|
+
* a beam's end, and what @rulecad/frames refuses.
|
|
35
|
+
* @param {object} a the assembly as read @param {(x: any) => number} num @param {object} [context] framesContext()'s @param {string} [material]
|
|
36
|
+
* @returns {{ a: object, mounts: object[], runs: object[] }}
|
|
37
|
+
*/
|
|
38
|
+
export function expandServices(a, num, context = framesContext(), material = 'pla') {
|
|
39
|
+
const items = a.items || [], mounted = items.filter((it) => it.mount != null), runs0 = (a.wires || []).some((w) => (w.via ?? []).some((v) => v && typeof v === 'object'));
|
|
40
|
+
if (!mounted.length && !runs0) return { a, mounts: [], runs: [] };
|
|
41
|
+
const beams = new Map(items.filter((it) => it.beam).map((it) => [it.id, it])), ids = new Set(items.map((it) => it.id)), models = new Map();
|
|
42
|
+
const modelOf = (id) => { if (!models.has(id)) models.set(id, beamOf(beams.get(id), num, context).model); return models.get(id); };
|
|
43
|
+
const free = (base) => { let n = base, k = 2; while (ids.has(n)) n = `${base}-${k++}`; ids.add(n); return n; };
|
|
44
|
+
const beamOfAddress = (what, ref, key) => {
|
|
45
|
+
const s = String(ref ?? ''), i = s.indexOf('.');
|
|
46
|
+
if (i < 0) throw new Error(`${what}: ${key} is a beam's slotted face${key === 'on' ? ' and a distance, as rail.top@200' : ', as rail.top'} (got ${shown(ref)})`);
|
|
47
|
+
const id = s.slice(0, i), rest = s.slice(i + 1);
|
|
48
|
+
if (!beams.has(id)) throw new Error(`${what}: ${key} names a beam item of this assembly, and ${id} is ${items.some((x) => x.id === id) ? 'not a beam' : 'not an item'} (beams: ${[...beams.keys()].join(', ') || 'none'})`);
|
|
49
|
+
return { id, rest, B: modelOf(id) };
|
|
50
|
+
};
|
|
51
|
+
const added = [], fasten = [], fits = [], mounts = [], runs = [], plates = [], replaced = new Map(), ahead = new Map();
|
|
52
|
+
for (const it of mounted) {
|
|
53
|
+
const what = `item ${it.id}`, M = it.mount;
|
|
54
|
+
if (!M || typeof M !== 'object' || Array.isArray(M)) throw new Error(`${what}: mount is { "on": "rail.top@200" }, an address on a beam's slotted face (got ${shown(M)})`);
|
|
55
|
+
for (const k of Object.keys(M)) if (!MOUNT_KEYS.includes(k)) throw new Error(`${what}: a mount has no "${k}": it takes ${MOUNT_KEYS.join(', ')}`);
|
|
56
|
+
if (!it.bought) throw new Error(`${what}: mount holds a bought board or supply by the holes its rule set gives: give "bought"`);
|
|
57
|
+
const part = boughtSets().get(it.bought);
|
|
58
|
+
if (!['board', 'supply', 'encoder'].includes(part)) throw new Error(`${what}: mount holds a bought board or supply, and ${it.bought} is ${part ? `a ${part}` : 'no bought part'}`);
|
|
59
|
+
if (it.at != null || it.rotate != null || it.repeat != null) throw new Error(`${what}: a mounted item is placed by its mount: leave out at, rotate and repeat`);
|
|
60
|
+
const { id: bid, rest, B } = beamOfAddress(what, M.on, 'on'), [face, dist] = rest.split('@');
|
|
61
|
+
if (dist == null) throw new Error(`${what}: on is a beam's face and a distance along it, as ${bid}.${face}@200 (got ${shown(M.on)})`);
|
|
62
|
+
try { beamAnchor(B, rest); } catch (e) { throw new Error(`${what}: on: ${String(e.message).replace(/^beamAnchor: /, '')}`); }
|
|
63
|
+
const q = slotPlace(what, bid, B, face), mid = free(`${it.id}-mount`);
|
|
64
|
+
const spec = { kind: 'device-mount', profile: B.profile.name, face: faceOf(B, q), device: it.bought, ...(it.variant != null ? { variant: it.variant } : {}),
|
|
65
|
+
...(M.turn != null ? { turn: M.turn } : {}), ...(M.offset != null ? { offset: num(M.offset) } : {}), ...(M.standoff != null ? { standoff: num(M.standoff) } : {}), ...(M.load != null ? { load: num(M.load) } : {}),
|
|
66
|
+
...(M.nut != null ? { nut: M.nut } : {}), ...(M.head != null ? { head: M.head } : {}), ...(M.screw != null ? { screw: M.screw } : {}) };
|
|
67
|
+
const m = fittingModel(spec, context, material, what), D = m.device;
|
|
68
|
+
ahead.set(it.id, { id: mid, fitting: spec, at: `${bid}.${rest}`, mountOf: it.id }); // (listed just before its device: of two parts as near the base, the earlier goes on first)
|
|
69
|
+
fasten.push({ screw: `${m.thread} ${m.head}`, through: [mid], into: `${bid}.${q.name}`, at: m.screws.map((_, k) => `${mid}.b${k + 1}`), nut: m.screws[0].nutKind, note: `${it.id}'s mount into ${bid}`, mountOf: it.id });
|
|
70
|
+
const at = D.holes.map((_, k) => `${mid}.d${k + 1}`);
|
|
71
|
+
fasten.push(m.fix === 'tapped'
|
|
72
|
+
? { screw: `${D.thread} ${D.head}`, through: [mid], into: it.id, at, note: `${it.id} on its mount, from under it`, mountOf: it.id }
|
|
73
|
+
: { screw: `${D.thread} ${D.head}`, through: [it.id], into: mid, at, note: `${it.id} on its mount`, mountOf: it.id });
|
|
74
|
+
replaced.set(it.id, { ...it, at: `${mid}.device` });
|
|
75
|
+
// the stretch of the slot its plate covers (either way along, as its outline reaches): a run's clips keep off it
|
|
76
|
+
const reachX = Math.max(...m.outline.map((pt) => Math.abs(pt[0]))), d0 = num(dist), at0 = d0 < 0 ? B.length + d0 : d0;
|
|
77
|
+
plates.push({ mount: mid, item: it.id, beam: bid, slot: q.name, lo: r3(at0 - reachX), hi: r3(at0 + reachX) });
|
|
78
|
+
mounts.push({ id: it.id, mount: mid, beam: bid, on: M.on, set: it.bought, variant: it.variant ?? null, fix: m.fix, holes: D.holes.length, thread: D.thread, length: D.length, grams: m.grams, margin: m.margin });
|
|
79
|
+
}
|
|
80
|
+
// wires: each run along a slot becomes clips, and the wire goes through each clip's cable anchor in turn
|
|
81
|
+
const wires = (a.wires || []).map((w, wi) => {
|
|
82
|
+
if (!(w.via ?? []).some((v) => v && typeof v === 'object')) return w;
|
|
83
|
+
const via = [];
|
|
84
|
+
for (const v of w.via) {
|
|
85
|
+
if (!v || typeof v !== 'object') { via.push(v); continue; }
|
|
86
|
+
const what = `wire ${w.id || wi + 1}`;
|
|
87
|
+
if (Array.isArray(v)) throw new Error(`${what}: a run in via is { "along": "rail.top", "from": 20, "to": 380 } (got ${shown(v)})`);
|
|
88
|
+
for (const k of Object.keys(v)) if (!RUN_KEYS.includes(k)) throw new Error(`${what}: a run along a slot has no "${k}": it takes ${RUN_KEYS.join(', ')}`);
|
|
89
|
+
const { id: bid, rest, B } = beamOfAddress(what, v.along, 'along');
|
|
90
|
+
if (rest.includes('@')) throw new Error(`${what}: along names the face (${bid}.${rest.split('@')[0]}); the run's ends are from and to, in mm from end a`);
|
|
91
|
+
const q = slotPlace(what, bid, B, rest);
|
|
92
|
+
if (v.from == null || v.to == null) throw new Error(`${what}: a run along ${v.along} gives from and to, in mm from ${bid}'s end a`);
|
|
93
|
+
const from = num(v.from), to = num(v.to), L = B.length;
|
|
94
|
+
for (const [k, x] of [['from', from], ['to', to]]) if (!(Number.isFinite(x) && x >= 0 && x <= L)) throw new Error(`${what}: a run's ${k} is from 0 to ${mm(L)} mm along ${bid} (got ${shown(v[k])})`);
|
|
95
|
+
let clips;
|
|
96
|
+
try { clips = runClips(Math.abs(to - from), v.pitch != null ? { pitch: num(v.pitch) } : {}); } catch (e) { throw new Error(`${what}: ${String(e.message).replace(/^runClips: /, '')}`); }
|
|
97
|
+
const sgn = to >= from ? 1 : -1, cable = v.cable != null ? num(v.cable) : SERVICE_DEFAULTS.cable.value, list = [];
|
|
98
|
+
// a mount on the same slot: no clip under its plate; one each side of it instead, and the wire said to go round it
|
|
99
|
+
const cw = fittingModel({ kind: 'cable-clip', profile: B.profile.name, face: faceOf(B, q), cable }, context, material, what).width, keep = cw / 2 + SERVICE_DEFAULTS.gap.value;
|
|
100
|
+
const rlo = Math.min(from, to), rhi = Math.max(from, to), round = plates.filter((pl) => pl.beam === bid && pl.slot === q.name && pl.lo - keep < rhi && pl.hi + keep > rlo).map((pl) => ({ ...pl, lo: r3(pl.lo - keep), hi: r3(pl.hi + keep) }));
|
|
101
|
+
let ds = clips.at.map((s) => r3(from + sgn * s));
|
|
102
|
+
if (round.length) {
|
|
103
|
+
ds = ds.filter((d) => !round.some((pl) => d > pl.lo && d < pl.hi));
|
|
104
|
+
for (const pl of round) for (const e of [pl.lo, pl.hi]) if (e >= rlo - 1e-9 && e <= rhi + 1e-9 && !round.some((o) => e > o.lo + 1e-9 && e < o.hi - 1e-9) && !ds.some((d) => Math.abs(d - e) < cw)) ds.push(e);
|
|
105
|
+
ds.sort((x, y) => sgn * (x - y));
|
|
106
|
+
if (!ds.length) throw new Error(`${what}: a run along ${bid}.${q.name} from ${mm(from)} to ${mm(to)} mm lies under ${round.map((pl) => pl.mount).join(' and ')}: no clip has room there; run it along another face`);
|
|
107
|
+
}
|
|
108
|
+
for (const d of ds) {
|
|
109
|
+
const cid = free(`${w.id || `w${wi + 1}`}-clip`);
|
|
110
|
+
added.push({ id: cid, fitting: { kind: 'cable-clip', profile: B.profile.name, face: faceOf(B, q), cable }, at: `${bid}.${q.name}@${d}`, runOf: w.id || `w${wi + 1}` });
|
|
111
|
+
fits.push({ a: cid, b: bid, fastens: true, note: `${cid}: snapped into ${bid}'s ${q.name} slot, its barbs under the lips` }); // (no screw: its barbs hold it)
|
|
112
|
+
via.push(`${cid}.cable`); list.push(cid);
|
|
113
|
+
}
|
|
114
|
+
runs.push({ wire: w.id || `w${wi + 1}`, along: `${bid}.${q.name}`, from, to, length: r3(Math.abs(to - from)), clips: list, count: list.length, pitch: clips.pitch, round: round.map((pl) => ({ mount: pl.mount, item: pl.item, from: pl.lo, to: pl.hi })), most: v.pitch != null ? num(v.pitch) : SERVICE_DEFAULTS.pitch.value, cable });
|
|
115
|
+
}
|
|
116
|
+
return { ...w, via };
|
|
117
|
+
});
|
|
118
|
+
const out = { ...a, items: [...items.flatMap((it) => [...(ahead.has(it.id) ? [ahead.get(it.id)] : []), replaced.get(it.id) ?? it]), ...added], ...(fasten.length ? { fasten: [...(a.fasten || []), ...fasten] } : {}), ...(runs.length ? { wires } : {}), ...(fits.length ? { fits: [...(a.fits || []), ...fits] } : {}) };
|
|
119
|
+
return { a: out, mounts, runs };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* A built assembly's service findings: service.mount for each mounted device (its set, its holes and screws, the
|
|
124
|
+
* mount's grams and margin) and wire.run for each run along a slot (its length and its clips at their pitch).
|
|
125
|
+
* @param {object} s a built assembly @param {Function} f the findings' sink
|
|
126
|
+
*/
|
|
127
|
+
export function serviceFindings(s, f) {
|
|
128
|
+
for (const m of s.mounts ?? []) f('info', `${m.id}: on a printed mount (${m.mount}) at ${m.on}, held by its ${m.holes} ${m.fix === 'tapped' ? `tapped ${m.thread} holes from ${m.set}'s rule set, screwed up from under the mount` : `holes from ${m.set}'s rule set, ${m.thread} screws down into the mount`}; the mount ${mm(m.grams)} g, ${mm(m.margin)}× its load`, null, { code: 'service.mount', refs: { item: m.id, mount: m.mount, beam: m.beam, set: m.set }, values: { holes: m.holes, length: m.length, grams: m.grams, margin: m.margin } });
|
|
129
|
+
for (const r of s.runs ?? []) f('info', `${r.wire}: ${mm(r.length)} mm along ${r.along} from ${mm(r.from)} to ${mm(r.to)} mm, held by ${r.count} cable clip${r.count > 1 ? 's' : ''} ${r.count > 1 ? (r.round?.length ? `no more than ${mm(r.most)} mm apart but across ${r.round.map((x) => `${x.mount} (${mm(x.to - x.from)} mm, a clip each side)`).join(' and ')},` : `${mm(r.pitch)} mm apart (no more than ${mm(r.most)})`) : ''} for a ${mm(r.cable)} mm bundle`.trimEnd(), null, { code: 'wire.run', refs: { wire: r.wire, along: r.along, clips: r.clips }, values: { length: r.length, clips: r.count, pitch: r.pitch } });
|
|
130
|
+
// a run under a mount's plate: its clips are set either side, and the wire cannot lie in the slot under the plate
|
|
131
|
+
for (const r of s.runs ?? []) for (const x of r.round ?? []) f('warn', `${r.wire}: its run along ${r.along} passes ${x.mount} (${x.item}'s mount) from ${mm(x.from)} to ${mm(x.to)} mm: no clip goes under the plate, so one is set each side of it, and the wire must go round the mount there: run it along another face, or end the run before the mount`, `${r.wire}: round ${x.mount}`, { code: 'wire.run', refs: { wire: r.wire, along: r.along, mount: x.mount, item: x.item }, values: { from: x.from, to: x.to } });
|
|
132
|
+
}
|
package/lib/slotnuts.mjs
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Slot nuts in a frame: what a fasten into a beam's slot (lib/fasten.mjs) asks of the joins round it. A slide-in nut
|
|
2
|
+
// (and a plain square nut) goes into a slot only from an open end of it; a drop-in, roll-in, hammer-head nut or T-bolt
|
|
3
|
+
// goes in through the opening anywhere along it. A slot's end is closed by a join that butts on it (the beam's end
|
|
4
|
+
// meets another beam), or, for the stretch of slot a nut is in, by a blind join's head sitting in that slot between
|
|
5
|
+
// the nut and the end; an item placed at the end (a cap, a foot) closes it too, though it comes off again.
|
|
6
|
+
// frame.nut: the nuts whose stretch of slot joins close at both ends. Once those joins are made a slide-in nut has
|
|
7
|
+
// no way in, so the check fails and names the nut of that thread that goes in through the opening.
|
|
8
|
+
// frame.preload: the nuts with a way in that a join closes and none that stays open (the other end capped): they
|
|
9
|
+
// go into the slot before that join is made. cad order and the build page list them at the step that makes it.
|
|
10
|
+
import { nutFor } from '@rulecad/frames';
|
|
11
|
+
import { framesContext } from './beams.mjs';
|
|
12
|
+
import { givenFor } from './frames.mjs';
|
|
13
|
+
|
|
14
|
+
const mm = (x) => String(+Number(x).toFixed(2)), r3 = (x) => +x.toFixed(3);
|
|
15
|
+
const EPS = 1e-3; // mm: a closure this near a nut is where the nut is, not beside it
|
|
16
|
+
const THROUGH = ['drop-in', 'roll-in', 'hammer', 't-bolt']; // (the kinds that go in through the opening, in the order a stand-in is offered)
|
|
17
|
+
const list = (xs) => (xs.length < 2 ? xs.join('') : `${xs.slice(0, -1).join(', ')} and ${xs.at(-1)}`);
|
|
18
|
+
const an = (t) => (/^(?:[aeiou8]|M\d)/i.test(String(t)) ? 'an' : 'a');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Each fasten's nuts in one slot: the relation, the beam and its slot (place: top.1, as joins name it; named: top, as
|
|
22
|
+
* said where the face has one slot), the nut, its kind and entry, the part it holds, and where along the beam each is.
|
|
23
|
+
* @param {object} s a built assembly
|
|
24
|
+
* @returns {{ rel: object, item: string, place: string, named: string, nut: string, kind: string, entry: string, thread: string, part: string, at: number[], screws: object[] }[]}
|
|
25
|
+
*/
|
|
26
|
+
export function nutGroupsOf(s) {
|
|
27
|
+
const out = new Map();
|
|
28
|
+
for (const rel of s.fastened?.relations ?? []) for (const sc of rel.screws) {
|
|
29
|
+
if (!sc.slot) continue;
|
|
30
|
+
const key = `${rel.index}|${sc.slot.item}|${sc.slot.place}`; // (place: top.1, as joins name it; named: top, as said where the face has one slot)
|
|
31
|
+
if (!out.has(key)) out.set(key, { rel, ...sc.slot, at: [], screws: [] });
|
|
32
|
+
out.get(key).at.push(sc.slot.distance); out.get(key).screws.push(sc);
|
|
33
|
+
}
|
|
34
|
+
return [...out.values()];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* What closes a beam's slot, and where along it: joins at its ends, blind joins' heads in that slot, items at its ends.
|
|
39
|
+
* @param {object} s a built assembly @param {string} item the beam @param {string} place its slot (top.1)
|
|
40
|
+
* @returns {{ at: number, end: string|null, join?: object, head?: boolean, item?: string }[]}
|
|
41
|
+
*/
|
|
42
|
+
export function closuresOf(s, item, place) {
|
|
43
|
+
const L = s.objects.find((o) => o.id === item)?.beam?.length ?? 0, out = [], endAt = (e) => (e === 'a' ? 0 : L);
|
|
44
|
+
for (const j of s.joins ?? []) {
|
|
45
|
+
if (j.items[0] === item) out.push({ at: endAt(j.end[0]), end: j.end[0], join: j });
|
|
46
|
+
if (j.items[1] === item && j.model.b.end) out.push({ at: endAt(j.model.b.end[0]), end: j.model.b.end[0], join: j });
|
|
47
|
+
if (j.items[1] === item && j.kind === 'blind' && j.model.b.place === place) out.push({ at: j.model.b.distance, end: null, join: j, head: true });
|
|
48
|
+
}
|
|
49
|
+
for (const it of s.a.items || []) {
|
|
50
|
+
const m = typeof it.at === 'string' ? /^([\w-]+)\.([ab])(\.|$)/.exec(it.at.trim()) : null;
|
|
51
|
+
if (m && m[1] === item) out.push({ at: endAt(m[2]), end: m[2], item: it.id });
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// The two ways out of a stretch of slot from lo to hi along the beam: every closure toward each end, nearest first (a
|
|
57
|
+
// join before an item where both stand at one place). A way is closed by a join where any closure on it is a join, not
|
|
58
|
+
// only the nearest: a head between the nuts and an end closed further along closes it as much as that end
|
|
59
|
+
function waysOf(s, item, place, lo, hi) {
|
|
60
|
+
const cs = closuresOf(s, item, place), near = (far) => (p, q) => (far ? q.at - p.at : p.at - q.at) || (q.join ? 1 : 0) - (p.join ? 1 : 0);
|
|
61
|
+
const all = { a: cs.filter((c) => c.at < lo - EPS).sort(near(true)), b: cs.filter((c) => c.at > hi + EPS).sort(near(false)) };
|
|
62
|
+
return { a: all.a[0] ?? null, b: all.b[0] ?? null, all, join: { a: all.a.find((c) => c.join) ?? null, b: all.b.find((c) => c.join) ?? null } };
|
|
63
|
+
}
|
|
64
|
+
const closerSays = (g, w) => (w.head ? `the head of the ${w.join.label} at ${mm(w.at)} mm` : w.join ? `${g.item}'s end ${w.end} (the ${w.join.label})` : `${g.item}'s end ${w.end} (${w.item} placed there)`);
|
|
65
|
+
const nutsSay = (g) => `${g.at.length} ${g.kind} nut${g.at.length > 1 ? 's' : ''} (${g.nut})`;
|
|
66
|
+
|
|
67
|
+
// The nut of that thread made for the slot that goes in through its opening: a drop-in first, then the other kinds
|
|
68
|
+
function throughNut(s, g) {
|
|
69
|
+
const b = s.objects.find((o) => o.id === g.item)?.beam;
|
|
70
|
+
for (const kind of THROUGH) { try { return nutFor(b.profile, g.place, g.thread, { kind, given: givenFor(framesContext(), b.profile.name) }); } catch {} }
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The nuts that must be in a slot before a join closes it: slide-in and square nuts whose stretch of slot has no way
|
|
76
|
+
* that stays open, and a way a join closes. @param {object} s a built assembly
|
|
77
|
+
* @returns {{ fasten: number, label: string, item: string, place: string, named: string, part: string, nut: string, count: number, end: string|null, way: string, at: number, join: object, closers: object[], other: object|null, text: string }[]}
|
|
78
|
+
* join: the nearest join on the way the nuts go in; closers: every join on that way, nearest the nuts first (any of them
|
|
79
|
+
* made shuts the way, so the nuts go in before the first of them is made)
|
|
80
|
+
*/
|
|
81
|
+
export function preloadOf(s) {
|
|
82
|
+
const out = [];
|
|
83
|
+
for (const g of nutGroupsOf(s)) {
|
|
84
|
+
if (g.entry !== 'end') continue;
|
|
85
|
+
const w = waysOf(s, g.item, g.place, Math.min(...g.at), Math.max(...g.at));
|
|
86
|
+
if (!w.a || !w.b || (w.join.a && w.join.b) || (!w.join.a && !w.join.b)) continue; // (a way stays open; or joins close both: frame.nut's; or only items placed at the ends do, which go on after the nuts)
|
|
87
|
+
// every join on that way closes it (a head nearer the end as much as the nearest), so the nuts go in before the first
|
|
88
|
+
// made; an item at that end (a foot, a cap) is off until then too
|
|
89
|
+
const way = w.join.a ? 'a' : 'b', other = way === 'a' ? 'b' : 'a', by = w.join[way], ends = w.all[other].filter((c) => c.item), caps = w.all[way].filter((c) => c.item);
|
|
90
|
+
const closers = [...new Map(w.all[way].filter((c) => c.join).map((c) => [c.join.index, c])).values()];
|
|
91
|
+
const end = closers.find((c) => c.end)?.end ?? null, heads = closers.filter((c) => c.head);
|
|
92
|
+
const from = closers.length > 1 || !end ? `from end ${way}${heads.length ? `, past ${list(heads.map((c) => `${mm(c.at)}`).reverse())} mm` : ''}` : `through its end ${end}`;
|
|
93
|
+
const capped = caps.length ? ` (${list(caps.map((c) => c.item))} off until then)` : '';
|
|
94
|
+
const before = closers.length > 1 ? `before the first made of ${list(closers.map((c) => `the ${c.join.label}`).reverse())}, each of which closes that way` : `before the ${by.join.label} closes it`;
|
|
95
|
+
const or = ends.length ? ` (or through end ${other} before ${list(ends.map((c) => c.item))} go${ends.length > 1 ? '' : 'es'} on)` : '';
|
|
96
|
+
const how = `${from}${capped}, ${before}${or}`;
|
|
97
|
+
out.push({ fasten: g.rel.index, label: g.rel.label, item: g.item, place: g.place, named: g.named, part: g.part, nut: g.nut, count: g.at.length, end: by.end, way, at: by.at, join: by.join, closers: closers.map((c) => c.join), other: ends[0] ?? null, how,
|
|
98
|
+
text: `load ${g.at.length} × ${g.nut} into ${g.item}'s ${g.named} slot ${from}${capped}, for ${g.part}, ${before}${or}` });
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The slide-in and square nuts that joins shut in: their stretch of slot closed at both ends by joins (frame.nut's
|
|
105
|
+
* failures), each with the two joins and the nut that goes in through the opening, where there is one.
|
|
106
|
+
* @param {object} s a built assembly
|
|
107
|
+
* @returns {{ fasten: number, label: string, item: string, place: string, named: string, nut: string, kind: string, count: number, part: string, at: number[], joins: object[], alternative: object|null }[]}
|
|
108
|
+
*/
|
|
109
|
+
export function trappedOf(s) {
|
|
110
|
+
const out = [];
|
|
111
|
+
for (const g of nutGroupsOf(s)) {
|
|
112
|
+
if (g.entry !== 'end') continue;
|
|
113
|
+
const w = waysOf(s, g.item, g.place, Math.min(...g.at), Math.max(...g.at));
|
|
114
|
+
if (w.join.a && w.join.b) out.push({ fasten: g.rel.index, label: g.rel.label, item: g.item, place: g.place, named: g.named, nut: g.nut, kind: g.kind, count: g.at.length, part: g.part, at: g.at, joins: [w.join.a.join, w.join.b.join], alternative: throughNut(s, g) });
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* frame.nut and frame.preload, in the assembly's findings shape. @param {object} s a built assembly @param {Function} f the findings' sink
|
|
121
|
+
*/
|
|
122
|
+
export function slotNutChecks(s, f) {
|
|
123
|
+
const groups = nutGroupsOf(s);
|
|
124
|
+
if (!groups.length) return;
|
|
125
|
+
const pre = preloadOf(s);
|
|
126
|
+
for (const g of groups) {
|
|
127
|
+
const lo = Math.min(...g.at), hi = Math.max(...g.at), where = `${g.item}'s ${g.named} slot`, first = g.screws[0];
|
|
128
|
+
const refs = { fasten: g.rel.index, item: g.item, place: g.place, nut: g.nut, kind: g.kind, along: g.at };
|
|
129
|
+
if (g.entry !== 'end') { f('pass', `${g.rel.label}: ${nutsSay(g)} go${g.at.length > 1 ? '' : 'es'} into ${where} through its opening, anywhere along it`, null, { code: 'frame.nut', at: first.at.map(r3), refs }); continue; }
|
|
130
|
+
const w = waysOf(s, g.item, g.place, lo, hi);
|
|
131
|
+
if (w.join.a && w.join.b) {
|
|
132
|
+
const alt = throughNut(s, g), joins = [w.join.a.join.index, w.join.b.join.index];
|
|
133
|
+
f('fail', `${g.rel.label}: ${nutsSay(g)} go${g.at.length > 1 ? '' : 'es'} into ${where} at ${g.at.map(mm).join(' and ')} mm, between ${closerSays(g, w.join.a)} and ${closerSays(g, w.join.b)}, which close it at both ends: a ${g.kind} nut goes in only from an open end. ${alt ? `${alt.name} (${an(alt.thread)} ${alt.thread} ${alt.nutKind} nut) goes in through the opening anywhere: give "nut": "${alt.nutKind}"` : `No ${g.thread} nut made for ${g.slot} goes in through its opening: load these before the later of the two joins, or move them to a slot with an open end`}`,
|
|
134
|
+
`${g.rel.label}: nut`, { code: 'frame.nut', at: first.at.map(r3), values: { nuts: g.at.length }, refs: { ...refs, joins, ...(alt ? { alternative: alt.name, kind_needed: alt.nutKind } : {}) } });
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const open = !w.a ? 'a' : !w.b ? 'b' : null, pl = open ? null : pre.find((p) => p.fasten === g.rel.index && p.item === g.item && p.place === g.place);
|
|
138
|
+
f('pass', `${g.rel.label}: ${nutsSay(g)} go${g.at.length > 1 ? '' : 'es'} into ${where} ${open ? `from its end ${open}, which nothing closes` : pl ? `before a join closes its way, ${pl.how} (frame.preload)` : `from an end before ${list(['a', 'b'].map((e) => w.all[e].filter((c) => c.item).map((c) => c.item)).flat())} go on`}`, null, { code: 'frame.nut', at: first.at.map(r3), refs });
|
|
139
|
+
}
|
|
140
|
+
for (const p of pre) f('info', `${p.label}: ${p.text}`, null, { code: 'frame.preload', values: { nuts: p.count }, refs: { fasten: p.fasten, item: p.item, place: p.place, nut: p.nut, join: p.join.index, joins: p.closers.map((j) => j.index), end: p.end, way: p.way } });
|
|
141
|
+
if (!pre.length) f('pass', 'no slot nut has to be in its slot before a join closes it', null, { code: 'frame.preload' });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The order of assembly with the nuts to load first: each preload at the step that makes the join that closes its slot
|
|
146
|
+
* (the step its later item goes on in), as that step's load. @param {object} s a built assembly @param {object} r orderOf's
|
|
147
|
+
* @returns {object} r, its steps copied with load: string[] where there are nuts to load before them
|
|
148
|
+
*/
|
|
149
|
+
export function withPreload(s, r) {
|
|
150
|
+
if (!r?.steps?.length) return r;
|
|
151
|
+
const pre = preloadOf(s);
|
|
152
|
+
if (!pre.length) return r;
|
|
153
|
+
const steps = r.steps.map((st) => ({ ...st })), stepOf = (id) => steps.findIndex((st) => st.items.includes(id));
|
|
154
|
+
for (const p of pre) {
|
|
155
|
+
const i = Math.min(...p.closers.map((j) => Math.max(0, ...j.items.map(stepOf)))); // (the step that makes the first of the joins on the way)
|
|
156
|
+
(steps[i].load ||= []).push(p.text);
|
|
157
|
+
}
|
|
158
|
+
return { ...r, steps };
|
|
159
|
+
}
|
package/lib/task.mjs
CHANGED
|
@@ -118,14 +118,16 @@ function speedCheck(s, f) {
|
|
|
118
118
|
else f('pass', `${t.tool} moves ${say}`, null, { code, at, values });
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
// Each joint's error terms: step resolution from its motor,
|
|
122
|
-
|
|
121
|
+
// Each joint's error terms: step resolution from its motor, what the assembly says of its play, its twist and so on, and a
|
|
122
|
+
// guide's rail's (its parallelism, its carriage's play, the beam's straightness and sag)
|
|
123
|
+
export function terms(s, c) {
|
|
123
124
|
const motion = s.motion, specs = new Map((s.a.joints || []).map((j) => [j.id, j]));
|
|
124
125
|
return c.names.map((id) => {
|
|
125
126
|
const out = [], t = trainFrom(motion, id), d = motion.drives.find((x) => x.joint === t.root), spec = specs.get(id);
|
|
126
127
|
if (d?.model.stepAngle) { const micro = d.spec.microsteps ?? 16; out.push({ term: 'step', value: t.slide != null ? (d.model.stepAngle / micro) * t.slide : d.model.stepAngle / micro / t.ratio, kind: 'spec', note: `${n3(d.model.stepAngle, 3)}° at 1/${micro} step, ${n3(t.ratio, 1)}:1` }); }
|
|
127
128
|
const belt = motion.joints.find((x) => x.id === id)?.slide?.stretch; if (belt) out.push({ term: 'belt stretch', value: (belt.load * belt.length) / (belt.k * belt.width), kind: 'estimate', note: `${belt.load} N over ${belt.length} mm` });
|
|
128
129
|
for (const [term, expr] of Object.entries(spec?.errors ?? {})) out.push({ term, value: s.num(expr), kind: kindOf(expr), expr });
|
|
130
|
+
for (const x of spec?._guide?.terms ?? []) out.push({ term: x.term, value: x.value, kind: x.kind, note: x.note }); // (a guide's rail: mm along its travel, from its rule sets and the beam's)
|
|
129
131
|
return { joint: id, terms: out, geared: t.stages.length > 0 };
|
|
130
132
|
});
|
|
131
133
|
}
|
package/lib/wires.mjs
CHANGED
|
@@ -80,7 +80,8 @@ export function wireRows(s, helpers) {
|
|
|
80
80
|
export function wireChecks(s, f, helpers) {
|
|
81
81
|
for (const w of wireRows(s, helpers)) {
|
|
82
82
|
const refs = { wire: w.id, from: w.from, to: w.to }, at = w.route?.[0], values = { length: w.length, longest: w.longest, shortest: w.shortest, current: w.current, capacity: w.capacity };
|
|
83
|
-
|
|
83
|
+
const run = (s.runs ?? []).filter((r) => r.wire === w.id), clips = run.reduce((t, r) => t + r.count, 0);
|
|
84
|
+
f('info', `${w.id}: ${w.from} to ${w.to}, ${n3(w.length, 0)} mm with its ${w.loop} mm loop (${n3(w.shortest, 0)} to ${n3(w.longest, 0)} mm as the joints move)${run.length ? `; ${run.map((r) => `${n3(r.length, 0)} mm of it along ${r.along}`).join(', ')}, held by ${clips} cable clip${clips > 1 ? 's' : ''}` : ''}`, null, { code: 'wire.length', at, refs, values: { ...values, ...(run.length ? { along: run.reduce((t, r) => t + r.length, 0), clips } : {}) } });
|
|
84
85
|
if (w.capacity == null) { f('warn', `${w.id}: no gauge given, so nothing checks it against ${n3(w.current, 2)} A (${w.why})`, `${w.id}: no gauge`, { code: 'wire.gauge', at, refs, values }); continue; }
|
|
85
86
|
if (w.current > w.capacity) f('fail', `${w.id}: ${w.gauge} carries ${n3(w.capacity, 2)} A at most, and this carries ${n3(w.current, 2)} A (${w.why}): a thicker wire`, `${w.id}: too thin`, { code: 'wire.gauge', at, refs, values });
|
|
86
87
|
else f('pass', `${w.id}: ${w.gauge} takes ${n3(w.current, 2)} A (${w.why}), up to ${n3(w.capacity, 2)} A`, null, { code: 'wire.gauge', at, refs, values });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/cad",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.57",
|
|
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,14 +58,14 @@
|
|
|
58
58
|
"url": "https://github.com/JoniBach/rulecad/issues"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@rulecad/variables": "^0.3.
|
|
61
|
+
"@rulecad/variables": "^0.3.5",
|
|
62
62
|
"@rulecad/keyboard-layout": "^0.1.2",
|
|
63
63
|
"@rulecad/printcheck": "^0.3.0",
|
|
64
64
|
"@rulecad/fit": "^0.4.0",
|
|
65
65
|
"@rulecad/model-link": "^0.3.2",
|
|
66
66
|
"@rulecad/versions": "^0.1.6",
|
|
67
67
|
"@rulecad/shapes": "^0.4.5",
|
|
68
|
-
"@rulecad/rules": "^0.3.
|
|
68
|
+
"@rulecad/rules": "^0.3.16",
|
|
69
69
|
"@jscad/modeling": "^2.12.0",
|
|
70
70
|
"three": "^0.186.1",
|
|
71
71
|
"@rulecad/fea": "^0.2.1",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@rulecad/motors": "^0.1.6",
|
|
76
76
|
"@rulecad/fixings": "^0.1.4",
|
|
77
77
|
"@rulecad/robots": "^0.1.1",
|
|
78
|
-
"@rulecad/frames": "^0.1.
|
|
78
|
+
"@rulecad/frames": "^0.1.8"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@rulecad/pcb": "^0.1.0 || ^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0"
|
|
@@ -18,13 +18,15 @@
|
|
|
18
18
|
"items": { "type": "array", "items": { "$ref": "#/$defs/item" } },
|
|
19
19
|
"fits": { "type": "array", "items": { "$ref": "#/$defs/fit" } },
|
|
20
20
|
"fasten": { "type": "array", "description": "Screwed joints: each names its screw, the parts it passes through in order, and the part it ends in. The holes are read from the parts as drawn and each screw followed along one axis; a fasten holds its parts as a fit that fastens does, lines their holes up as a holes fit does, and puts its screws on the shopping list. Draw the holes with v.fixings, and name the screw with no length: the check chooses one", "items": { "$ref": "#/$defs/fasten" }, "defaultSnippets": [{ "label": "fasten", "description": "A screwed joint", "body": [{ "screw": "${1:M3 cap}", "through": ["${2:bracket}"], "into": "${3:base}", "at": ["${4:bracket.h1}", "${5:bracket.h2}"] }] }] },
|
|
21
|
+
"joins": { "type": "array", "description": "How beams are joined: each names an end of one beam (a) and a place on another (b), and its kind. A join puts its operations on both beams (a tap in a's end, an access or clearance hole across b), its screws into fasten, and a spring for the frame's solve; join.geometry checks the end meets the face square and flush where b says", "items": { "$ref": "#/$defs/join" }, "defaultSnippets": [{ "label": "join", "description": "A blind join: a's end tapped, its screw's head in b's slot", "body": [{ "kind": "${1:blind}", "a": "${2:y1.a}", "b": "${3:x1.back@120}" }] }] },
|
|
22
|
+
"guides": {"type": "array", "description": "Linear motion on a beam. A rail: a miniature rail screwed down on a beam's slotted face into slot nuts at its hole pitch, its carriages each riding its own share of the rail on a sliding joint with its true travel (<id>-1, <id>-2 ..; poses <id>-a and <id>-b put them at either end), their loads held to their ratings as joint.moment. Wheels: a printed plate (<id>-carriage-1) over a beam's face on V-wheels (<id>-wheel-1 ..) in the V tracks of the faces either side, rolling on a sliding joint (<id>-1) through the stretch from..from + length; refused on a face with no V track. A slider: a printed slider (<id>-carriage-1) in or over a slot, on a sliding joint through its stretch. Rods: two smooth rods along a face in printed holders at the stretch's ends (<id>-holder-a, <id>-holder-b, saddles screwed into the slots either side), a printed carriage (<id>-carriage-1) on two linear bearings on a sliding joint; an endstop's printed mount at a side face's address and a flag on the carriage set the joint's home. A screw: a lead screw driving a rods guide's carriage from a printed motor plate (<id>-plate) at its end a, the motor (<id>-motor) a motor item whose lead screw comes from the screw's set, a coupler, the screw, its bearings in the holders and the lead nut on the carriage", "items": {"type": "object", "required": ["kind"], "additionalProperties": false, "properties": {"id": {"type": "string", "description": "Its name (default g1, g2 ..): the rail item takes it"}, "kind": {"enum": ["rail", "wheels", "slider", "rods", "screw"], "description": "rail (a miniature linear rail, which needs rail), wheels (a plate on V-wheels in a V-slot's tracks), slider (a printed slider in or over a slot), rods (two rods in printed holders and a printed carriage on linear bearings) or screw (a lead screw and its motor driving a rods guide, which needs guide and motor); every kind but screw needs on and length; a belt follows"}, "rail": {"type": "string", "description": "The rail's rule set: rail-mgn7, rail-mgn9, rail-mgn12, rail-mgn15"}, "carriage": {"type": "string", "description": "The carriage, a variant of the rail's set: MGN12C (standard, the default) or MGN12H (long)"}, "on": {"type": "string", "description": "A rail's or a slider's slotted face (x1.top, x1.top.2); for wheels, the face the plate lies over (x1.top), its wheels in the slots either side"}, "from": {"$ref": "#/$defs/expr", "description": "Where the rail or the stretch starts, mm from the beam's end a (default 0)"}, "length": {"$ref": "#/$defs/expr", "description": "The rail as it is cut, mm; for wheels and a slider, the stretch of the beam it runs along, mm"}, "carriages": {"type": "integer", "minimum": 1, "maximum": 8, "description": "How many carriages ride it (default 1)"}, "nut": {"type": "string", "description": "A rail or rods: the slot nuts' kind (slide-in, drop-in, roll-in, square, hammer, t-bolt), for the rail's screws, or the rods' holders, motor plate and endstop mount; between two joins that close a slot at both ends, a slide-in nut is shut in (frame.nut), so give drop-in. A screw: the lead nut's rule set (t8-nut, the default)"}, "note": {"type": "string"}, "wheel": {"type": "string", "description": "Wheels: the V-wheel's rule set, v-wheel-solid (the default) or v-wheel-mini"}, "wheels": {"enum": [3, 4], "description": "Wheels: 4 (two a side, the default) or 3 (one on an eccentric)"}, "pitch": {"$ref": "#/$defs/expr", "description": "Wheels: their spacing along the beam, mm (default a wheel's diameter and 15 mm, rounded up to 5)"}, "load": {"$ref": "#/$defs/expr", "description": "Wheels or a slider: the printed part's design load, N (default 50 for a plate, 20 for a slider)"}, "mode": {"enum": ["over", "in"], "description": "A slider: over the slot (a shoe on the face, keyed into the opening; the default) or in it (a block held under its lips)"}, "size": {"$ref": "#/$defs/expr", "description": "A slider: its own length along the beam, mm (default 30)"}, "rod": {"type": "string", "description": "Rods: the rods' rule set (rod-8, the default)"}, "bearing": {"type": "string", "description": "Rods: the linear bearings' rule set (lm8uu, the default, or lm8luu)"}, "spacing": {"$ref": "#/$defs/expr", "description": "Rods: their distance apart across the face, mm (default room for the bearings and a lead nut's flange between)"}, "height": {"$ref": "#/$defs/expr", "description": "Rods: the rods' and screw's height over the face, mm (default the least that clears the carriage, the nut, the screw's bearing, the coupler and the motor)"}, "endstop": {"type": "object", "required": ["at"], "additionalProperties": false, "description": "Rods: an endstop on a printed mount; its lever meets a flag on the carriage, and the joint homes there", "properties": {"at": {"type": "string", "description": "An address on a face beside the rods: x1.front@80"}, "switch": {"type": "string", "description": "The switch's rule set (endstop-10t85, the default)"}}}, "guide": {"type": "string", "description": "A screw: the id of the rods guide whose carriage it drives"}, "screw": {"type": "string", "description": "A screw: the lead screw's rule set (t8-screw, the default)"}, "support": {"type": ["string", "null"], "description": "A screw: the ball bearing each holder takes the screw in (bearing-608, the default), or null for none"}, "coupler": {"type": "string", "description": "A screw: the coupler from the motor's shaft to the screw (coupler-5-8, the default)"}, "motor": {"type": "object", "required": ["model"], "description": "A screw: the motor item's spec ({ \"model\": \"28byj48\", \"microsteps\": 1 }): its drives and leadscrew come from the guide"}, "friction": {"$ref": "#/$defs/expr", "description": "A screw: the nut's friction on the screw (default the screw's set's, an estimate)"}}}, "defaultSnippets": [{"label": "rail", "description": "An MGN12 rail on a beam's top face", "body": [{"kind": "rail", "rail": "${1:rail-mgn12}", "on": "${2:x1.top}", "from": 0, "length": "${3:300}"}]}, {"label": "wheels", "description": "A plate on four V-wheels over a V-slot beam's top face", "body": [{"kind": "wheels", "wheel": "${1:v-wheel-solid}", "on": "${2:x1.top}", "from": 0, "length": "${3:400}"}]}, {"label": "rods and a screw", "description": "Two 8 mm rods on a beam's top face, a carriage on LM8UUs, driven by a 28BYJ-48 through a T8 screw", "body": [{"kind": "rods", "on": "${1:x1.top}", "from": "${2:60}", "length": "${3:120}"}, {"kind": "screw", "guide": "g1", "screw": "t8-screw", "motor": {"model": "${4:28byj48}"}}]}]},
|
|
21
23
|
"joints": { "type": "array", "items": { "$ref": "#/$defs/joint" } },
|
|
22
24
|
"loops": { "type": "array", "items": { "$ref": "#/$defs/loop" } },
|
|
23
25
|
"planetary": { "type": "array", "items": { "$ref": "#/$defs/planetary" } },
|
|
24
26
|
"task": { "type": "object", "required": ["tool"], "additionalProperties": false, "description": "What the machine is for: the tool, where it works, how fast and how accurately", "properties": { "tool": { "type": "string", "description": "An anchor, <item>.<anchor>" }, "sheet": { "type": "object", "required": ["at"], "additionalProperties": false, "properties": { "size": {}, "width": { "type": "number" }, "height": { "type": "number" }, "landscape": { "type": "boolean" }, "at": { "$ref": "#/$defs/vec3" }, "normal": { "$ref": "#/$defs/vec3" }, "u": { "$ref": "#/$defs/vec3" } } }, "region": { "type": "object" }, "volume": { "type": "object" }, "speed": { "$ref": "#/$defs/expr", "description": "mm/s" }, "accuracy": { "$ref": "#/$defs/expr", "description": "mm" }, "accel": { "$ref": "#/$defs/expr", "description": "mm/s², for planning" }, "elbow": { "enum": ["left", "right"] }, "deflection": { "$ref": "#/$defs/expr", "description": "mm of link deflection at the tool, an estimate; else worked out from the parts when there is a payload" }, "payload": { "$ref": "#/$defs/expr", "description": "kg at the tool" }, "grip": { "type": "object", "description": "A compliant gripper on a servo: { servo, horn, leaf: { length, thickness, width }, travel, friction, lever, margin }" }, "pen": { "type": "object", "description": "Servo angles for the pen: { up, down }" } } },
|
|
25
27
|
"gait": { "type": "object", "required": ["legs", "pattern", "stride", "lift", "period", "height", "mass"], "additionalProperties": false, "description": "Poses in time: the feet by anchor, a pattern, and the body", "properties": { "legs": { "type": "array", "items": { "type": "string" } }, "pattern": {}, "stride": { "$ref": "#/$defs/expr" }, "lift": { "$ref": "#/$defs/expr" }, "period": { "$ref": "#/$defs/expr" }, "height": { "$ref": "#/$defs/expr" }, "mass": { "$ref": "#/$defs/expr" }, "steps": { "$ref": "#/$defs/expr" }, "com": { "$ref": "#/$defs/vec3" }, "clearance": { "$ref": "#/$defs/expr" } } },
|
|
26
28
|
"power": { "type": "object", "additionalProperties": false, "properties": { "margin": { "type": "number" } } },
|
|
27
|
-
"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": { "type": "string" }, "description": "Anchors
|
|
29
|
+
"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" } } } },
|
|
28
30
|
"gravity": { "$ref": "#/$defs/vec3", "description": "Which way down is, for masses in loads (default [0, 0, -1])" },
|
|
29
31
|
"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" } } } },
|
|
30
32
|
"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" } } },
|
|
@@ -44,9 +46,12 @@
|
|
|
44
46
|
"object": { "type": "string" },
|
|
45
47
|
"assembly": { "type": "string" },
|
|
46
48
|
"motor": { "type": "object", "required": ["model"], "additionalProperties": false, "description": "A motor from @rulecad/motors: bought, not printed; its shaft turns the joint it drives", "properties": { "model": { "type": "string" }, "drives": { "type": "string" }, "set": { "type": "object", "description": "Figures that differ from the catalogue's, by name" }, "speed": { "$ref": "#/$defs/expr", "description": "The motor's speed, rpm (default: what it does comfortably)" }, "margin": { "$ref": "#/$defs/expr", "description": "How many times over the torque must be (default 2)" }, "duty": { "$ref": "#/$defs/expr", "description": "The share of the time it runs, 0 to 1 (default 1), for its heat" }, "screw": { "type": "string", "description": "The screws through a motor's plain holes, if not the size they take: M3" }, "driver": { "type": "string", "description": "The bought driver item this motor plugs into" }, "leadscrew": { "type": "object", "additionalProperties": false, "required": ["lead"], "properties": { "lead": { "$ref": "#/$defs/expr" }, "diameter": { "$ref": "#/$defs/expr" }, "friction": { "$ref": "#/$defs/expr" } } }, "belt": { "type": "object", "additionalProperties": false, "required": ["teeth"], "properties": { "teeth": { "$ref": "#/$defs/expr" }, "pitch": { "$ref": "#/$defs/expr" }, "stiffness": { "$ref": "#/$defs/expr", "description": "N per mm of strain, per mm of belt width" }, "width": { "$ref": "#/$defs/expr" }, "length": { "$ref": "#/$defs/expr" }, "load": { "$ref": "#/$defs/expr" } } }, "current": { "type": "number", "description": "A per coil, as set on the driver (default its rated current)" }, "cooled": { "type": "boolean", "description": "The driver has a heat sink and moving air" }, "microsteps": { "type": "number", "description": "Steps to a full step (default 16): resolution, not accuracy" } } },
|
|
47
|
-
"bought": { "type": "string", "description": "A part from a rule set (\"608\", \"drv8825\"): bought, not printed; drawn faint from its figures, with anchors from what it is" },
|
|
49
|
+
"bought": { "type": "string", "description": "A part from a rule set (\"608\", \"drv8825\", \"fitting-motedis-end-cap-20-b6\"): bought, not printed; drawn faint from its figures, with anchors from what it is. A frame's bought fitting (an end cap, a levelling foot, a hinge) placed at a beam's address is checked against that beam's profile, and its price goes on cad list" },
|
|
48
50
|
"variant": { "type": "string" },
|
|
49
51
|
"set": { "type": "object" },
|
|
52
|
+
"fitting": { "type": "object", "required": ["kind"], "additionalProperties": false, "description": "A printed fitting from @rulecad/frames, drawn from a profile's and its slot nuts' rules and sized from a named load (a join with \"fitting\": \"printed\" adds one for itself; a panel adds its clips, a door its hinges, handle and catch). A bracket, gusset or splice is sized by finite elements; the others by beam formulas, each reporting its grams and margin. In its fitted frame: a bracket's x along b's face away from a, y up a, z across; a plate's x along b, y along a, its contact face at z = 0", "properties": { "kind": { "enum": ["bracket", "gusset", "splice", "panel-clip", "panel-corner", "slot-cover", "panel-edge", "gasket-strip", "hinge", "handle", "latch", "magnet-catch", "end-cap", "foot", "levelling-foot", "castor-plate", "stacking-foot", "device-mount", "fan-mount", "drag-chain-end", "din-rail", "cable-clip", "tie-anchor", "spool-holder", "rail-jig", "wheel-plate", "slider", "rod-holder", "rod-carriage", "motor-plate", "endstop-mount"] }, "profile": { "type": "string", "description": "The profile the base leg or the plate lies on" }, "other": { "type": "string", "description": "A bracket's: the profile its upright leg lies on, where not the same" }, "face": { "type": "string", "description": "The face of the profile it lies on (top, top.2): its slot sizes the tongue and the nut" }, "otherFace": { "type": "string" }, "shape": { "enum": ["L", "T", "cross", "splice"], "description": "A gusset's shape" }, "brace": { "type": "boolean", "description": "A bracket's brace across its inside corner" }, "load": { "type": "number", "description": "The design load in N, across beam a at the fitting's screw (default 100)" }, "count": { "type": "number", "description": "A plate's screws on each arm (default 2)" }, "thread": { "type": "string" }, "head": { "enum": ["cap", "button"] }, "part": { "type": "string", "description": "A hinge's leaf (frame, door) or a levelling foot's part (body, pad): an item each" }, "sheet": { "type": "number", "description": "The panel's or door's thickness, in mm" }, "length": { "type": "number", "description": "A strip's length, in mm" }, "standoff": { "type": "number", "description": "A latch's or catch's: the door's inner face over the beam's face (a hinge's standoff)" }, "edge": { "type": "number" }, "magnet": { "type": "array", "items": { "type": "number" } }, "stud": { "type": "string" }, "range": { "type": "number" }, "holes": { "type": "array", "items": { "type": "number" } }, "end": { "enum": ["a", "b"] }, "depth": { "type": "number" }, "grip": { "type": "number" }, "span": { "type": "number" }, "gap": { "type": "number" }, "squeeze": { "type": "number" }, "pin": { "type": "string" }, "screw": { "type": "string" }, "thickness": { "type": "number" }, "nut": { "type": "string" }, "material": { "type": "string" }, "device": { "type": "string", "description": "A device mount's: the rule set its holes are read from (supply-24v, cnc-shield-v3)" }, "variant": { "type": "string", "description": "A device mount's: the device's variant" }, "turn": { "enum": [0, 90, 180, 270], "description": "A device mount's: the device's x from the slot's line, degrees" }, "offset": { "type": "number", "description": "A device mount's: the device's middle across the slot, mm" }, "deviceHead": { "enum": ["cap", "button"] }, "size": { "type": "number", "description": "A fan mount's fan, mm: 40, 60, 80, 92 or 120" }, "side": { "enum": [1, -1] }, "flange": { "type": "number" }, "cable": { "type": "number", "description": "A cable clip's bundle, mm" }, "width": { "type": "number" }, "tie": { "type": "array", "items": { "type": "number" } }, "spool": { "type": "object" }, "rod": { "type": "string", "description": "A rod holder's or carriage's: the rods' rule set" }, "bearing": { "type": "string", "description": "A carriage's linear bearings' rule set" }, "spacing": { "type": "number" }, "height": { "type": "number" }, "leadNut": { "type": "string", "description": "A rod holder's or carriage's: the lead nut's rule set" }, "support": { "type": ["string", "null"], "description": "A rod holder's: the screw's ball bearing's rule set" }, "flag": { "type": "object", "description": "A carriage's endstop flag: where its tip reaches, { y, z }" }, "motor": { "type": "string", "description": "A motor plate's: the motor's rule set (28byj48, nema14, nema17)" }, "coupler": { "type": "object", "description": "A motor plate's: the coupler's { length, D }" }, "switch": { "type": "string", "description": "An endstop mount's: the switch's rule set" }, "toward": { "enum": [1, -1], "description": "An endstop mount's: which way across the face its lever reaches" }, "pose": { "enum": ["fit", "print"], "description": "fit (the default): in its place, as the item's at and rotate put it; print: laid as it prints, for a plate (cad plates writes it so)" } } },
|
|
53
|
+
"panel": { "type": "object", "required": ["sheet", "thickness", "bay", "out"], "additionalProperties": false, "description": "A panel from @rulecad/frames: a sheet cut to the bay of four beams it closes, on their faces that look along out, held by printed clips at a pitch; with door, a door on printed hinges that turns on a joint", "properties": { "sheet": { "enum": ["acrylic", "polycarbonate", "aluminium"] }, "thickness": { "$ref": "#/$defs/expr" }, "bay": { "type": "array", "items": { "type": "string" }, "minItems": 4, "maxItems": 4, "description": "The four beam items round it, in order" }, "out": { "type": "array", "items": { "$ref": "#/$defs/expr" }, "minItems": 3, "maxItems": 3, "description": "The way its face looks, square to the bay" }, "pitch": { "$ref": "#/$defs/expr" }, "nut": { "type": "string" }, "load": { "$ref": "#/$defs/expr" }, "door": { "type": "object", "required": ["hinge"], "additionalProperties": false, "properties": { "hinge": { "type": "string", "description": "The beam of the bay its hinges go on" }, "open": { "$ref": "#/$defs/expr" }, "handle": { "type": "boolean" }, "catch": { "type": "boolean" }, "latch": { "type": "boolean" }, "load": { "$ref": "#/$defs/expr" } } } } },
|
|
54
|
+
"mount": { "type": "object", "required": ["on"], "additionalProperties": false, "description": "A bought board's or supply's printed mount on a beam (@rulecad/frames' deviceMountModel), its holes read from the item's rule set: the mount goes at a slotted face's address, the item on it, and the screws into the slot and into the device are fastens", "properties": { "on": { "type": "string", "description": "An address on a beam's slotted face: rail.top@200" }, "turn": { "enum": [0, 90, 180, 270], "description": "The device's x from the beam's line, degrees" }, "offset": { "$ref": "#/$defs/expr", "description": "The device's middle across the slot, mm" }, "standoff": { "$ref": "#/$defs/expr", "description": "A board's least standoff, mm" }, "load": { "$ref": "#/$defs/expr", "description": "N on the device at its farthest hole (default 50)" }, "nut": { "type": "string" }, "head": { "enum": ["cap", "button"] }, "screw": { "type": "string", "description": "A board's screws, where not the largest its holes pass" } } },
|
|
50
55
|
"beam": { "type": "object", "required": ["profile"], "additionalProperties": false, "description": "A length of a profile from @rulecad/frames: bought and cut to length, faint in previews; placed by its ends (from, to, roll) or by at and rotate", "properties": { "profile": { "type": "string", "description": "A profile's name: 2020-misumi-hfs5, profile-4040-item-8, or a set in this workspace's rules/" }, "length": { "$ref": "#/$defs/expr", "description": "mm from end a to end b; may be left out when from and to are both given" }, "printed": { "type": "boolean", "description": "A printed beam (a later release): a bought one is false, the default" }, "material": { "type": "string", "description": "A material set in place of the profile's alloy: al6063-t5, or a plastic" }, "ops": { "type": "array", "items": { "$ref": "#/$defs/beamOp" }, "description": "Operations on the beam, each a line on its sheet and a cut in its solid, placed by an address on the beam and dimensioned from end a" } } },
|
|
51
56
|
"at": { "anyOf": [{ "$ref": "#/$defs/vec3" }, { "$ref": "#/$defs/address" }] },
|
|
52
57
|
"rotate": { "$ref": "#/$defs/vec3" },
|
|
@@ -104,7 +109,7 @@
|
|
|
104
109
|
"at": { "$ref": "#/$defs/beamAddress" },
|
|
105
110
|
"thread": { "type": "string", "description": "A thread by name (M5): sizes the hole, the tap or the seat through @rulecad/fixings" },
|
|
106
111
|
"kind": { "enum": ["clearance", "close", "loose", "tap"], "description": "A drilled hole's kind" },
|
|
107
|
-
"head": { "type": "string", "description": "A counterbore's head: cap, button, hex or pan" },
|
|
112
|
+
"head": { "type": "string", "description": "A counterbore's head: cap, button, hex or pan; an access hole's, the head its hex key turns: cap (the default), button or countersunk" },
|
|
108
113
|
"diameter": { "$ref": "#/$defs/expr", "description": "mm, in place of a thread's figure" },
|
|
109
114
|
"depth": { "$ref": "#/$defs/expr", "description": "mm from the face or the end" },
|
|
110
115
|
"through": { "enum": ["wall", "beam"], "description": "A drilled hole through one wall (the default) or right through the beam" },
|
|
@@ -116,6 +121,23 @@
|
|
|
116
121
|
"radius": { "$ref": "#/$defs/expr", "description": "A pocket's corner radius, mm" },
|
|
117
122
|
"length": { "$ref": "#/$defs/expr", "description": "A notch's length along the beam, mm" } } },
|
|
118
123
|
"address": { "type": "string", "pattern": "^[a-z][\\w-]*(\\.[\\w-]+)+(@-?\\d+(\\.\\d+)?%?)?$", "description": "An anchor by name, <item>.<anchor>; on a beam an end (x1.a, x1.b), an end bore (x1.a.1), or a face with a distance from end a (x1.top@120), from end b (x1.top@-20) or a share of the length (x1.top@50%), the second slot of a face x1.top.2@120" },
|
|
124
|
+
"join": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"description": "Two beams joined: an end of one (a), a place on the other (b), and how (kind)",
|
|
127
|
+
"required": ["kind", "a", "b"],
|
|
128
|
+
"additionalProperties": false,
|
|
129
|
+
"properties": {
|
|
130
|
+
"kind": { "enum": ["blind", "end-tap", "bracket", "gusset", "cube", "hidden", "anchor", "mitre", "pivot", "splice", "printed"], "description": "blind: a's end tapped, a button-head screw's head in b's slot, an access hole across b. end-tap: a's end tapped, a cap screw through a hole drilled across b. bracket, gusset and splice with \"fitting\": \"printed\" add a printed fitting and its screws; bracket, gusset, splice, hidden and anchor with a bought fitting's set by name add that fitting, its screws and the holes it needs. The rest (cube, mitre's key, pivot, printed) are checked where they meet and stiffen the frame by an estimate; their fittings come in later releases" },
|
|
131
|
+
"a": { "type": "string", "description": "A beam's end: y1.a, or one bore of it where the end has several (y1.a.2)" },
|
|
132
|
+
"b": { "type": "string", "description": "A place on the other beam where a's end (its bore's axis) meets it: a face with a distance from its end a (x1.back@120, x1.top@-20, x1.top@50%), or an end (x1.b) for a splice, mitre or corner" },
|
|
133
|
+
"fitting": { "type": "string", "minLength": 1, "description": "For a kind with a fitting: printed, or a bought fitting's rule set by name (fitting-motedis-bracket-20-b6), or bought to be told which sets there are. Printed, a bracket, gusset or splice join adds the fitting as an item, placed from where the beams are, its screws into slot nuts in both beams as fastens, and its own stiffness by finite elements. A bought set on a bracket, gusset, splice, hidden or anchor join adds its item (a reference, listed with its price), its screws into the set's nuts as fastens, the hole a beam needs for it, and its set's stiffness, an estimate until the joint rig measures it" },
|
|
134
|
+
"brace": { "type": "boolean", "description": "A printed bracket's brace across its inside corner" },
|
|
135
|
+
"load": { "type": "number", "description": "A printed fitting's design load in N, across beam a at its screw (default 100): it is sized to about twice the margin at it" },
|
|
136
|
+
"nut": { "enum": ["slide-in", "drop-in", "roll-in", "hammer", "square", "t-bolt"], "description": "A printed fitting's slot nuts' kind (default: the strongest made for the slot)" },
|
|
137
|
+
"screw": { "type": "string", "description": "For blind and end-tap: the screw by thread and head (M5 button), where not the end bore's thread with the kind's head" },
|
|
138
|
+
"note": { "type": "string" }
|
|
139
|
+
}
|
|
140
|
+
},
|
|
119
141
|
"fasten": {
|
|
120
142
|
"type": "object",
|
|
121
143
|
"description": "A screwed joint: the screw by thread and head, the parts it passes in order, the part it ends in, and where the screws go (at, an anchor each, or holes, a part's own holes)",
|
|
@@ -128,10 +150,10 @@
|
|
|
128
150
|
"properties": {
|
|
129
151
|
"screw": { "type": "string", "description": "The screw, by its thread and head: M3 cap, M4 button, M3x12 countersunk, 6-32 UNC cap (the names @rulecad/fixings reads). With no length in the name, the shortest sold length that fits is chosen" },
|
|
130
152
|
"through": { "type": "array", "items": { "type": "string" }, "description": "The parts the screw passes through, in order from under its head: items (bracket) or item.part (bracket.body). Each needs a clearance hole for the thread" },
|
|
131
|
-
"into": { "type": "string", "description": "The part the screw ends in: a pilot, a tapped or printed thread, an insert's hole or a nut's seat there, or a clearance hole with nut" },
|
|
153
|
+
"into": { "type": "string", "description": "The part the screw ends in: a pilot, a tapped or printed thread, an insert's hole or a nut's seat there, or a clearance hole with nut. Or a slot on a beam (x1.top, x1.top.2, x1.top@120): the screw ends in a slot nut under the slot's lips, the one made for that slot and thread (nut chooses its kind), and each screw lies over a slot's centre line (fasten.slot)" },
|
|
132
154
|
"at": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/anchorRef" }, "description": "One screw at each anchor: a point on its axis (bracket.h1), the anchor's axis along the screw" },
|
|
133
155
|
"holes": { "type": "string", "description": "In place of at: a part whose holes are the screws' places, found in the part as drawn (a circuit board: its mounting holes)" },
|
|
134
|
-
"nut": { "anyOf": [{ "type": "boolean" }, { "type": "string" }], "description": "What holds the screw where the part it ends in does not: true or hex, square, lock. It sits on that part's far face, or in a nut's seat drawn there" },
|
|
156
|
+
"nut": { "anyOf": [{ "type": "boolean" }, { "type": "string" }], "description": "What holds the screw where the part it ends in does not: true or hex, square, lock. It sits on that part's far face, or in a nut's seat drawn there. Into a beam's slot, the slot nut's kind: slide-in, drop-in, roll-in, hammer, square or t-bolt (left out, the strongest made for the slot). A slide-in or square nut enters only from an open end of the slot (frame.nut, frame.preload)" },
|
|
135
157
|
"washer": { "type": "boolean", "description": "A plain washer under the head" },
|
|
136
158
|
"length": { "$ref": "#/$defs/expr", "description": "The screw's length in mm, where the name gives none: checked for reaching, bottoming out and standing proud" },
|
|
137
159
|
"torque": { "$ref": "#/$defs/expr", "description": "The tightening torque, N m: the pressure under the head is then held against the material it sits on (fasten.seat)" },
|