@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/fixings.mjs
CHANGED
|
@@ -2,39 +2,64 @@
|
|
|
2
2
|
// the workspace's own thread sets before the kit's, the project's printer, and the design's booleans (v.ops); where a
|
|
3
3
|
// call names no material, the project's is taken for what a thread is in or a head sits on (a hole, engagement,
|
|
4
4
|
// stripping, seating: never a screw's own steel). What each call found is kept, so cad check says what every hole
|
|
5
|
-
// and seat was drawn to.
|
|
5
|
+
// and seat was drawn to. In an object that is not printed (a reference: a bought circuit board, drilled by its maker),
|
|
6
|
+
// a hole is drawn to its rule's figure as it stands, with no hole compensation. No files are read here: the sandbox's
|
|
7
|
+
// runner uses it as the build does.
|
|
6
8
|
import { fixingsFor } from '@rulecad/fixings';
|
|
7
9
|
|
|
8
10
|
// The functions whose material is the part's (the plastic a pilot is formed in, what a thread or a head bears on)
|
|
9
11
|
const IN_PART = ['hole', 'holeModel', 'engagement', 'stripping', 'seating'];
|
|
12
|
+
// The functions that draw a hole to a figure and add the printer's hole compensation to it, which take printed: false
|
|
13
|
+
const HOLES = ['hole', 'holeModel'];
|
|
10
14
|
const isOptions = (o) => o && typeof o === 'object' && !Array.isArray(o);
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
17
|
* @rulecad/fixings bound to a design's project, with what its calls found.
|
|
14
|
-
* @param {{ sets?: object, printer?: object, material?: string | null, ops?: object }} context sets:
|
|
15
|
-
* sets by name (threads, materials); printer: the printer's rule set ({ name, rules }); material:
|
|
18
|
+
* @param {{ sets?: object, printer?: object, material?: string | null, ops?: object, printed?: boolean }} context sets:
|
|
19
|
+
* the workspace's rule sets by name (threads, materials); printer: the printer's rule set ({ name, rules }); material:
|
|
20
|
+
* the project's; ops: v.ops; printed: false for an object that is not printed (a reference), whose holes then get no
|
|
21
|
+
* hole compensation unless a call says printed itself
|
|
16
22
|
* @returns {{ fixings: Record<string, Function>, found: () => object[], used: () => boolean }} fixings: v.fixings;
|
|
17
23
|
* found: the findings of every model made, each said once (values.count where it came up again); used: whether the design called any of it
|
|
18
24
|
*/
|
|
19
|
-
export function designFixings({ sets, printer, material, ops } = {}) {
|
|
20
|
-
const bound = fixingsFor({
|
|
21
|
-
|
|
25
|
+
export function designFixings({ sets, printer, material, ops, printed = true } = {}) {
|
|
26
|
+
const bound = fixingsFor({
|
|
27
|
+
...(sets && Object.keys(sets).length ? { sets } : {}),
|
|
28
|
+
...(printer ? { printer } : {}),
|
|
29
|
+
...(ops ? { ops } : {}),
|
|
30
|
+
});
|
|
31
|
+
const found = new Map();
|
|
32
|
+
let calls = 0;
|
|
22
33
|
const keep = (r) => {
|
|
23
34
|
const list = Array.isArray(r) ? r : (r?.model ?? r)?.findings;
|
|
24
|
-
if (Array.isArray(list))
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
if (Array.isArray(list))
|
|
36
|
+
for (const x of list) {
|
|
37
|
+
if (!x || typeof x.text !== 'string' || typeof x.level !== 'string') continue;
|
|
38
|
+
const k = `${x.level}|${x.code}|${x.text}`,
|
|
39
|
+
had = found.get(k);
|
|
40
|
+
if (had) had.values = { ...had.values, count: (had.values?.count ?? 1) + 1 };
|
|
41
|
+
else found.set(k, { ...x });
|
|
42
|
+
}
|
|
29
43
|
return r;
|
|
30
44
|
};
|
|
31
45
|
const fixings = {};
|
|
32
46
|
for (const [k, f] of Object.entries(bound)) {
|
|
33
|
-
if (typeof f !== 'function') {
|
|
47
|
+
if (typeof f !== 'function') {
|
|
48
|
+
fixings[k] = f;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
34
51
|
const lead = k === 'lengthFor' ? 2 : 1; // (lengthFor takes the stack first: its options come third)
|
|
35
52
|
fixings[k] = (...a) => {
|
|
36
53
|
calls++;
|
|
37
|
-
if (material && IN_PART.includes(k) && (a[lead] === undefined || isOptions(a[lead])) && a[lead]?.material == null)
|
|
54
|
+
if (material && IN_PART.includes(k) && (a[lead] === undefined || isOptions(a[lead])) && a[lead]?.material == null)
|
|
55
|
+
a[lead] = { material, ...a[lead] };
|
|
56
|
+
if (
|
|
57
|
+
printed === false &&
|
|
58
|
+
HOLES.includes(k) &&
|
|
59
|
+
(a[lead] === undefined || isOptions(a[lead])) &&
|
|
60
|
+
a[lead]?.printed == null
|
|
61
|
+
)
|
|
62
|
+
a[lead] = { printed: false, ...a[lead] };
|
|
38
63
|
return keep(f(...a));
|
|
39
64
|
};
|
|
40
65
|
}
|