@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.
Files changed (68) hide show
  1. package/AGENTS.md +29 -10
  2. package/CHANGELOG.md +604 -0
  3. package/EXAMPLES.md +122 -105
  4. package/README.md +292 -63
  5. package/bin/cad.mjs +500 -87
  6. package/lib/assembly.mjs +486 -134
  7. package/lib/bays.mjs +124 -0
  8. package/lib/cache-file.mjs +148 -0
  9. package/lib/clone.mjs +93 -11
  10. package/lib/code-text.mjs +28 -0
  11. package/lib/design-imports.mjs +127 -0
  12. package/lib/design.mjs +291 -59
  13. package/lib/designshapes.mjs +142 -0
  14. package/lib/edit.mjs +29 -5
  15. package/lib/estimates.mjs +51 -0
  16. package/lib/fasten.mjs +11 -5
  17. package/lib/fe-key.mjs +29 -0
  18. package/lib/fittings.mjs +20 -15
  19. package/lib/fixings.mjs +17 -4
  20. package/lib/framebuild.mjs +73 -92
  21. package/lib/framecheck.mjs +154 -77
  22. package/lib/framegen.mjs +9 -1
  23. package/lib/frames.mjs +6 -2
  24. package/lib/framesize.mjs +45 -82
  25. package/lib/gait.mjs +17 -7
  26. package/lib/guides.mjs +84 -50
  27. package/lib/host.mjs +7 -3
  28. package/lib/kit.mjs +5 -5
  29. package/lib/list.mjs +29 -21
  30. package/lib/live-guard.mjs +18 -8
  31. package/lib/loads.mjs +35 -23
  32. package/lib/measured.mjs +740 -99
  33. package/lib/mesh.mjs +156 -56
  34. package/lib/motors.mjs +26 -33
  35. package/lib/names.mjs +15 -0
  36. package/lib/node-version.mjs +52 -0
  37. package/lib/optimise.mjs +34 -25
  38. package/lib/order.mjs +5 -12
  39. package/lib/parts.mjs +3 -0
  40. package/lib/picture-servers.mjs +66 -0
  41. package/lib/power.mjs +14 -7
  42. package/lib/preview.mjs +12 -25
  43. package/lib/programs.mjs +113 -0
  44. package/lib/rules.mjs +2 -1
  45. package/lib/sandbox-guard.mjs +43 -0
  46. package/lib/sandbox-hooks.mjs +109 -15
  47. package/lib/sandbox-lock.mjs +225 -0
  48. package/lib/sandbox-preload.mjs +2 -2
  49. package/lib/sandbox-run.mjs +22 -24
  50. package/lib/sandbox.mjs +345 -42
  51. package/lib/sheet.mjs +114 -3
  52. package/lib/targets/gist.mjs +9 -6
  53. package/lib/versions.mjs +294 -35
  54. package/lib/workspace.mjs +6 -3
  55. package/package.json +14 -14
  56. package/schemas/assembly.schema.json +6 -5
  57. package/schemas/object.schema.json +1 -1
  58. package/schemas/project.schema.json +6 -0
  59. package/templates/coupons/MEASURE.md +109 -0
  60. package/templates/coupons/assemblies/fixings-test.json +20 -0
  61. package/templates/coupons/assemblies/slot-test.json +11 -0
  62. package/templates/coupons/objects/fixings-coupon.js +88 -0
  63. package/templates/coupons/objects/fixings-coupon.json +26 -0
  64. package/templates/coupons/objects/holds-coupon.js +130 -0
  65. package/templates/coupons/objects/holds-coupon.json +42 -0
  66. package/templates/coupons/objects/slot-coupon.js +89 -0
  67. package/templates/coupons/objects/slot-coupon.json +29 -0
  68. package/templates/coupons/project.json +10 -0
package/AGENTS.md CHANGED
@@ -8,7 +8,10 @@ variable says which rule it comes from. Follow these steps; they're what makes a
8
8
  1. **Rules first.** Find the facts the part depends on: standards, the thing it fits, the printer. Put shared ones in
9
9
  `rules/<set>.json` with `kind`, `source` and `checked`. Research them, don't guess. Ask the person to measure what
10
10
  can't be looked up, and record it as `"kind": "measured"`; something nobody has published goes in as
11
- `"kind": "estimate"`, and the check will flag it.
11
+ `"kind": "estimate"`, and the check will flag it. A set from the kit is copied into `rules/` the first time a design
12
+ uses it; when `npx cad rules check` notes `rules.changed` or `rules.new` (the kit has corrected or added figures
13
+ since), run `npx cad rules update <set>`: it takes the kit's figures and keeps the measured ones. Say in your report
14
+ which figures moved, and check the designs that use them.
12
15
  2. `npx cad new <project>/<object>`, then write the variables in the .json and the shape in the .js. No numbers in
13
16
  the .js other than 0, 1 and 2: `cad check` fails on any other.
14
17
  3. `npx cad check`, then `npx cad preview`, and **look at the preview image** before saying it's done. Check the views
@@ -39,6 +42,16 @@ variable says which rule it comes from. Follow these steps; they're what makes a
39
42
  ## Changing a design
40
43
  1. `npx cad history <project>/<object>` first: read the print log. A failed print is the reason for most changes:
41
44
  fix the rule or variable it points at (a measured fit beats a community rule).
45
+ A figure the person measured goes back with `npx cad measured <project>/<assembly> <name>=<value>`: report what it
46
+ says moved. `--table` (`--json`) lists what is still unmeasured and the coupon that measures each. A figure of the
47
+ other sign, or under half or over twice the old one (a tenth to ten times for an estimate; 0 passes for a figure a
48
+ kit coupon measures), is refused as a likely slip: ask the person to measure again, and add `--force` only once
49
+ they confirm it. `--strike <date> <name>` takes a mistaken row out of the ledger; set the rule file it names back
50
+ too. The kit's coupons (test prints that settle the printer's holes, nuts, pins and slot fits) come into the
51
+ workspace with `npx cad coupons`, as `projects/coupons` with a MEASURE.md that says how to read each. A coupon's
52
+ figure needs no assembly: `npx cad measured x1c.pilot_m3=<value>`, and `npx cad history` lists those.
53
+ `npx cad measured --export` prints what was measured as a diff of the kit's rule sets: offer it to the person to
54
+ send to the kit, with the printer and plastic.
42
55
  2. Change, then check, preview and look, as for a new part. Change values with `npx cad set <project>/<object>
43
56
  name=value` and assemblies with `npx cad add fit|joint|item|beam|pose|fasten|join|guide|load …`, `npx cad set
44
57
  <project>/<assembly> x1.at=… joins.0.kind=…`, `npx cad move` and `npx cad remove`: they keep the file's layout and
@@ -71,11 +84,15 @@ variable says which rule it comes from. Follow these steps; they're what makes a
71
84
  bends within its layers; give its thickness in whole lines (`x1c.line`), and check its strain at the travel against
72
85
  the material's limit with `v.flexures.printable`. PLA creeps held bent and fatigues; PETG or nylon for springs.
73
86
  - Use the print-aware features in `v.shapes` before drawing your own: `teardropHole`, `crushRibs`, `wallOpening`
74
- print without supports as drawn (and `countersink` and `nutPocket` for a size that is no screw's). Use `v.ops.union/subtract/intersect` for booleans: the
75
- workspace can switch them to Manifold (faster, watertight) without touching the design.
76
- - Designs run sandboxed: they may import only `@jscad/modeling`, `@rulecad/shapes`, `@rulecad/flexures`,
77
- `@rulecad/gears`, `@rulecad/motors`, `@rulecad/fixings` and files in their project, and can't write files or start
78
- programs. To see a value while designing, `console.log` it: it comes
87
+ print without supports as drawn (and `countersink` and `nutPocket` for a size that is no screw's). Use `v.ops.union/subtract/intersect` for booleans: they
88
+ run in Manifold (faster, watertight) where the workspace has `manifold-3d` installed and `"engine": "manifold"` in
89
+ cad.config.json, as a new workspace has, and in JSCAD otherwise, with no change to the design. JSCAD can leave seams
90
+ that read as overlaps: an overlap finding that names Manifold (parts that "may overlap" or "may hit", or overlap by
91
+ "about" a figure) is settled by doing what it says (`npm install manifold-3d`, or building the part it names with
92
+ Manifold), never by widening a bore or a gap.
93
+ - Designs run sandboxed: they may import only <!-- ALLOWED -->`@jscad/modeling`, `@rulecad/shapes`,
94
+ `@rulecad/flexures`, `@rulecad/gears`, `@rulecad/motors`, `@rulecad/frames`, `@rulecad/fixings`<!-- /ALLOWED --> and
95
+ files in their project, and can't write files or start programs. To see a value while designing, `console.log` it: it comes
79
96
  out with the command's output. A misspelt `v.name` stops the build and says which name was meant.
80
97
  A design may run for an hour (3600 s) and hold 4096 MB: `design.time` or `design.memory` means it was stopped
81
98
  there, most often by a loop that never ends. Fix the loop; raise `designTimeout` or `designMemory` in
@@ -161,8 +178,10 @@ variable says which rule it comes from. Follow these steps; they're what makes a
161
178
  estimate).
162
179
  - **A frame for a size starts from a generator**: `"frame": { "kind": "box", "inside": [w, d, h], "profile",
163
180
  "join": "blind" }` (also portal, table, gantry, shelf) expands into beams, joins, feet and caps before anything is
164
- checked. Ask by `inside` for what it must enclose, `outside` for what it must fit in; never work the lengths out by
165
- hand. Make it with `npx cad new <project>/<assembly> --assembly --frame box --inside 300,300,350 --profile …
181
+ checked. Ask by `inside` for what it must enclose, `outside` for what it must fit in (its feet and end caps with
182
+ it); never work the lengths out by hand. A join the kit cannot build yet (cube; bracket, gusset, hidden or anchor
183
+ with no fitting) is refused unless it says `"estimate": true`. Make it with
184
+ `npx cad new <project>/<assembly> --assembly --frame box --inside 300,300,350 --profile …
166
185
  --join blind`, which says what it expands into before it writes. Read `frame.generated` for what it made, and
167
186
  `npx cad frame <project>/<assembly> --expand` to write it out when it needs changes a generator cannot make, then
168
187
  change the beams and joins with `cad set`, `cad move`, `cad add` and `cad remove` as a hand-drawn frame's.
@@ -225,7 +244,7 @@ variable says which rule it comes from. Follow these steps; they're what makes a
225
244
  `exports/<project>/<assembly>-kit/` (the build page as README.md, buy.csv, each plate's 3MF and the jigs', each
226
245
  mark's sheet; `--pictures` adds the steps' pictures). It refuses a design whose check fails: fix the failures, never
227
246
  hand on a kit of one. `npx cad plates` lays out every printed part by material, with a frame's jigs beside them.
228
- A new frame project can start from `npm create rulecad my-frame --machine frame --size 300x300x350 --profile
247
+ A new frame project can start from `npm create rulecad my-frame -- --machine frame --size 300x300x350 --profile
229
248
  2020-misumi-hfs5`.
230
249
  - What holds parts with no steel screw is named in the fit's `fastener`, never typed in a note:
231
250
  `{ "pin": "snap pin 4x6", "count": 2 }`, `{ "pin": "dowel 3x12", "fit": "press" }`, or
@@ -301,7 +320,7 @@ EXAMPLES chapter 12 builds one from start to finish.
301
320
  - Before moving anything: `cad plot` the drawing and watch the preview. It refuses a stroke that leaves the sheet.
302
321
  - **A gait is the same idea for a body.** Give an assembly a `gait` (`legs`, `pattern`, `stride`, `lift`, `period`, `height`, `mass`): the body at the world origin, the hips at z = 0, the feet as anchors. One leg on a stand is a gait of one leg (`"pattern": { "duty": 0.6, "phase": [0] }`). Anchor a round foot at its centre, so the contact rolls with the shin and the height stays true. Report a gait's numbers as they are: quasi-static, the torque from the weight alone, no dynamics.
303
322
  - **Say what the machine weighs.** A robot built from these parts is heavier than the first sizing said it was: list `cad list`'s grams and set the gait's `mass` to that, and report the torque margin at the real mass.
304
- - Start a machine from a template rather than from an empty assembly: `npm create rulecad my-arm --machine arm --sheet a5 --accuracy 0.3`, or `--machine leg`.
323
+ - Start a machine from a template rather than from an empty assembly: `npm create rulecad my-arm -- --machine arm --sheet a5 --accuracy 0.3`, or `--machine leg`.
305
324
 
306
325
  ## Talking to the person
307
326
  - Give links as one labelled line (`npx cad link <project>/<object> --md`), never a raw URL. If it says