@rulecad/cad 0.8.0 → 0.10.0
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 +45 -16
- package/CHANGELOG.md +724 -0
- package/EXAMPLES.md +61 -54
- package/README.md +376 -98
- package/TUTORIAL.md +2 -2
- package/bin/cad.mjs +2664 -541
- package/lib/animate.mjs +173 -49
- package/lib/assembly.mjs +1883 -435
- package/lib/beams.mjs +256 -52
- package/lib/belts.mjs +66 -15
- package/lib/board-work.mjs +12 -0
- package/lib/bought.mjs +309 -53
- package/lib/buildpage.mjs +179 -29
- package/lib/cache-file.mjs +105 -0
- package/lib/carried.mjs +201 -0
- package/lib/clone.mjs +194 -42
- package/lib/code-text.mjs +28 -0
- package/lib/design-imports.mjs +127 -0
- package/lib/design.mjs +871 -147
- package/lib/designshapes.mjs +142 -0
- package/lib/drive.mjs +187 -63
- package/lib/edit.mjs +922 -192
- package/lib/errors.mjs +16 -3
- package/lib/estimates.mjs +51 -0
- package/lib/explain.mjs +62 -13
- package/lib/fasten.mjs +2708 -507
- package/lib/fe-key.mjs +29 -0
- package/lib/fittings.mjs +721 -122
- package/lib/fixings.mjs +38 -13
- package/lib/framebuild.mjs +790 -175
- package/lib/framecheck.mjs +1901 -368
- package/lib/framegen.mjs +108 -22
- package/lib/frameheat.mjs +225 -42
- package/lib/frameprint.mjs +513 -108
- package/lib/frames.mjs +86 -18
- package/lib/framesize.mjs +719 -120
- package/lib/frametip.mjs +235 -0
- package/lib/gait.mjs +135 -23
- package/lib/grip.mjs +62 -13
- package/lib/guides.mjs +1403 -230
- package/lib/host.mjs +129 -23
- package/lib/inplace.mjs +171 -36
- package/lib/jigs.mjs +360 -78
- package/lib/joins.mjs +697 -118
- package/lib/jsonedit.mjs +88 -26
- package/lib/kept.mjs +84 -0
- package/lib/kit.mjs +439 -69
- package/lib/layout.mjs +2 -1
- package/lib/links.mjs +149 -42
- package/lib/list.mjs +334 -64
- package/lib/live-guard.mjs +68 -0
- package/lib/live-shape.mjs +96 -24
- package/lib/live.mjs +189 -59
- package/lib/loads.mjs +597 -136
- package/lib/machine.mjs +372 -74
- package/lib/magnets.mjs +162 -44
- package/lib/measured.mjs +1080 -117
- package/lib/mesh.mjs +526 -119
- package/lib/meshcmd.mjs +215 -60
- package/lib/motors.mjs +1002 -214
- package/lib/motorsvg.mjs +114 -32
- package/lib/names.mjs +18 -1
- package/lib/optimise.mjs +991 -287
- package/lib/order.mjs +515 -114
- package/lib/panels.mjs +482 -94
- package/lib/parts.mjs +81 -23
- package/lib/pins.mjs +163 -44
- package/lib/plates.mjs +223 -35
- package/lib/player.mjs +37 -9
- package/lib/power.mjs +64 -13
- package/lib/preview.mjs +83 -16
- package/lib/profilemeasure.mjs +572 -129
- package/lib/rules.mjs +17 -6
- package/lib/sandbox-hooks.mjs +179 -27
- package/lib/sandbox-lock.mjs +225 -0
- package/lib/sandbox-preload.mjs +2 -2
- package/lib/sandbox-run.mjs +122 -25
- package/lib/sandbox.mjs +667 -75
- package/lib/schema.mjs +42 -11
- package/lib/seats.mjs +227 -49
- package/lib/services.mjs +261 -52
- package/lib/sheet.mjs +963 -179
- package/lib/slotnuts.mjs +213 -34
- package/lib/targets/gist.mjs +4 -1
- package/lib/targets.mjs +22 -4
- package/lib/task.mjs +376 -79
- package/lib/versions.mjs +285 -39
- package/lib/wires.mjs +228 -45
- package/lib/workspace.mjs +200 -14
- package/package.json +19 -19
- package/schemas/assembly.schema.json +2 -2
- package/schemas/project.schema.json +6 -0
- package/templates/coupons/MEASURE.md +109 -0
- package/templates/coupons/assemblies/fixings-test.json +20 -0
- package/templates/coupons/assemblies/slot-test.json +11 -0
- package/templates/coupons/objects/fixings-coupon.js +88 -0
- package/templates/coupons/objects/fixings-coupon.json +26 -0
- package/templates/coupons/objects/holds-coupon.js +130 -0
- package/templates/coupons/objects/holds-coupon.json +42 -0
- package/templates/coupons/objects/slot-coupon.js +89 -0
- package/templates/coupons/objects/slot-coupon.json +29 -0
- package/templates/coupons/project.json +10 -0
package/lib/services.mjs
CHANGED
|
@@ -14,12 +14,16 @@ import { boughtSets } from './bought.mjs';
|
|
|
14
14
|
const MOUNT_KEYS = ['on', 'turn', 'offset', 'standoff', 'load', 'nut', 'head', 'screw'];
|
|
15
15
|
const RUN_KEYS = ['along', 'from', 'to', 'pitch', 'cable'];
|
|
16
16
|
const shown = (v) => (v === undefined ? 'nothing' : JSON.stringify(v));
|
|
17
|
-
const mm = (x) => String(+Number(x).toFixed(2)),
|
|
17
|
+
const mm = (x) => String(+Number(x).toFixed(2)),
|
|
18
|
+
r3 = (x) => +x.toFixed(3);
|
|
18
19
|
|
|
19
20
|
// a slotted place on a beam by its face's name (top, top.2) and the beam's model, refused by name
|
|
20
21
|
function slotPlace(what, id, B, name) {
|
|
21
22
|
const q = B.places.find((x) => x.name === name || (x.face === name && x.index === 1));
|
|
22
|
-
if (!q)
|
|
23
|
+
if (!q)
|
|
24
|
+
throw new Error(
|
|
25
|
+
`${what}: ${id} has no face "${name}": it has ${[...new Set(B.places.map((x) => x.face))].join(', ')}`,
|
|
26
|
+
);
|
|
23
27
|
if (!q.slot) throw new Error(`${what}: ${id}'s ${name} face is closed: a mount or a clip goes into a slot`);
|
|
24
28
|
return q;
|
|
25
29
|
}
|
|
@@ -36,86 +40,260 @@ const faceOf = (B, q) => (B.places.filter((x) => x.face === q.face).length > 1 ?
|
|
|
36
40
|
* @returns {{ a: object, mounts: object[], runs: object[] }}
|
|
37
41
|
*/
|
|
38
42
|
export function expandServices(a, num, context = framesContext(), material = 'pla') {
|
|
39
|
-
const items = a.items || [],
|
|
43
|
+
const items = a.items || [],
|
|
44
|
+
mounted = items.filter((it) => it.mount != null),
|
|
45
|
+
runs0 = (a.wires || []).some((w) => (w.via ?? []).some((v) => v && typeof v === 'object'));
|
|
40
46
|
if (!mounted.length && !runs0) return { a, mounts: [], runs: [] };
|
|
41
|
-
const beams = new Map(items.filter((it) => it.beam).map((it) => [it.id, it])),
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
const beams = new Map(items.filter((it) => it.beam).map((it) => [it.id, it])),
|
|
48
|
+
ids = new Set(items.map((it) => it.id)),
|
|
49
|
+
models = new Map();
|
|
50
|
+
const modelOf = (id) => {
|
|
51
|
+
if (!models.has(id)) models.set(id, beamOf(beams.get(id), num, context).model);
|
|
52
|
+
return models.get(id);
|
|
53
|
+
};
|
|
54
|
+
const free = (base) => {
|
|
55
|
+
let n = base,
|
|
56
|
+
k = 2;
|
|
57
|
+
while (ids.has(n)) n = `${base}-${k++}`;
|
|
58
|
+
ids.add(n);
|
|
59
|
+
return n;
|
|
60
|
+
};
|
|
44
61
|
const beamOfAddress = (what, ref, key) => {
|
|
45
|
-
const s = String(ref ?? ''),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
const s = String(ref ?? ''),
|
|
63
|
+
i = s.indexOf('.');
|
|
64
|
+
if (i < 0)
|
|
65
|
+
throw new Error(
|
|
66
|
+
`${what}: ${key} is a beam's slotted face${key === 'on' ? ' and a distance, as rail.top@200' : ', as rail.top'} (got ${shown(ref)})`,
|
|
67
|
+
);
|
|
68
|
+
const id = s.slice(0, i),
|
|
69
|
+
rest = s.slice(i + 1);
|
|
70
|
+
if (!beams.has(id))
|
|
71
|
+
throw new Error(
|
|
72
|
+
`${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'})`,
|
|
73
|
+
);
|
|
49
74
|
return { id, rest, B: modelOf(id) };
|
|
50
75
|
};
|
|
51
|
-
const added = [],
|
|
76
|
+
const added = [],
|
|
77
|
+
fasten = [],
|
|
78
|
+
fits = [],
|
|
79
|
+
mounts = [],
|
|
80
|
+
runs = [],
|
|
81
|
+
plates = [],
|
|
82
|
+
replaced = new Map(),
|
|
83
|
+
ahead = new Map();
|
|
52
84
|
for (const it of mounted) {
|
|
53
|
-
const what = `item ${it.id}`,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
85
|
+
const what = `item ${it.id}`,
|
|
86
|
+
M = it.mount;
|
|
87
|
+
if (!M || typeof M !== 'object' || Array.isArray(M))
|
|
88
|
+
throw new Error(
|
|
89
|
+
`${what}: mount is { "on": "rail.top@200" }, an address on a beam's slotted face (got ${shown(M)})`,
|
|
90
|
+
);
|
|
91
|
+
for (const k of Object.keys(M))
|
|
92
|
+
if (!MOUNT_KEYS.includes(k)) throw new Error(`${what}: a mount has no "${k}": it takes ${MOUNT_KEYS.join(', ')}`);
|
|
93
|
+
if (!it.bought)
|
|
94
|
+
throw new Error(`${what}: mount holds a bought board or supply by the holes its rule set gives: give "bought"`);
|
|
57
95
|
const part = boughtSets().get(it.bought);
|
|
58
|
-
if (!['board', 'supply', 'encoder'].includes(part))
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
96
|
+
if (!['board', 'supply', 'encoder'].includes(part))
|
|
97
|
+
throw new Error(
|
|
98
|
+
`${what}: mount holds a bought board or supply, and ${it.bought} is ${part ? `a ${part}` : 'no bought part'}`,
|
|
99
|
+
);
|
|
100
|
+
if (it.at != null || it.rotate != null || it.repeat != null)
|
|
101
|
+
throw new Error(`${what}: a mounted item is placed by its mount: leave out at, rotate and repeat`);
|
|
102
|
+
const { id: bid, rest, B } = beamOfAddress(what, M.on, 'on'),
|
|
103
|
+
[face, dist] = rest.split('@');
|
|
104
|
+
if (dist == null)
|
|
105
|
+
throw new Error(
|
|
106
|
+
`${what}: on is a beam's face and a distance along it, as ${bid}.${face}@200 (got ${shown(M.on)})`,
|
|
107
|
+
);
|
|
108
|
+
try {
|
|
109
|
+
beamAnchor(B, rest);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
throw new Error(`${what}: on: ${String(e.message).replace(/^beamAnchor: /, '')}`);
|
|
112
|
+
}
|
|
113
|
+
const q = slotPlace(what, bid, B, face),
|
|
114
|
+
mid = free(`${it.id}-mount`);
|
|
115
|
+
const spec = {
|
|
116
|
+
kind: 'device-mount',
|
|
117
|
+
profile: B.profile.name,
|
|
118
|
+
face: faceOf(B, q),
|
|
119
|
+
device: it.bought,
|
|
120
|
+
...(it.variant != null ? { variant: it.variant } : {}),
|
|
121
|
+
...(M.turn != null ? { turn: M.turn } : {}),
|
|
122
|
+
...(M.offset != null ? { offset: num(M.offset) } : {}),
|
|
123
|
+
...(M.standoff != null ? { standoff: num(M.standoff) } : {}),
|
|
124
|
+
...(M.load != null ? { load: num(M.load) } : {}),
|
|
125
|
+
...(M.nut != null ? { nut: M.nut } : {}),
|
|
126
|
+
...(M.head != null ? { head: M.head } : {}),
|
|
127
|
+
...(M.screw != null ? { screw: M.screw } : {}),
|
|
128
|
+
};
|
|
129
|
+
const m = fittingModel(spec, context, material, what),
|
|
130
|
+
D = m.device;
|
|
68
131
|
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({
|
|
132
|
+
fasten.push({
|
|
133
|
+
screw: `${m.thread} ${m.head}`,
|
|
134
|
+
through: [mid],
|
|
135
|
+
into: `${bid}.${q.name}`,
|
|
136
|
+
at: m.screws.map((_, k) => `${mid}.b${k + 1}`),
|
|
137
|
+
nut: m.screws[0].nutKind,
|
|
138
|
+
note: `${it.id}'s mount into ${bid}`,
|
|
139
|
+
mountOf: it.id,
|
|
140
|
+
});
|
|
70
141
|
const at = D.holes.map((_, k) => `${mid}.d${k + 1}`);
|
|
71
|
-
fasten.push(
|
|
72
|
-
|
|
73
|
-
|
|
142
|
+
fasten.push(
|
|
143
|
+
m.fix === 'tapped'
|
|
144
|
+
? {
|
|
145
|
+
screw: `${D.thread} ${D.head}`,
|
|
146
|
+
through: [mid],
|
|
147
|
+
into: it.id,
|
|
148
|
+
at,
|
|
149
|
+
note: `${it.id} on its mount, from under it`,
|
|
150
|
+
mountOf: it.id,
|
|
151
|
+
}
|
|
152
|
+
: {
|
|
153
|
+
screw: `${D.thread} ${D.head}`,
|
|
154
|
+
through: [it.id],
|
|
155
|
+
into: mid,
|
|
156
|
+
at,
|
|
157
|
+
note: `${it.id} on its mount`,
|
|
158
|
+
mountOf: it.id,
|
|
159
|
+
},
|
|
160
|
+
);
|
|
74
161
|
replaced.set(it.id, { ...it, at: `${mid}.device` });
|
|
75
162
|
// 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]))),
|
|
163
|
+
const reachX = Math.max(...m.outline.map((pt) => Math.abs(pt[0]))),
|
|
164
|
+
d0 = num(dist),
|
|
165
|
+
at0 = d0 < 0 ? B.length + d0 : d0;
|
|
77
166
|
plates.push({ mount: mid, item: it.id, beam: bid, slot: q.name, lo: r3(at0 - reachX), hi: r3(at0 + reachX) });
|
|
78
|
-
mounts.push({
|
|
167
|
+
mounts.push({
|
|
168
|
+
id: it.id,
|
|
169
|
+
mount: mid,
|
|
170
|
+
beam: bid,
|
|
171
|
+
on: M.on,
|
|
172
|
+
set: it.bought,
|
|
173
|
+
variant: it.variant ?? null,
|
|
174
|
+
fix: m.fix,
|
|
175
|
+
holes: D.holes.length,
|
|
176
|
+
thread: D.thread,
|
|
177
|
+
length: D.length,
|
|
178
|
+
grams: m.grams,
|
|
179
|
+
margin: m.margin,
|
|
180
|
+
});
|
|
79
181
|
}
|
|
80
182
|
// wires: each run along a slot becomes clips, and the wire goes through each clip's cable anchor in turn
|
|
81
183
|
const wires = (a.wires || []).map((w, wi) => {
|
|
82
184
|
if (!(w.via ?? []).some((v) => v && typeof v === 'object')) return w;
|
|
83
185
|
const via = [];
|
|
84
186
|
for (const v of w.via) {
|
|
85
|
-
if (!v || typeof v !== 'object') {
|
|
187
|
+
if (!v || typeof v !== 'object') {
|
|
188
|
+
via.push(v);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
86
191
|
const what = `wire ${w.id || wi + 1}`;
|
|
87
|
-
if (Array.isArray(v))
|
|
88
|
-
|
|
192
|
+
if (Array.isArray(v))
|
|
193
|
+
throw new Error(`${what}: a run in via is { "along": "rail.top", "from": 20, "to": 380 } (got ${shown(v)})`);
|
|
194
|
+
for (const k of Object.keys(v))
|
|
195
|
+
if (!RUN_KEYS.includes(k))
|
|
196
|
+
throw new Error(`${what}: a run along a slot has no "${k}": it takes ${RUN_KEYS.join(', ')}`);
|
|
89
197
|
const { id: bid, rest, B } = beamOfAddress(what, v.along, 'along');
|
|
90
|
-
if (rest.includes('@'))
|
|
198
|
+
if (rest.includes('@'))
|
|
199
|
+
throw new Error(
|
|
200
|
+
`${what}: along names the face (${bid}.${rest.split('@')[0]}); the run's ends are from and to, in mm from end a`,
|
|
201
|
+
);
|
|
91
202
|
const q = slotPlace(what, bid, B, rest);
|
|
92
|
-
if (v.from == null || v.to == null)
|
|
93
|
-
|
|
94
|
-
|
|
203
|
+
if (v.from == null || v.to == null)
|
|
204
|
+
throw new Error(`${what}: a run along ${v.along} gives from and to, in mm from ${bid}'s end a`);
|
|
205
|
+
const from = num(v.from),
|
|
206
|
+
to = num(v.to),
|
|
207
|
+
L = B.length;
|
|
208
|
+
for (const [k, x] of [
|
|
209
|
+
['from', from],
|
|
210
|
+
['to', to],
|
|
211
|
+
])
|
|
212
|
+
if (!(Number.isFinite(x) && x >= 0 && x <= L))
|
|
213
|
+
throw new Error(`${what}: a run's ${k} is from 0 to ${mm(L)} mm along ${bid} (got ${shown(v[k])})`);
|
|
95
214
|
let clips;
|
|
96
|
-
try {
|
|
97
|
-
|
|
215
|
+
try {
|
|
216
|
+
clips = runClips(Math.abs(to - from), v.pitch != null ? { pitch: num(v.pitch) } : {});
|
|
217
|
+
} catch (e) {
|
|
218
|
+
throw new Error(`${what}: ${String(e.message).replace(/^runClips: /, '')}`);
|
|
219
|
+
}
|
|
220
|
+
const sgn = to >= from ? 1 : -1,
|
|
221
|
+
cable = v.cable != null ? num(v.cable) : SERVICE_DEFAULTS.cable.value,
|
|
222
|
+
list = [];
|
|
98
223
|
// 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(
|
|
100
|
-
|
|
224
|
+
const cw = fittingModel(
|
|
225
|
+
{ kind: 'cable-clip', profile: B.profile.name, face: faceOf(B, q), cable },
|
|
226
|
+
context,
|
|
227
|
+
material,
|
|
228
|
+
what,
|
|
229
|
+
).width,
|
|
230
|
+
keep = cw / 2 + SERVICE_DEFAULTS.gap.value;
|
|
231
|
+
const rlo = Math.min(from, to),
|
|
232
|
+
rhi = Math.max(from, to),
|
|
233
|
+
round = plates
|
|
234
|
+
.filter((pl) => pl.beam === bid && pl.slot === q.name && pl.lo - keep < rhi && pl.hi + keep > rlo)
|
|
235
|
+
.map((pl) => ({ ...pl, lo: r3(pl.lo - keep), hi: r3(pl.hi + keep) }));
|
|
101
236
|
let ds = clips.at.map((s) => r3(from + sgn * s));
|
|
102
237
|
if (round.length) {
|
|
103
238
|
ds = ds.filter((d) => !round.some((pl) => d > pl.lo && d < pl.hi));
|
|
104
|
-
for (const pl of round)
|
|
239
|
+
for (const pl of round)
|
|
240
|
+
for (const e of [pl.lo, pl.hi])
|
|
241
|
+
if (
|
|
242
|
+
e >= rlo - 1e-9 &&
|
|
243
|
+
e <= rhi + 1e-9 &&
|
|
244
|
+
!round.some((o) => e > o.lo + 1e-9 && e < o.hi - 1e-9) &&
|
|
245
|
+
!ds.some((d) => Math.abs(d - e) < cw)
|
|
246
|
+
)
|
|
247
|
+
ds.push(e);
|
|
105
248
|
ds.sort((x, y) => sgn * (x - y));
|
|
106
|
-
if (!ds.length)
|
|
249
|
+
if (!ds.length)
|
|
250
|
+
throw new Error(
|
|
251
|
+
`${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`,
|
|
252
|
+
);
|
|
107
253
|
}
|
|
108
254
|
for (const d of ds) {
|
|
109
255
|
const cid = free(`${w.id || `w${wi + 1}`}-clip`);
|
|
110
|
-
added.push({
|
|
111
|
-
|
|
112
|
-
|
|
256
|
+
added.push({
|
|
257
|
+
id: cid,
|
|
258
|
+
fitting: { kind: 'cable-clip', profile: B.profile.name, face: faceOf(B, q), cable },
|
|
259
|
+
at: `${bid}.${q.name}@${d}`,
|
|
260
|
+
runOf: w.id || `w${wi + 1}`,
|
|
261
|
+
});
|
|
262
|
+
fits.push({
|
|
263
|
+
a: cid,
|
|
264
|
+
b: bid,
|
|
265
|
+
fastens: true,
|
|
266
|
+
note: `${cid}: snapped into ${bid}'s ${q.name} slot, its barbs under the lips`,
|
|
267
|
+
}); // (no screw: its barbs hold it)
|
|
268
|
+
via.push(`${cid}.cable`);
|
|
269
|
+
list.push(cid);
|
|
113
270
|
}
|
|
114
|
-
runs.push({
|
|
271
|
+
runs.push({
|
|
272
|
+
wire: w.id || `w${wi + 1}`,
|
|
273
|
+
along: `${bid}.${q.name}`,
|
|
274
|
+
from,
|
|
275
|
+
to,
|
|
276
|
+
length: r3(Math.abs(to - from)),
|
|
277
|
+
clips: list,
|
|
278
|
+
count: list.length,
|
|
279
|
+
pitch: clips.pitch,
|
|
280
|
+
round: round.map((pl) => ({ mount: pl.mount, item: pl.item, from: pl.lo, to: pl.hi })),
|
|
281
|
+
most: v.pitch != null ? num(v.pitch) : SERVICE_DEFAULTS.pitch.value,
|
|
282
|
+
cable,
|
|
283
|
+
});
|
|
115
284
|
}
|
|
116
285
|
return { ...w, via };
|
|
117
286
|
});
|
|
118
|
-
const out = {
|
|
287
|
+
const out = {
|
|
288
|
+
...a,
|
|
289
|
+
items: [
|
|
290
|
+
...items.flatMap((it) => [...(ahead.has(it.id) ? [ahead.get(it.id)] : []), replaced.get(it.id) ?? it]),
|
|
291
|
+
...added,
|
|
292
|
+
],
|
|
293
|
+
...(fasten.length ? { fasten: [...(a.fasten || []), ...fasten] } : {}),
|
|
294
|
+
...(runs.length ? { wires } : {}),
|
|
295
|
+
...(fits.length ? { fits: [...(a.fits || []), ...fits] } : {}),
|
|
296
|
+
};
|
|
119
297
|
return { a: out, mounts, runs };
|
|
120
298
|
}
|
|
121
299
|
|
|
@@ -125,8 +303,39 @@ export function expandServices(a, num, context = framesContext(), material = 'pl
|
|
|
125
303
|
* @param {object} s a built assembly @param {Function} f the findings' sink
|
|
126
304
|
*/
|
|
127
305
|
export function serviceFindings(s, f) {
|
|
128
|
-
for (const m of s.mounts ?? [])
|
|
129
|
-
|
|
306
|
+
for (const m of s.mounts ?? [])
|
|
307
|
+
f(
|
|
308
|
+
'info',
|
|
309
|
+
`${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`,
|
|
310
|
+
null,
|
|
311
|
+
{
|
|
312
|
+
code: 'service.mount',
|
|
313
|
+
refs: { item: m.id, mount: m.mount, beam: m.beam, set: m.set },
|
|
314
|
+
values: { holes: m.holes, length: m.length, grams: m.grams, margin: m.margin },
|
|
315
|
+
},
|
|
316
|
+
);
|
|
317
|
+
for (const r of s.runs ?? [])
|
|
318
|
+
f(
|
|
319
|
+
'info',
|
|
320
|
+
`${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(),
|
|
321
|
+
null,
|
|
322
|
+
{
|
|
323
|
+
code: 'wire.run',
|
|
324
|
+
refs: { wire: r.wire, along: r.along, clips: r.clips },
|
|
325
|
+
values: { length: r.length, clips: r.count, pitch: r.pitch },
|
|
326
|
+
},
|
|
327
|
+
);
|
|
130
328
|
// 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 ?? [])
|
|
329
|
+
for (const r of s.runs ?? [])
|
|
330
|
+
for (const x of r.round ?? [])
|
|
331
|
+
f(
|
|
332
|
+
'warn',
|
|
333
|
+
`${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`,
|
|
334
|
+
`${r.wire}: round ${x.mount}`,
|
|
335
|
+
{
|
|
336
|
+
code: 'wire.run',
|
|
337
|
+
refs: { wire: r.wire, along: r.along, mount: x.mount, item: x.item },
|
|
338
|
+
values: { from: x.from, to: x.to },
|
|
339
|
+
},
|
|
340
|
+
);
|
|
132
341
|
}
|