@rulecad/cad 0.9.0 → 0.11.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 +29 -10
- package/CHANGELOG.md +604 -0
- package/EXAMPLES.md +122 -105
- package/README.md +292 -63
- package/bin/cad.mjs +500 -87
- package/lib/assembly.mjs +486 -134
- package/lib/bays.mjs +124 -0
- package/lib/cache-file.mjs +148 -0
- package/lib/clone.mjs +93 -11
- package/lib/code-text.mjs +28 -0
- package/lib/design-imports.mjs +127 -0
- package/lib/design.mjs +291 -59
- package/lib/designshapes.mjs +142 -0
- package/lib/edit.mjs +29 -5
- package/lib/estimates.mjs +51 -0
- package/lib/fasten.mjs +11 -5
- package/lib/fe-key.mjs +29 -0
- package/lib/fittings.mjs +20 -15
- package/lib/fixings.mjs +17 -4
- package/lib/framebuild.mjs +73 -92
- package/lib/framecheck.mjs +154 -77
- package/lib/framegen.mjs +9 -1
- package/lib/frames.mjs +6 -2
- package/lib/framesize.mjs +45 -82
- package/lib/gait.mjs +17 -7
- package/lib/guides.mjs +84 -50
- package/lib/host.mjs +7 -3
- package/lib/kit.mjs +5 -5
- package/lib/list.mjs +29 -21
- package/lib/live-guard.mjs +18 -8
- package/lib/loads.mjs +35 -23
- package/lib/measured.mjs +740 -99
- package/lib/mesh.mjs +156 -56
- package/lib/motors.mjs +26 -33
- package/lib/names.mjs +15 -0
- package/lib/node-version.mjs +52 -0
- package/lib/optimise.mjs +34 -25
- package/lib/order.mjs +5 -12
- package/lib/parts.mjs +3 -0
- package/lib/picture-servers.mjs +66 -0
- package/lib/power.mjs +14 -7
- package/lib/preview.mjs +12 -25
- package/lib/programs.mjs +113 -0
- package/lib/rules.mjs +2 -1
- package/lib/sandbox-guard.mjs +43 -0
- package/lib/sandbox-hooks.mjs +109 -15
- package/lib/sandbox-lock.mjs +225 -0
- package/lib/sandbox-preload.mjs +2 -2
- package/lib/sandbox-run.mjs +22 -24
- package/lib/sandbox.mjs +345 -42
- package/lib/sheet.mjs +114 -3
- package/lib/targets/gist.mjs +9 -6
- package/lib/versions.mjs +294 -35
- package/lib/workspace.mjs +6 -3
- package/package.json +14 -14
- package/schemas/assembly.schema.json +6 -5
- package/schemas/object.schema.json +1 -1
- 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/README.md
CHANGED
|
@@ -24,6 +24,7 @@ measured into rules, an optimised arm, a board, and a mechanism printed flat, ea
|
|
|
24
24
|
```
|
|
25
25
|
rules/ shared facts, one file per set: x1c.json (printer), mx.json (Cherry MX). A set from
|
|
26
26
|
@rulecad/rules is copied here the first time a design uses it: yours to keep and correct
|
|
27
|
+
(cad rules update <set> takes the kit's later corrections; see The workspace)
|
|
27
28
|
projects/<project>/
|
|
28
29
|
project.json name, title, description, default material, printer, objects, filaments (AMS slots)
|
|
29
30
|
(schemas/project.schema.json; written by cad new <project>, changed by cad set <project>)
|
|
@@ -39,6 +40,7 @@ exports/ .preview/ .versions/ .cache/ generated (ignore them in git); .cache/b
|
|
|
39
40
|
```sh
|
|
40
41
|
npx cad rules bathroom/soap-tray # every variable, its rule and source
|
|
41
42
|
npx cad check bathroom/soap-tray --set width=60 # change variables that have a tweak range
|
|
43
|
+
npx cad check bathroom/tray-on-shelf --set tray.width=60 # in an assembly: <item>.<variable>
|
|
42
44
|
npx cad variants keyboard/keycap # named sets of inputs: keyboard/keycap:legend-f
|
|
43
45
|
npx cad compare keyboard/keycap dsa legend-f # two variants (or releases) side by side
|
|
44
46
|
npx cad import-kle layout.json keyboard/mine # a layout from keyboard-layout-editor.com, into layouts/
|
|
@@ -133,11 +135,13 @@ The workspace is `$CAD_WORKSPACE`, else the nearest folder at or above the curre
|
|
|
133
135
|
else the current folder:
|
|
134
136
|
|
|
135
137
|
```json
|
|
136
|
-
{ "printer": "x1c", "viewUrl": "https://…/", "targets": { "show": "targets/show.mjs", "shorten": "gist" } }
|
|
138
|
+
{ "printer": "x1c", "engine": "manifold", "viewUrl": "https://…/", "targets": { "show": "targets/show.mjs", "shorten": "gist" } }
|
|
137
139
|
```
|
|
138
140
|
|
|
139
141
|
- `printer`: the rule set prints are checked against (bed, overhang, layer, bridge, support_gap); a project.json's
|
|
140
142
|
`printer` wins. Either is a rule set's plain name (letters, digits, `-` and `_`; see Variables).
|
|
143
|
+
- `engine`: optional. The boolean engine for every design's `v.ops` whose object names none: `"manifold"` (a new
|
|
144
|
+
workspace's, with `manifold-3d` installed beside the cad command) or `"jscad"` (the default). See Engines.
|
|
141
145
|
- `designTimeout` and `designMemory`: optional. How long a design may run in the sandbox, in seconds (3600, an hour, if
|
|
142
146
|
left out), and how much memory its JavaScript may hold, in megabytes (4096). A design past either is stopped with
|
|
143
147
|
`design.time` or `design.memory` (see Sandbox). `CAD_DESIGN_TIMEOUT` and `CAD_DESIGN_MEMORY` set them for one run.
|
|
@@ -151,8 +155,32 @@ else the current folder:
|
|
|
151
155
|
- Designs are ES modules that import JSCAD themselves, so the workspace needs `"type": "module"` and
|
|
152
156
|
`@jscad/modeling`. Circuit boards need `@rulecad/pcb` as well.
|
|
153
157
|
- Previews need Chrome or Chromium: `$CAD_CHROME`, else the usual install paths.
|
|
158
|
+
cad shows that Chrome the page from a small server on this computer for the few seconds a picture takes. The
|
|
159
|
+
server answers only to this computer's own names and addresses, so a web page open in your browser can't read the
|
|
160
|
+
part from it.
|
|
154
161
|
- Designs are code: run only designs you trust. Links and rule files are data and never run.
|
|
155
162
|
|
|
163
|
+
### Your copies of the kit's rule sets
|
|
164
|
+
|
|
165
|
+
The first time a design uses one of the kit's rule sets (`x1c`, `m3`, `pla`), cad copies it into `rules/` and from
|
|
166
|
+
then on reads only that copy: the workspace keeps every figure its designs were built on, and your measurements are
|
|
167
|
+
edits to your copy. A later version of the kit may correct a figure or add rules, and the copy keeps what it had until
|
|
168
|
+
you take them. `cad rules check` says when:
|
|
169
|
+
|
|
170
|
+
| Note | What it says | What to do |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| `rules.changed` | The kit has a different figure for a rule, checked after your copy's was, and your copy's is not `measured` | `cad rules update <set>` |
|
|
173
|
+
| `rules.new` | The kit's set has rules your copy lacks | `cad rules update <set>`, or copy the ones you want by hand |
|
|
174
|
+
| `rules.same` | Your copy is the kit's set word for word: nothing in it is yours | Keep it, or delete it: the next design to use the set copies in the kit's as it is then |
|
|
175
|
+
|
|
176
|
+
`cad rules update <set>` brings `rules/<set>.json` up to the kit's and prints each change: a figure the kit checked
|
|
177
|
+
after your copy's was (`13.8 → 14`), the kit's new rules, and the same figure with more said of it (its range, a newer
|
|
178
|
+
source). It keeps every figure of kind `measured`, every figure you checked on or after the kit's date (your own
|
|
179
|
+
word), and every rule the kit has none of. `--dry-run` prints what it would change and writes nothing; `--json` gives
|
|
180
|
+
it as `{ changed: [{ rule, from, to }], added, refreshed, fields, kept: { measured, newer, own } }`. A figure that
|
|
181
|
+
changes can move a printed size: check the designs that use the set afterwards. So that a correction of yours is never
|
|
182
|
+
taken for an old figure, record it with `"kind": "measured"` (or today's date in `checked`).
|
|
183
|
+
|
|
156
184
|
## Links
|
|
157
185
|
|
|
158
186
|
`cad link <project>/<object>` (and `cad show`) prints three links to the model page (`viewUrl`; a public one by default):
|
|
@@ -203,8 +231,13 @@ so in one line (on stderr), so that a workspace from elsewhere can't send your l
|
|
|
203
231
|
also checks the version; `"macropad/pcb@0.2.0"` reads that release. `cad rules` shows each borrowed number with the
|
|
204
232
|
object and version it came from; two objects can't read each other.
|
|
205
233
|
- `show`: on the rules card `cad show` hands its target (six at most). `interface`: other parts depend on it (versioning will compare these).
|
|
206
|
-
- `tweak: { min, max }`: may be changed with `--set`. Variables without one are fixed by their rule.
|
|
207
|
-
|
|
234
|
+
- `tweak: { min, max }`: may be changed with `--set`. Variables without one are fixed by their rule. On an assembly,
|
|
235
|
+
`--set <item>.<variable>=<value>` builds that object item at the value (`cad check`, `preview`, `export`, `show`,
|
|
236
|
+
`link`, `animate`, `cad list`, `wires` and `beams`); a name that is not one of the assembly's object items and that
|
|
237
|
+
object's variables is refused by name, never passed over. The commands that make a build from the file as written
|
|
238
|
+
(`kit`, `plates`, `order`, `frame`, `machine`, `plot`, `measured`) refuse `--set`: write the value with `cad set`.
|
|
239
|
+
- Inputs that hold names or text, not numbers (the design reads them; expressions can't), all settable with `--set`
|
|
240
|
+
and `cad set`, which keep the text as typed (`legend=007` stays `007`, never the number 7):
|
|
208
241
|
- `choice: ["dsa", "oem"]`: one of a list.
|
|
209
242
|
- `"type": "text"` (with `max`, characters): free text, e.g. a keycap's `legend`.
|
|
210
243
|
- `"type": "anchor"`: one of 9 places on a face, `tl tc tr / ml mc mr / bl bc br`, for placing a legend.
|
|
@@ -221,6 +254,9 @@ so in one line (on stderr), so that a workspace from elsewhere can't send your l
|
|
|
221
254
|
text so punctuation stays small, each straight stroke thickened to whole print lines, dots drawn round, and ↑ ↓ ← →
|
|
222
255
|
as arrows), `anchor(face, size, at)` (where something goes on a face, by anchor), and `cut(a, b)` (a subtract that
|
|
223
256
|
only touches a's faces near b; JSCAD's own splits every face along b's planes, which can leave slivers far away).
|
|
257
|
+
Its seats for bought parts, `shaftBore`, `bearingSeat`, `plainBearing` and `pulleyBore`, are reported by `cad check`
|
|
258
|
+
as `v.fixings`'s holes are (`seat.drawn`): what each was drawn to, the fit it rests on and that fit's kind (a press
|
|
259
|
+
fit on a shaft is an estimate until it is measured).
|
|
224
260
|
- `v.flexures`: compliant mechanisms (`@rulecad/flexures`): `leaf`, `fixedGuided`, `parallelGuide`, `serpentine`,
|
|
225
261
|
`notchHinge`, `bistable`, `livingHinge` as shapes, each with a `<name>Model(shape, { E })` giving its stiffness and the
|
|
226
262
|
strain at a travel, and `printable(shape, printer, material, model)` for how it prints. Drawn flat: bending along y,
|
|
@@ -232,7 +268,9 @@ so in one line (on stderr), so that a workspace from elsewhere can't send your l
|
|
|
232
268
|
print, and `engagement`, `seating` and `lengthFor` for first sums. Each reads the workspace's own thread set
|
|
233
269
|
(`rules/m3.json`) before the kit's, the project's printer and (for what a thread is in) its material, so a design
|
|
234
270
|
types no diameter and passes none. `cad check` lists what each call drew and the rule it rests on (`hole.drawn`,
|
|
235
|
-
`counterbore.drawn`, ...).
|
|
271
|
+
`counterbore.drawn`, ...). In an object that is not printed (`"role": "reference"` or `"board"`: a bought circuit
|
|
272
|
+
board, drilled by its maker), a hole is drawn to its rule's figure as it stands, with no hole compensation. A design
|
|
273
|
+
may also import `@rulecad/fixings` itself: then it reads the kit's sets only.
|
|
236
274
|
- `v.frames`: beams and profiles (`@rulecad/frames`): `profileModel` for a profile's figures, slots and faces
|
|
237
275
|
(`v.frames.profileModel('2020-misumi-hfs5').slots['slot-6-misumi'].opening`, to draw a tab that drops into a slot),
|
|
238
276
|
`slotModel`, `beamModel`, `beam` and `outline`. A profile measured into this workspace's `rules/` (`cad measure
|
|
@@ -246,7 +284,13 @@ so in one line (on stderr), so that a workspace from elsewhere can't send your l
|
|
|
246
284
|
from its `.kicad_pcb` (a file, or a GitHub link: pinned to the commit, with the repository's licence). A board's code
|
|
247
285
|
reads it as `v.sea_picro.circuit` and builds from it with @rulecad/pcb's `clone`. Its rules (`width`, `height`,
|
|
248
286
|
`thickness`, `layers`) are `kind: derived`, with the source and its licence. A reciprocal licence (CERN-OHL-S,
|
|
249
|
-
share-alike) carries over to boards made from it: keep such a rule set apart from your others.
|
|
287
|
+
share-alike) carries over to boards made from it: keep such a rule set apart from your others. It reads up to 64 MB
|
|
288
|
+
for the board and for each 3D model of its parts, from a file or downloaded: a larger board is refused, and a larger
|
|
289
|
+
model is left out with a note that names it by its path in the board's folder or repository (`note: no 3D model for
|
|
290
|
+
hw/lib/usb.wrl: its .wrl file is more than the 64 MB cad clone reads`). A model of more than 2 million triangles is
|
|
291
|
+
left out the same way. Only a file is read: a board that is a folder, a device or a pipe is refused, and a model
|
|
292
|
+
that is one is left out with a note. A character in a model's name that doesn't print (a bell, an escape code) is
|
|
293
|
+
written in its note as its code, `\u{7}`.
|
|
250
294
|
- An object or rule set named with a hyphen (`mx-switch`) is read with an underscore in expressions (`mx_switch.housing_top`),
|
|
251
295
|
since a hyphen there is a minus.
|
|
252
296
|
- Rule-set, project, object, layout, problem and assembly names are plain: letters, digits, `-` and `_`, starting
|
|
@@ -255,8 +299,12 @@ so in one line (on stderr), so that a workspace from elsewhere can't send your l
|
|
|
255
299
|
was read from (`projects/p/project.json: the "printer" field "../x" is not a plain name`): a workspace's own files
|
|
256
300
|
cannot make the tool read or write anywhere but where it means to. In `"uses"`, another object is
|
|
257
301
|
`<project>/<object>`, optionally with `:<variant>` and `@<version>`, never a path to a file.
|
|
258
|
-
- Rules carry `kind`: spec (
|
|
259
|
-
|
|
302
|
+
- Rules carry `kind`: spec (the maker's or a standard's own document), default (slicer), community (a widely used
|
|
303
|
+
figure from anyone else, such as a shop's listing or a wiki), estimate (a reasoned guess nobody has measured yet),
|
|
304
|
+
derived (worked out from other figures, such as a board's size read from its design file) or measured (your own test
|
|
305
|
+
print, which beats the rest), plus `source` and `checked`; the rules README says what each means. `cad check` warns
|
|
306
|
+
(`rules.estimate`) when an object or an assembly rests on an estimate: a rule it reads, or a seat drawn to an
|
|
307
|
+
estimated fit (a press-fit `shaftBore`), naming each one to measure.
|
|
260
308
|
|
|
261
309
|
## Versions
|
|
262
310
|
|
|
@@ -266,11 +314,33 @@ Every object has its own semver version, kept as a git tag (`keyboard/keycap@1.2
|
|
|
266
314
|
- **major**: an earlier print may no longer fit. An `interface` variable changed or went away, including through a
|
|
267
315
|
rule it's built from (a new `x1c.hole_comp` widens the slot, so the keycap's slot changes: major).
|
|
268
316
|
- **minor**: something added that doesn't break fits: a new interface variable, a new tweakable option.
|
|
269
|
-
- **patch**: everything else: other variables, the shape's code, rules that don't reach the interface
|
|
317
|
+
- **patch**: everything else: other variables, the shape's code, rules that don't reach the interface, and any other
|
|
318
|
+
file the design reads (below).
|
|
319
|
+
|
|
320
|
+
A release records everything its design is built from, so that it can be rebuilt exactly and any later change to
|
|
321
|
+
one of those files asks for a new release. Its commit holds, and its tag names:
|
|
322
|
+
|
|
323
|
+
- the object's `.js` and `.json`, the rule sets in its `"uses"` and the layout files it can pick;
|
|
324
|
+
- the files of its project that its code imports (the starter template's `lid.js` imports `./box.js`);
|
|
325
|
+
- where it draws with `v.fixings` or `v.frames`, the workspace's own rule sets those read (thread, material and
|
|
326
|
+
profile sets, the printer's, and measured outlines in `rules/outlines/`), and the project's material and printer;
|
|
327
|
+
- the files of the objects it reads through `"uses"` (each one's own files, and what it reads), unless it names a
|
|
328
|
+
release of theirs (`"home/box@1.0.0"`), which is rebuilt from its own tag.
|
|
329
|
+
|
|
330
|
+
A release is rebuilt in `.versions/<project>/<object>@<version>/`, its files at the paths they have in the workspace,
|
|
331
|
+
with the rule sets, imports and other objects of its tag, never today's. `cad status` and `cad diff` compare each of
|
|
332
|
+
those files with the workspace's: a helper edited, a rule set measured again (`rules/m3.json`) or one added that its
|
|
333
|
+
fixings now read is a change to the part (`rules/m3.json changed`, `now reads rules/m3.json`), and a changed object
|
|
334
|
+
it reads counts through the numbers it takes from it. A release made before releases recorded this is rebuilt with
|
|
335
|
+
the files its code imports by a path (`./box.js`), and its rule sets as its tag holds them.
|
|
270
336
|
|
|
271
337
|
A lower `--bump` than the changes need is refused (`--force` overrides). Releases are logged in the project's
|
|
272
338
|
`CHANGELOG.md`. A project release (`cad release keyboard`) records the version of each object, and its bump is the
|
|
273
|
-
biggest of theirs
|
|
339
|
+
biggest of theirs: it writes `version` and `release` (each object's version) into the project's `project.json`, and
|
|
340
|
+
`cad set <project>` goes on working after it. A release is a git commit and tag, so the workspace must be in a git
|
|
341
|
+
repository (it may be a folder of a larger one) with a name and email address set (`git config user.name`, `git config
|
|
342
|
+
user.email`); `cad release` says what to run if either is missing. If git refuses the commit or the tag (a hook that
|
|
343
|
+
fails), the version and changelog are put back as they were, and the release can simply be run again. `cad printed` logs what you printed and how it came out in `prints.jsonl`; `cad history` shows
|
|
274
344
|
releases and prints together.
|
|
275
345
|
|
|
276
346
|
```sh
|
|
@@ -283,6 +353,61 @@ npx cad history keyboard/keycap
|
|
|
283
353
|
npx cad diff keyboard/keycap 1.0.0 1.1.0
|
|
284
354
|
```
|
|
285
355
|
|
|
356
|
+
### Measurements: `cad measured`
|
|
357
|
+
|
|
358
|
+
A figure measured on a test print goes back where the estimate was: `cad measured <project>/<assembly>
|
|
359
|
+
x1c.hole_comp=0.15` writes it into the workspace's copy of the rule set as `measured`, with the date and `--source`,
|
|
360
|
+
runs the assembly's checks before and after, and says what moved: each prediction with its figure before and after,
|
|
361
|
+
and each other finding whose words changed (the lid's hole measures 3.5 mm, now 3.55 mm). A finding is paired with
|
|
362
|
+
itself by its code and what it is about (the fasten, the fit's two parts, the join, the beam), so a fasten whose
|
|
363
|
+
screws come out in another order is still matched. A check's prediction is measured the same way (`c1.drop=0.4`,
|
|
364
|
+
`task.accuracy=0.8`). Each figure goes into the project's ledger, `projects/<project>/ledger.jsonl`, against what was
|
|
365
|
+
predicted; `cad history <project>/<assembly>` shows it.
|
|
366
|
+
|
|
367
|
+
A slip of the pen is refused before anything is written: an empty figure (`x1c.fit=`), a figure of the other sign
|
|
368
|
+
from the one it replaces, and one under half or over twice it (a tenth to ten times, for an estimate, which is a
|
|
369
|
+
guess the measurement is there to correct). A 0 goes in as typed for a figure a coupon in the kit measures, since
|
|
370
|
+
the coupons step either side of the kit's figure and some start at 0 (the fixings coupon's nut slots). A figure that
|
|
371
|
+
really is that far out goes in with `--force`. A figure
|
|
372
|
+
the coupon bounds by what a fit of its kind can be is held to that instead, and a drop or a sag is checked as it is
|
|
373
|
+
read.
|
|
374
|
+
|
|
375
|
+
A row written by mistake comes out of the ledger with `--strike <date> <name>` (`<name>=<figure>` where the ledger
|
|
376
|
+
has that name twice that day). The ledger and the rule set are separate files, so it says what the rule set still
|
|
377
|
+
holds: set that back yourself (`git checkout rules/x1c.json`, or `cad measured` with the right figure).
|
|
378
|
+
|
|
379
|
+
**Coupons.** The kit's test prints come into your workspace with `cad coupons`: it adds `projects/coupons`, with the
|
|
380
|
+
fixings coupon (pilots, insert holes, nut pockets and slots, printed threads), the holds coupon (snap pin sockets,
|
|
381
|
+
pins pressed and slipping, magnet pockets) and the slot coupon (tongues, carriers and printed slots for aluminium
|
|
382
|
+
beams), each with its figure beside every feature, and a `MEASURE.md` that says how to read each row and the command
|
|
383
|
+
that writes it back. A workspace that has the project already keeps it as it is. A coupon's figure needs no assembly:
|
|
384
|
+
`cad measured x1c.pilot_m3=2.9` writes it the same way, keeps its row in the workspace's own ledger, `ledger.jsonl`
|
|
385
|
+
(`cad history` alone shows it, `--strike` takes a row out), and has no checks to run either side; give an assembly
|
|
386
|
+
first to see what it moves there. The source written names the coupon's `MEASURE.md` in your workspace
|
|
387
|
+
(`projects/coupons/MEASURE.md`).
|
|
388
|
+
|
|
389
|
+
**Sending figures to the kit.** `cad measured --export` prints every figure measured in this workspace that the kit
|
|
390
|
+
does not hold yet (or holds as anything but a measurement checked that day or since) as a unified diff of the kit's
|
|
391
|
+
rule sets, `packages/rules/<set>.json`, the rest of each file as the kit has it: `npx cad measured --export >
|
|
392
|
+
measured.diff`, then send it with the printer and plastic to the kit's issues, or apply it to a copy of the repository
|
|
393
|
+
for a pull request. A set the kit has no file for (the joins set, a part of your own) is listed apart, on stderr, to
|
|
394
|
+
send as it is. `--json` gives the same as data.
|
|
395
|
+
|
|
396
|
+
`--table` lists what the assembly still assumes: every rule it reads that is an estimate, a community figure or a
|
|
397
|
+
default, with its figure, the coupon in the kit that measures it (marked where this assembly is that coupon), and how
|
|
398
|
+
to settle it; the figures a coupon in it measures that the rule set has no figure for yet; and each prediction its
|
|
399
|
+
checks make. `--json` gives the same rows as data, and `--out MEASURE.md` keeps the table in that file.
|
|
400
|
+
|
|
401
|
+
```sh
|
|
402
|
+
npx cad measured home/lidded-box --table # what to measure
|
|
403
|
+
npx cad measured home/lidded-box x1c.hole_comp=0.15 --source "fit bar, row 1"
|
|
404
|
+
npx cad measured home/lidded-box x1c.fit=0.5 --force # more than twice the 0.2 it replaces, and right
|
|
405
|
+
npx cad measured home/lidded-box --strike 2026-12-01 x1c.fit
|
|
406
|
+
npx cad coupons # the coupons, in projects/coupons, with MEASURE.md
|
|
407
|
+
npx cad measured x1c.pilot_m3=2.9 # a coupon's figure, with no assembly
|
|
408
|
+
npx cad measured --export > measured.diff # what you measured, to send to the kit
|
|
409
|
+
```
|
|
410
|
+
|
|
286
411
|
## Parts
|
|
287
412
|
|
|
288
413
|
`main()` can return named parts instead of one shape, described in the .json:
|
|
@@ -313,8 +438,12 @@ To fit something someone else made (a maker's connector, a part from a model sit
|
|
|
313
438
|
guessing, then check your design against it.
|
|
314
439
|
|
|
315
440
|
`cad measure <model.stl|model.3mf>` (and `cad match`) reads a model from anywhere as data, up to 2,000,000 triangles,
|
|
316
|
-
a 3MF's zip up to 512 MB unpacked
|
|
317
|
-
three numbers,
|
|
441
|
+
a 3MF's zip up to 512 MB unpacked, its objects placed up to 100,000 times and held up to 16 levels deep inside each
|
|
442
|
+
other: a file past a limit, a corner that is not three numbers, a 3MF triangle naming a corner its object hasn't got,
|
|
443
|
+
a 3MF object that holds itself, or a damaged zip (a size or place in it that points past the file's end) is refused,
|
|
444
|
+
naming the file and what is wrong (`part.3mf: a damaged zip file: entry 2 (3D/3dmodel.model) runs past the end of the
|
|
445
|
+
file`). So is a file of more than 2 GB, a text STL or a 3MF's model file of more than 511 MB of text (the most Node
|
|
446
|
+
holds), and a folder given for a file. It finds the stretches along the model's longest axis (or `--along y`) where its
|
|
318
447
|
cross-section stays the same, numbers the distinct sections (a section seen again gets the same letter), and describes
|
|
319
448
|
each one: its extent and its height bands, the heights over which it has the same pieces across, split again at steps.
|
|
320
449
|
It draws every distinct section in `.preview/measure/`. `--line 0.6,2.5` reports where a line along the axis is inside
|
|
@@ -381,8 +510,23 @@ other items' variables, so a keycap can sit exactly where its slot meets the swi
|
|
|
381
510
|
"fits": [ { "a": "cap.cap", "b": "switch.stem", "min": "-x1c.hole_comp", "max": "x1c.fit", "note": "Slot over the stem" } ] }
|
|
382
511
|
```
|
|
383
512
|
|
|
384
|
-
- **fit** assemblies check how parts go together: no overlaps
|
|
385
|
-
`min`
|
|
513
|
+
- **fit** assemblies check how parts go together: no overlaps, and the closest gap for each `fit` within its range,
|
|
514
|
+
from `min` to `max` in millimetres; a gap outside it fails (within 1 µm of a bound passes). A negative `min` is a
|
|
515
|
+
press fit: the two may run into each other no deeper than that, measured as a depth (the volume they share over the
|
|
516
|
+
area where they meet), so a knob 1 mm into a block fails a fit whose `min` is -0.05. A negative `max` asks for at
|
|
517
|
+
least that depth, for a press fit that must grip. Round a pin pressed into its hole the depth reads a little deeper
|
|
518
|
+
than the interference (0.33 mm for 0.3 mm round a 3 mm pin). A `min` below -1 is
|
|
519
|
+
refused as deeper than any press fit, and a `min` above its `max` is refused (`fit.range`), on a fit of any kind
|
|
520
|
+
(a gap, an `engage`, a `seat`, a `shaft`). Where two parts may overlap by any amount (a rod through a part, an end
|
|
521
|
+
cap's pegs in a beam, a reference part drawn into another), say so with `"overlap": "allowed"` in place of the
|
|
522
|
+
`min`. Supports are left out: they're snipped off first.
|
|
523
|
+
Overlaps are measured by Manifold where it is installed and can read both parts; else by JSCAD, whose unions can
|
|
524
|
+
leave seams open (a flat face of no thickness across a bore). Such a face measures nothing, by itself or beside a
|
|
525
|
+
real overlap, which fails by its own volume. An overlap under 0.5 mm³ that only JSCAD measured is a warning that
|
|
526
|
+
says how to measure it with Manifold, not a failure (in the overlap check and in a fit it puts out of range), and
|
|
527
|
+
`--sweep` through one warns that the parts "may hit".
|
|
528
|
+
Where JSCAD finds faces that close into no solid and are no flat film, the overlap still fails, its volume given as
|
|
529
|
+
"about", with the same advice.
|
|
386
530
|
Objects with `"role": "reference"` (the MX switch) model things you don't print: drawn faint, never exported.
|
|
387
531
|
- **Hosts:** the core (resolve, build, check) reads and writes through a host (`lib/host.mjs`): Node's file system
|
|
388
532
|
for the CLI, or `memoryHost(files)`, a workspace in memory (reading the tool's own packages from disk), for tests
|
|
@@ -390,27 +534,51 @@ other items' variables, so a keycap can sit exactly where its slot meets the swi
|
|
|
390
534
|
page (`motionData`) are in the library too, so other programs make the same links without the CLI:
|
|
391
535
|
`import { memoryHost, useHost } from '@rulecad/cad/host'`, and likewise `/design`, `/assembly`, `/links`, `/edit`,
|
|
392
536
|
`/explain`, `/schema`, `/errors`, `/optimise`, `/rules`, `/workspace`, `/versions`, `/layout`, `/preview`, `/targets`, `/threemf`.
|
|
393
|
-
- **Engines:** designs get `v.ops` (union, subtract, intersect):
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
the package's own,
|
|
409
|
-
|
|
410
|
-
`fetch` and its kin are gone, and
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
537
|
+
- **Engines:** designs get `v.ops` (union, subtract, intersect): Manifold's (faster, watertight; `npm install
|
|
538
|
+
manifold-3d`) with `"engine": "manifold"` in the object's JSON, `CAD_ENGINE=manifold` for one run, or `"engine":
|
|
539
|
+
"manifold"` in cad.config.json for the workspace (a new workspace has it, and manifold-3d in its package.json);
|
|
540
|
+
JSCAD's otherwise. Where the workspace asks for Manifold and manifold-3d isn't installed, designs are built with
|
|
541
|
+
JSCAD and cad says so once; an object that asks for it by name is refused until it is installed. An object's
|
|
542
|
+
`"engine": "jscad"` keeps it on JSCAD in a Manifold workspace (`CAD_ENGINE` still sets every design for one run).
|
|
543
|
+
- **Sandbox:** a design (a board design's too) runs in a separate Node process under Node's permission model, with
|
|
544
|
+
none of your environment (no tokens), and an import hook on top to keep it to making shapes. What it can do there
|
|
545
|
+
depends on the Node it runs on:
|
|
546
|
+
|
|
547
|
+
| A design … | Node 22.13 to 22.14 | Node 22.15 to 24 | From Node 25 | What holds it |
|
|
548
|
+
|---|---|---|---|---|
|
|
549
|
+
| writes or deletes files | never | never | never | Node's permission model (no `--allow-fs-write`) |
|
|
550
|
+
| starts programs or loads addons | never | never | never | the permission model (no `--allow-child-process` or `--allow-addons`) |
|
|
551
|
+
| starts threads | never | never | never | the permission model (`--allow-worker` only where the hook needs one), and the runner, which shuts Node's modules to the design |
|
|
552
|
+
| reads files | only its project's files and the packages below, by importing them | the same | the same | the import hook, and below it the permission model, which holds a design that finds a way round the hook (through an allowed package's own CommonJS code, say) to the same folders: of the workspace only the design's own project, its `package.json` and the design's own cache folders (never another project; and since the permission model follows a link wherever it leads, a link anywhere in the project, its `node_modules` too, that leads to another project or out of the workspace stops the design before it runs, and a cache folder that holds a link is not read), and the tool, the `node_modules` folders above them and the packages designs use |
|
|
553
|
+
| imports | the packages below and its project's files: never Node's own modules, and never a CommonJS file (`.cjs`, or `require` and `module.exports`) | the same | the same | the import hook, and the runner, which shuts Node's own modules to the CommonJS loader before the design loads; those that reach the network, other programs or workers (`net`, `http`, `dns`, `child_process`, `worker_threads`, `vm` and the rest) load for no one at all, the tool's own code included |
|
|
554
|
+
| sends over the network | no way the tests know of | the same | never | from Node 25 the permission model (no `--allow-net`); before it, rulecad's runner alone (`fetch` and its kin are gone, none of Node's modules that reach the network loads, whoever asks, and the design's standard streams are plain ones with no socket behind them) |
|
|
555
|
+
|
|
556
|
+
The packages a design may import are <!-- ALLOWED -->`@jscad/modeling`, `@rulecad/shapes`, `@rulecad/flexures`,
|
|
557
|
+
`@rulecad/gears`, `@rulecad/motors`, `@rulecad/frames`, `@rulecad/fixings`<!-- /ALLOWED --> (the hook's own list,
|
|
558
|
+
`ALLOWED` in `lib/sandbox-hooks.mjs`), and no `node:` modules by `import` or `require()`. A design and its project's
|
|
559
|
+
files are ES modules (`import` and `export`): a CommonJS file of the project is refused before it runs, with
|
|
560
|
+
`designs can't load …: it is a CommonJS file`, as one could reach Node's own modules past the hook. Before Node 25
|
|
561
|
+
what keeps a design off the network is rulecad's own runner, in the design's own process, not Node: cad says so once
|
|
562
|
+
a run, `designs are kept off the network on Node 24 by rulecad alone, not by Node itself: use Node 25 or above for
|
|
563
|
+
designs you did not write`. Run only designs you trust, as with any code; from Node 25 Node itself holds the
|
|
564
|
+
writing, programs and network rows. (`test/sandbox-docs.test.mjs`, `test/sandbox-loader.test.mjs` and
|
|
565
|
+
`test/sandbox.test.mjs` try the writing, reading, importing, programs and network rows, and the ways round them, on
|
|
566
|
+
the Node they run on; the other rows rest on the Node flags they name.)
|
|
567
|
+
It reads by real paths: a `node_modules` link spelled through another link, as macOS spells its temporary folders
|
|
568
|
+
through `/tmp` and `/var`, is refused by name (make the link with the real path). A link inside the workspace that
|
|
569
|
+
leads out of it (a design's file, a folder of its project or a rule set in `rules/` that is a link to a file
|
|
570
|
+
elsewhere, which a workspace cloned from someone else can hold) is refused before the design runs, and whenever
|
|
571
|
+
rulecad reads one of the workspace's own files, with `workspace.outside` and the link's name, so no file of yours
|
|
572
|
+
elsewhere is read into a build or a model link; a kept result in `.cache/` that is such a link is not read but made
|
|
573
|
+
afresh, and a link anywhere in `.versions/` (where a released version is unpacked to build it) stops the command,
|
|
574
|
+
named, with nothing written or removed through it. To share a file between workspaces, copy it into each, or put it in a package and install that (the
|
|
575
|
+
workspace's own `node_modules` is the packages', and may link anywhere). A target named in cad.config.json is held
|
|
576
|
+
to the same, by its real path. An import of a package must lead inside that package: a file of it is named by its
|
|
577
|
+
path there (`@jscad/modeling/src/primitives/index.js`), never with `..`, `.`, `node_modules`, a backslash, `%` or
|
|
578
|
+
`~`, and the file it finds must be the package's own, as rulecad finds it, or one in the project, so no path or link
|
|
579
|
+
climbs out of it to another file. A file of such a package may in turn import only what that package depends on (its
|
|
580
|
+
own tests' tools are refused).
|
|
581
|
+
It gets its values as data and returns its parts; what it prints
|
|
414
582
|
(`console.log`) comes out on stderr. What comes back is checked before it is used, since the design could have
|
|
415
583
|
written it itself: a reply that is not one rulecad makes stops the build with a `design.sandbox` message, and the
|
|
416
584
|
only files written from a reply are the cache's slow stages, each in the design's own folder of `.cache/stages/`,
|
|
@@ -421,7 +589,12 @@ other items' variables, so a keycap can sit exactly where its slot meets the swi
|
|
|
421
589
|
(a stage that goes is worked out again next time). A design may run for an hour (3600 s) and its JavaScript may hold 4096 MB, its process 512 MB
|
|
422
590
|
more in all (Node itself, typed arrays, WebAssembly memory, output not yet sent): past any limit its process is
|
|
423
591
|
stopped and the build fails with `design.time` or `design.memory`, naming the design, so a design that loops for
|
|
424
|
-
ever or fills memory without end can't hang the command or take the machine down with it.
|
|
592
|
+
ever or fills memory without end can't hang the command or take the machine down with it. If the command
|
|
593
|
+
itself is stopped from outside (its terminal closed, its job cancelled), a small guard process it starts ends the
|
|
594
|
+
design's process with it, so no design is left running. A command that comes to its own end, pass or fail, first
|
|
595
|
+
waits until the design's process and the guard have gone: nothing of it is left in the workspace's folder, which a
|
|
596
|
+
script can move or remove the moment the command returns (Windows refuses while a process still sits in a folder).
|
|
597
|
+
What a design sends back
|
|
425
598
|
is kept only up to its memory limit, and what it prints only its last megabyte, so it can't fill the tool's own
|
|
426
599
|
process either. A slow design that needs more raises them in cad.config.json (`"designTimeout"` in seconds,
|
|
427
600
|
`"designMemory"` in megabytes; above the defaults, once the workspace is trusted with `cad trust`) or with
|
|
@@ -446,7 +619,25 @@ other items' variables, so a keycap can sit exactly where its slot meets the swi
|
|
|
446
619
|
only its own designs in the tool's process: one from another folder (a path to it, or a link out) is refused. A
|
|
447
620
|
workspace held in memory (`memoryHost`, for tests and later a browser or an editor's server) runs its designs in the
|
|
448
621
|
same sandbox, through the host's `runDesign` (a copy of the design's project in a temporary folder, removed after),
|
|
449
|
-
and in the tool's own process only when `build` is called with `{ trusted: true }`.
|
|
622
|
+
and in the tool's own process only when `build` is called with `{ trusted: true }`. (`test/sandbox.test.mjs`,
|
|
623
|
+
`test/target-trust.test.mjs`, `test/board-trust.test.mjs` and `test/sandbox-limits.test.mjs` try each of these.)
|
|
624
|
+
- **Programs cad starts:** cad itself starts a few of your computer's programs: git (for versions: `status`, `link`,
|
|
625
|
+
`show`, `history`, `diff`, `compare` and `release`, and `check` or `build` of a release such as `home/tray@1.2.3`),
|
|
626
|
+
`gh` (short links through a GitHub Gist) and the file browser (`open`, `explorer` or `xdg-open`, for `--open`). It
|
|
627
|
+
finds each in the folders on your PATH and starts it by the full path it found, never through a shell: never from the
|
|
628
|
+
workspace's own folder (where Windows looks first for a program named without its folder), never from a folder of
|
|
629
|
+
PATH inside the workspace (npm puts the workspace's `node_modules/.bin` there), and never from a PATH entry that is
|
|
630
|
+
not a full path, such as `.`. On Windows only a `.com` or `.exe` is taken. If one is not found, cad says which, and
|
|
631
|
+
that it should be installed or its folder added to PATH. A workspace that comes with its `.git` folder (in an
|
|
632
|
+
archive, or copied) brings git's settings and hooks with it, and those can name programs for git to run. The git
|
|
633
|
+
commands cad runs to read a workspace (its releases, what has changed since) run none of them: each is started with
|
|
634
|
+
git's file system monitor off, its hooks looked for where there are none, no pager, nothing written back to git's
|
|
635
|
+
index, and every filter and diff program git's settings name switched off. A release is different: `cad release`
|
|
636
|
+
commits, tags and pushes as `git commit`, `git tag` and `git push` do by hand, so the repository's own hooks (such as
|
|
637
|
+
pre-commit), filters, signing and push settings run, as they do for your own commits. So before you release in a
|
|
638
|
+
workspace that came from someone else with its `.git` folder, look at its settings (`git config --list
|
|
639
|
+
--show-origin`) and its `.git/hooks` folder, or start its git afresh (move `.git` aside, then `git init`).
|
|
640
|
+
(`test/workspace-programs.test.mjs` tries each of these.)
|
|
450
641
|
- **Mistakes are named:** a design that reads a variable that isn't there (`v.widht`) stops with the name it
|
|
451
642
|
probably meant, not a shape drawn from `undefined`; errors in a design carry its file and line.
|
|
452
643
|
- **Units:** `cad check` warns where an expression mixes units (millimetres added to degrees, a sine of a length) or
|
|
@@ -547,8 +738,9 @@ paste: `{ "screw": "M2 cap", "through": ["pcb.board"], "into": "case.body", "hol
|
|
|
547
738
|
read from the fit's `fastener` (`M2x6`), else from a thread set the holes fit's `depth` names (`m2.insert_length`),
|
|
548
739
|
else from the board's holes as drawn: the largest metric thread narrower than the narrowest hole. `cad add fasten
|
|
549
740
|
<project>/<assembly> --from-fits` writes it in their place: the holes fit goes, the fit that fastens keeps its gap
|
|
550
|
-
range (`min`, `max`) with `fastens`, `fastener` and `count` taken off, or goes too where
|
|
551
|
-
countersunk"` gives another screw. Screws driven from below (`"direction": "up"`) are
|
|
741
|
+
range (`min`, `max`) and its `"overlap": "allowed"` with `fastens`, `fastener` and `count` taken off, or goes too where
|
|
742
|
+
it had neither. `--screw "M2x8 countersunk"` gives another screw. Screws driven from below (`"direction": "up"`) are
|
|
743
|
+
left for you to write.
|
|
552
744
|
|
|
553
745
|
`cad list` counts every fixing (`fasten.count`): each screw, nut, washer and insert a `fasten` placed (a component's
|
|
554
746
|
too), a motor's mounting screws where a fit that `fastens` holds it (as many as its holes, at the length its mount
|
|
@@ -588,10 +780,11 @@ draws its hole or pocket from the printer's rules:
|
|
|
588
780
|
|
|
589
781
|
`cad list` lists pins (printed, cut or bought) and magnets (bought) with their grams, and printed bolts among the
|
|
590
782
|
printed parts; `cad order` names each on its step. A fastener given as text (`"fastener": "push pin"`) is listed as
|
|
591
|
-
written, unchecked. The fits these rest on (`x1c.
|
|
592
|
-
`
|
|
593
|
-
|
|
594
|
-
|
|
783
|
+
written, unchecked. The fits these rest on (`x1c.pin_press`, `pin_slip`, `magnet_press`, `magnet_glue`,
|
|
784
|
+
`magnet_crush`, and a plastic's `strength_z`) are estimates until the holds coupon measures them (`x1c.snap_clearance`
|
|
785
|
+
is measured, on the launcher's fit test plate, and the coupon measures it again for your printer):
|
|
786
|
+
`cad coupons` adds it to your workspace with its `MEASURE.md` (rows 40 to 47), and `cad measured
|
|
787
|
+
x1c.pin_press=<figure>` writes the result back, refusing a figure no fit of its kind can be.
|
|
595
788
|
|
|
596
789
|
### Joints and poses
|
|
597
790
|
|
|
@@ -649,9 +842,12 @@ then y, then z, as `rotate` does.
|
|
|
649
842
|
wrong height or on the wrong step of a compound gear would. This overlap rule covers spur, internal and rack meshes;
|
|
650
843
|
worms and bevels are placed by their own checks. Both gears' axes sit on
|
|
651
844
|
one part, or on parts held still; planets on a carrier are a `planetary`.
|
|
652
|
-
- **Worms and bevels:** `"worm": true` (or `{ "diameter", "hand" }`) in a mesh makes the
|
|
653
|
-
this one its wheel, `teeth` [starts, the wheel's], the axes crossed at right angles; the
|
|
654
|
-
whether it locks, and the centre distance.
|
|
845
|
+
- **Worms and bevels:** `"worm": true` (or `{ "diameter", "hand", "flanks", "overhang" }`) in a mesh makes the
|
|
846
|
+
driving joint a worm and this one its wheel, `teeth` [starts, the wheel's], the axes crossed at right angles; the
|
|
847
|
+
check says the ratio, whether it locks, and the centre distance. A worm is drawn to print standing, the flank of its
|
|
848
|
+
thread that faces down laid back, so the check also says which flank drives and its contact ratio (`worm.flanks`):
|
|
849
|
+
give the mesh the `"flanks"` (`"standard"` for the full thread) and `"overhang"` the object gives `v.gears.worm`,
|
|
850
|
+
where it gives any. `"bevel": true` makes the two bevel gears, their axes meeting at the
|
|
655
851
|
shaft angle; the cones must share their apex (`mesh.bevel`). Both follow in phase, so `--sweep` turns them clean.
|
|
656
852
|
- **Planetary gearboxes:** `"planetary": [{ "sun": "sun", "carrier": "carrier", "ring": "ring", "planets": ["p0", "p1",
|
|
657
853
|
"p2"], "drive": "carrier", "module": 1, "teeth": ["sun.teeth", "p0.teeth", "ring.teeth"] }]` names the items. One of
|
|
@@ -834,8 +1030,9 @@ address stands for the faces near it, as `item@anchor` does (`"within"`, 10 mm b
|
|
|
834
1030
|
(`"at": "x1.a"`); its anchor `b1` is its screw's, and its `ops` say the tap the end needs. In a mechanism, hold it
|
|
835
1031
|
as anything else is held: a foot by a `fasten` of its screw into the beam (`{ "screw": "M5 cap", "through": ["foot1"],
|
|
836
1032
|
"into": "p1", "at": ["foot1.b1"] }`, the beam's end tapped as its `ops` say), and an end cap by a fit that fastens,
|
|
837
|
-
its pegs
|
|
838
|
-
and an in-slot panel edge or a slot cover by what stands above the face alone: the rest lies in the
|
|
1033
|
+
its pegs standing in the beam (`"overlap": "allowed"`). The overlap check measures an end cap without its pegs, which
|
|
1034
|
+
stand in the beam, and an in-slot panel edge or a slot cover by what stands above the face alone: the rest lies in the
|
|
1035
|
+
slot by design.
|
|
839
1036
|
A panel item (below) holds its sheet with clips; a panel corner or an in-slot edge is placed by hand as an item.
|
|
840
1037
|
- A `bracket`, `gusset`, `splice`, `hidden` or `anchor` join with a bought fitting's set by name (`"fitting":
|
|
841
1038
|
"fitting-motedis-bracket-20-b6"`, @rulecad/frames' README, Bought fittings) adds that fitting as an item placed
|
|
@@ -952,6 +1149,13 @@ address stands for the faces near it, as `item@anchor` does (`"within"`, 10 mm b
|
|
|
952
1149
|
`estimate` while any join's spring is one, even where the springs change no figure; `measured` when every join's
|
|
953
1150
|
is; `beams` with no joins); the rigid figure is the least the sag can be. The limit is a rail's own parallelism
|
|
954
1151
|
under a guide, else `"frame": { "limit": 0.2 }`, else the task's accuracy, else the beam's span over 360. Over it fails.
|
|
1152
|
+
Every beam is held to its own span over 360 too (or `frame.limit` where given; never the task's accuracy), by its
|
|
1153
|
+
worst sag anywhere along its length (each element's stations, not only its ends and joins), loaded or not: each beam
|
|
1154
|
+
over it fails, and where none is, the beam nearest its limit is said as the one pass. That sag is the beam's own
|
|
1155
|
+
bending, measured from the line through where it is held (its supports, and its joins to beams that reach a support
|
|
1156
|
+
without passing through it), so a short beam hanging from the middle of a long rail is not failed for the rail's
|
|
1157
|
+
sag; a beam held at one end only keeps its tip's whole drop, whatever hangs from it. A 3 m rail of MISUMI 2020 held at its ends sags about 9.96 mm on its own weight (Roark, table 8.1:
|
|
1158
|
+
5 w L⁴ / 384 E I), against 8.33 mm, and fails.
|
|
955
1159
|
A sag is given in mm to three places, or to three figures under 0.1 mm (0.00123 mm, 0.000352 mm). Where a beam of
|
|
956
1160
|
the frame is drawn printed, each sag is given after creep too: the frame solved again with the joins' springs, each
|
|
957
1161
|
printed beam bending as if at half its modulus (`PRINTED_DEFAULTS.creep_modulus`, an estimate), under every case but
|
|
@@ -1134,13 +1338,15 @@ a brace in both bays that way about 240 times ("frame checks: an open cube racks
|
|
|
1134
1338
|
nuts and the join, and `cad order` and the build page list them as the step before the one that makes it
|
|
1135
1339
|
(`5. Load 2 × slot-nut-6-misumi-m4-slide-in into y1's top slot through its end a, for plate2, before the blind join
|
|
1136
1340
|
of y1.a to p1.top@170 closes it`).
|
|
1137
|
-
- `frame.square`: each bay of the frame (four beams
|
|
1341
|
+
- `frame.square`: each bay of the frame (four beams round a rectangle in one plane, each neighbouring pair joined to each
|
|
1342
|
+
other or both joined to one beam there, as the top and bottom rings of a corner-post box meet through its posts: one
|
|
1343
|
+
finder, `lib/bays.mjs`, for this, the frame's solve, `frame.rack`, `cad order` and the build page), with its two diagonals,
|
|
1138
1344
|
inside corner to inside corner, and the difference between them to accept, stacked from its parts as an arm's
|
|
1139
1345
|
error budget stacks its joints (`squareness` in `@rulecad/frames`). Each beam of the bay whose end butts another
|
|
1140
|
-
beam of the bay sets the opening along it by its cut length: cut t long or short, it moves one diagonal against the
|
|
1346
|
+
beam of the bay, or the post its corner meets through, sets the opening along it by its cut length: cut t long or short, it moves one diagonal against the
|
|
1141
1347
|
other by t × span / d (span the opening along that beam, d the diagonal). Each join of the bay's beams lets the end
|
|
1142
1348
|
of `a` sit off by its play s along `b` (`JOIN_PLAY`, an estimate for every kind): s × span / d, span the opening
|
|
1143
|
-
along `b
|
|
1349
|
+
along `b` (a join to a post slips along the post, out of a ring's plane, so it adds nothing to the ring's). The difference to accept is their sum, the worst case, with their root-sum-square beside it, and the
|
|
1144
1350
|
finding lists each term. The cut tolerance is the assembly's `"frame": { "cut": { "tolerance": 1 } }` where given
|
|
1145
1351
|
(this workshop's saw, also taken by the cut list), else the profile's `cut_tolerance`, else 0.5 mm. A 260 × 200 mm
|
|
1146
1352
|
opening of MISUMI 2020 (d = 328.02 mm) with its two rails butting the posts and four blind joins: 2 × 0.5 × 260 / d
|
|
@@ -1188,12 +1394,14 @@ screws, the cut list, the frame checks, the build page) sees a hand-drawn frame.
|
|
|
1188
1394
|
joint `gantry`, with the poses `gantry-front` and `gantry-back`) or `shelf` (a box with `"shelves"` rings between,
|
|
1189
1395
|
default 1, spacing its height into equal clear bays). Beams across x are `x1`, `x2` .., along y `y1` .., by ring
|
|
1190
1396
|
from the bottom. The frame's outside starts at the origin.
|
|
1191
|
-
- `"inside"` is the clear volume it encloses, `[width, depth, height]` in mm; `"outside"` is the volume
|
|
1192
|
-
in
|
|
1397
|
+
- `"inside"` is the clear volume it encloses, `[width, depth, height]` in mm; `"outside"` is the volume the whole
|
|
1398
|
+
frame must fit in, its feet and end caps with it, so its beams come out smaller by what those add (refused on castor
|
|
1399
|
+
plates, whose castor is not drawn). Give one, as numbers. A portal takes `[width, height]`. `cad frame` says the
|
|
1400
|
+
whole frame's size, its feet and caps fitted, beside the beams'. A table's height is the clear height under its ring, a gantry's
|
|
1193
1401
|
under its side beams.
|
|
1194
1402
|
- `"profile"`: one square profile for every beam (2020, 3030, 4040 ..). A profile of two cells (2040) is refused:
|
|
1195
1403
|
its beams would face differently by how they lie.
|
|
1196
|
-
- `"join"` sets the corners, as a kind or `{ "kind", "fitting", "screw", "nut" }`. With a join against a face (`blind`,
|
|
1404
|
+
- `"join"` sets the corners, as a kind or `{ "kind", "fitting", "screw", "nut", "estimate" }`. With a join against a face (`blind`,
|
|
1197
1405
|
`end-tap`, `bracket`, `gusset`, `hidden`, `anchor`) the upright beams run through, top to bottom, and every other
|
|
1198
1406
|
beam butts against their faces, so it is shorter than the outside span it closes by the profile's width at each
|
|
1199
1407
|
end. With `cube` every beam butts into a corner node and is as long as the inside it bounds. A box round 300 x 300
|
|
@@ -1205,8 +1413,12 @@ screws, the cut list, the frame checks, the build page) sees a hand-drawn frame.
|
|
|
1205
1413
|
takes the first of `drop-in`, `roll-in`, `hammer` and `t-bolt` the kit has for the profile's slot (drop-in on
|
|
1206
1414
|
MISUMI's 2020, roll-in on item's 4040); `"nut"` names one of them, and `slide-in` is refused. A printed gusset lies
|
|
1207
1415
|
on the face of its upright that looks out of the frame (its join's `"face"`), so it never lands where the corner's
|
|
1208
|
-
third beam butts.
|
|
1209
|
-
|
|
1416
|
+
third beam butts. A join the kit cannot build is refused by name, saying what is missing: `cube` (its three-way
|
|
1417
|
+
corner comes with a later release), and `bracket`, `gusset`, `hidden` or `anchor` with no fitting (a printed one,
|
|
1418
|
+
or a bought set by name). `"estimate": true` (`cad new ... --estimate`) makes it all the same, each join warning
|
|
1419
|
+
`join.fitting` that no fitting is drawn, as a hand-drawn join does. A join that holds by slots is refused on a
|
|
1420
|
+
profile with none (a tube, a bar, an angle), and a blind or end-tap join on an inside too narrow for the taps at
|
|
1421
|
+
both ends of its butting beams (37 mm in 2020).
|
|
1210
1422
|
- A gantry's outside height is its inside plus three widths: the two rings and `g`, which lies on the top side beams
|
|
1211
1423
|
between the uprights' tops, its top level with theirs.
|
|
1212
1424
|
- `"feet"`: `foot`, `levelling` or `stacking` (printed), a bought foot's set by name, or a printed castor plate,
|
|
@@ -1294,7 +1506,8 @@ joins' springs, the loads and mounted items):
|
|
|
1294
1506
|
heavier profile's stiffer joins, nor refused a heavier profile on a lighter one's softer joins.
|
|
1295
1507
|
- `"limits"`: in place of the checks' own. Left out, each is the check's: the sag at each load, named point and guide
|
|
1296
1508
|
as `frame.deflection` holds it (a guide's rail parallelism, `frame.limit`, the task's accuracy, else the span over
|
|
1297
|
-
360; a load that moves with a joint anywhere along its beam),
|
|
1509
|
+
360; a load that moves with a joint anywhere along its beam), and every beam's own sag along its length (its bending, from where it is held) against
|
|
1510
|
+
its span over 360, each beam's stress with the joins' springs and with
|
|
1298
1511
|
them rigid against its alloy's strength `frame.margin` (2) times over, the frame's first buckling factor and each
|
|
1299
1512
|
grouped beam's Euler load (K 1) the same, and the lowest mode at twice the task's moves where it has a task.
|
|
1300
1513
|
`"deflection"` (mm, at every load, point and guide), `"stress"` and `"buckling"` (margins), `"frequency"` (Hz) and
|
|
@@ -1359,14 +1572,23 @@ limit: it is a bay's to brace, not a beam's to thicken.
|
|
|
1359
1572
|
|
|
1360
1573
|
Once an assembly is checked, these say how to make it. They all read the assembly itself, so they can't disagree with it.
|
|
1361
1574
|
|
|
1362
|
-
- `cad
|
|
1575
|
+
- `cad list <project>/<assembly>`: what to buy (bought parts, fixings, wire, the cut list) and what to print, each
|
|
1576
|
+
printed part's grams and an estimate of its minutes from its volume and the printer's `print_flow`: the printer the
|
|
1577
|
+
project names (`project.json`'s `printer`, else `cad.config.json`'s), as `cad check` reads it. The total says whose
|
|
1578
|
+
flow it used, and says so where it assumed one (a printer whose rule set gives no `print_flow`: 12 mm³/s) or the
|
|
1579
|
+
material's density (a material with no rule set: PLA's 1.25 g/cm³). `--json` gives the same as `totals.printer`,
|
|
1580
|
+
`totals.flow`, `flowAssumed` and `densityAssumed`.
|
|
1581
|
+
|
|
1582
|
+
- `cad order <project>/<assembly>`: the order it goes together in, each step with the part and what fastens it. A `fasten` names its screws on the step where its parts are both there, with the key that turns them and how tight: its `torque`, or half what the seat under the head takes, held for a screw in a thread in plastic to half what the thread is estimated to strip at (`2. bracket goes on: bracket fastened to base (2 × M3x10 cap) with a 2.5 mm hex key, to 0.12 N m at most (half what the seat takes)`); `--json` gives each as `{ fit, fastener, count, key, tighten: { torque, given } }` (with `thread: true` where the thread sets the torque, `load: true` where the joint's load does), and the build page shows the same. What is not a screw (pins, a clip) is named on a fit that fastens: `"fastener": "push pin", "count": 2` puts it on the shopping list and the step. `--preview` writes a picture of each step to `.preview/`: what's there, and the new part held off along the way it goes on. The order is found by taking the assembly apart, so a part goes in after what it's fastened into, a bearing before its shaft, and a nut trapped by a wall before the neighbour that traps it. A part goes on along a straight line that clears everything already there; which line comes from the part as drawn.
|
|
1363
1583
|
- `cad order` on a **frame** (an assembly with `joins`) gives its build from bars to a square frame, in numbered steps:
|
|
1364
1584
|
1. **Cut** the beams: each mark's count and length, the bars to buy and the cuts on each (the cut list).
|
|
1365
1585
|
2. **Drill and tap** each mark as its cut-and-drill sheet shows (each mark's work and its sheet's file).
|
|
1366
1586
|
3. **Sides built flat**: each bay that shares no beam with a side already chosen is built on the bench, beam by beam,
|
|
1367
1587
|
each beam's joins with their screws, key and torque, left snug (`Snug for now: tightened to its torque at step 8,
|
|
1368
1588
|
once square`), then squared by its diagonals and its joins tightened. Of
|
|
1369
|
-
two bays that share a post, the first found is a side and the other is squared once the frame is joined.
|
|
1589
|
+
two bays that share a post, the first found is a side and the other is squared once the frame is joined. A bay
|
|
1590
|
+
whose beams meet only through a post (the top and bottom rings of a corner-post box) is never a side, and is
|
|
1591
|
+
squared with the rest once every join is made, so the box is square in plan as well as on its upright faces.
|
|
1370
1592
|
4. **Nuts to load, heads slid in**: every blind join's head and every slot nut needs a way into its slot at the
|
|
1371
1593
|
step that puts it there: an end of the slot that nothing has closed yet (a join on that end, or an item placed
|
|
1372
1594
|
there) and nothing already in the slot between it and that end (a head, a nut). A beam going on slides along the
|
|
@@ -1489,7 +1711,7 @@ slotted face, its holes read from its own rule set (@rulecad/frames' README, Ser
|
|
|
1489
1711
|
printed carrier strip in the slot under the rail instead: a `nut-carrier` fitting item `<id>-nuts`, one hex nut
|
|
1490
1712
|
under each hole, slid in from the beam's end. The rail's screws go into its nuts as a fasten, and `cad list` counts
|
|
1491
1713
|
the strip with its grams and each nut once. An MGN7 cut to 200 mm on a 2020 takes a 189 mm strip of 9.3 g of PLA,
|
|
1492
|
-
thirteen M2x8 cap screws and thirteen M2 hex nuts; each nut holds about
|
|
1714
|
+
thirteen M2x8 cap screws and thirteen M2 hex nuts; each nut holds about 905 N straight out of the slot (an estimate
|
|
1493
1715
|
until tested). Where no carrier fits the slot either, `guide.fit` fails and says why.
|
|
1494
1716
|
- Each carriage (`"carriages"`, 1 by default) is a bought item `<id>-carriage-1`, ... on its own sliding joint
|
|
1495
1717
|
`<id>-1`, ... along the beam, from 0 to its travel: its share of the rail less its length with its seals. The
|
|
@@ -1498,7 +1720,9 @@ slotted face, its holes read from its own rule set (@rulecad/frames' README, Ser
|
|
|
1498
1720
|
table fixed on it.
|
|
1499
1721
|
- `cad check` says `guide.holes` (the holes, their pitch and the end distance; `guide.end` where an end is past half
|
|
1500
1722
|
the pitch), `guide.travel`, `guide.fit` (the rail on the face, a slot nut for its screws, its ends on the beam and
|
|
1501
|
-
clear of a beam joined across its face), `guide.budget` (what it adds to an error budget
|
|
1723
|
+
clear of a beam joined across its face), `guide.budget` (what it adds to an error budget: said after the frame is
|
|
1724
|
+
solved, its beam sag the frame's own figure under the rail, the one `frame.deflection` gives, and the rail's estimate
|
|
1725
|
+
only where the frame is not solved) and `guide.jig` (a
|
|
1502
1726
|
printed jig that centres the rail while it is screwed down, as a `rail-jig` fitting item).
|
|
1503
1727
|
- Each carriage's loads are held to its ratings at every pose (`joint.moment`): the weight of all it carries and the
|
|
1504
1728
|
masses of `"loads"` hung on it, as a force and a moment about its middle on the rail's top, in its own frame.
|
|
@@ -1803,7 +2027,7 @@ surface is also kept within the printer's overhang limit: faces smoothing tipped
|
|
|
1803
2027
|
The surface is drawn with many small triangles, and `cad optimise` thins them by default: the surface stays within
|
|
1804
2028
|
0.1 mm of where it was drawn (a quarter of an X1C's print line), closed, with no more overhang and no new tips, and
|
|
1805
2029
|
`cad optimise` says how many triangles it had and has. On the bracket bench's printable result that takes 75,592
|
|
1806
|
-
triangles to 21,124 and 27.808 cm³ to 27.806 cm³ (
|
|
2030
|
+
triangles to 21,124 and 27.808 cm³ to 27.806 cm³ (34.48 g of PLA at 1.24 g/cm³ either way, 0.003 g apart), a quarter
|
|
1807
2031
|
of the size in a file or a link. `"outline": { "reduce": 0.05 }` keeps the surface closer (31,154 triangles on the
|
|
1808
2032
|
bracket), and `"outline": { "reduce": false }` keeps every triangle it was drawn with.
|
|
1809
2033
|
|
|
@@ -1923,8 +2147,13 @@ placed parts in `.cache/overlaps.json`, keyed by each part's build and placement
|
|
|
1923
2147
|
about 10 s, and a re-check after an edit measures only what the edit moved. The build cache keeps its 800 most
|
|
1924
2148
|
recently used builds, keyed by what a build is made from: the design's code, its values resolved, its parts' names
|
|
1925
2149
|
and roles, the rule sets and the tool's own code; a rule's words, a label or the version change nothing it builds,
|
|
1926
|
-
so they don't start one.
|
|
1927
|
-
|
|
2150
|
+
so they don't start one. The files of its project a design imports (the starter lid's `./box.js`, and whatever those
|
|
2151
|
+
import) are part of what it is made from: a kept build lists them, and is used only while each reads as it did, so an
|
|
2152
|
+
edit to a shared helper rebuilds every design that imports it. (A package a design imports, such as
|
|
2153
|
+
`@jscad/modeling`, is not followed that way: it changes with an install, and the tool's own packages are in the key.)
|
|
2154
|
+
A lamina mechanism's slow stages (its physics, a flooded frame's probe) are kept apart in
|
|
2155
|
+
a folder of each design's own in `.cache/stages/`, keyed by their own inputs and by what works them out (the code of
|
|
2156
|
+
`@rulecad/flexures` and the packages it calls, and the installed manifold-3d and `@jscad/modeling`), so a build that changes only what comes after them (a strap, a check)
|
|
1928
2157
|
takes minutes rather than the twenty a launcher's physics takes; the design's sandbox reads them and hands back what
|
|
1929
2158
|
it made for the tool to write. `CAD_NO_CACHE=1` computes everything afresh (and keeps it).
|
|
1930
2159
|
|