create-rulecad 0.3.15 → 0.3.17

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 (54) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +5 -2
  3. package/index.mjs +3 -2
  4. package/machines/arm/projects/arm/assemblies/arm.json +18 -4
  5. package/machines/arm/projects/arm/objects/base.js +6 -4
  6. package/machines/arm/projects/arm/objects/base.json +5 -6
  7. package/machines/arm/projects/arm/objects/bridge.js +4 -2
  8. package/machines/arm/projects/arm/objects/bridge.json +5 -4
  9. package/machines/arm/projects/arm/objects/clip.js +3 -1
  10. package/machines/arm/projects/arm/objects/clip.json +1 -2
  11. package/machines/arm/projects/arm/objects/forearm.js +10 -5
  12. package/machines/arm/projects/arm/objects/forearm.json +8 -4
  13. package/machines/arm/projects/arm/objects/holder.js +5 -2
  14. package/machines/arm/projects/arm/objects/holder.json +2 -3
  15. package/machines/arm/projects/arm/objects/housing.js +6 -3
  16. package/machines/arm/projects/arm/objects/housing.json +6 -6
  17. package/machines/arm/projects/arm/objects/output.js +3 -1
  18. package/machines/arm/projects/arm/objects/output.json +1 -2
  19. package/machines/arm/projects/arm/objects/spindle.js +5 -2
  20. package/machines/arm/projects/arm/objects/spindle.json +8 -7
  21. package/machines/arm/projects/arm/objects/upper.js +6 -3
  22. package/machines/arm/projects/arm/objects/upper.json +5 -6
  23. package/machines/arm/rules/arm.json +3 -3
  24. package/machines/leg/projects/leg/assemblies/stand.json +12 -2
  25. package/machines/leg/projects/leg/objects/bridge.js +4 -2
  26. package/machines/leg/projects/leg/objects/bridge.json +5 -4
  27. package/machines/leg/projects/leg/objects/carriage.js +3 -1
  28. package/machines/leg/projects/leg/objects/carriage.json +2 -3
  29. package/machines/leg/projects/leg/objects/clip.js +3 -1
  30. package/machines/leg/projects/leg/objects/clip.json +1 -2
  31. package/machines/leg/projects/leg/objects/collar.js +3 -1
  32. package/machines/leg/projects/leg/objects/collar.json +1 -2
  33. package/machines/leg/projects/leg/objects/foot.js +3 -1
  34. package/machines/leg/projects/leg/objects/foot.json +1 -2
  35. package/machines/leg/projects/leg/objects/housing.js +6 -3
  36. package/machines/leg/projects/leg/objects/housing.json +6 -6
  37. package/machines/leg/projects/leg/objects/output.js +3 -1
  38. package/machines/leg/projects/leg/objects/output.json +1 -2
  39. package/machines/leg/projects/leg/objects/shin.js +4 -2
  40. package/machines/leg/projects/leg/objects/shin.json +6 -4
  41. package/machines/leg/projects/leg/objects/spindle.js +5 -2
  42. package/machines/leg/projects/leg/objects/spindle.json +8 -7
  43. package/machines/leg/projects/leg/objects/thigh.js +5 -2
  44. package/machines/leg/projects/leg/objects/thigh.json +2 -4
  45. package/machines/leg/rules/leg.json +2 -2
  46. package/package.json +2 -1
  47. package/template/AGENTS.md +73 -7
  48. package/template/README.md +14 -0
  49. package/template/projects/home/assemblies/lidded-box.json +18 -0
  50. package/template/projects/home/objects/box.js +20 -0
  51. package/template/projects/home/objects/box.json +61 -0
  52. package/template/projects/home/objects/lid.js +11 -0
  53. package/template/projects/home/objects/lid.json +21 -0
  54. package/template/projects/home/project.json +1 -1
@@ -3,7 +3,7 @@
3
3
  "name": "thigh",
4
4
  "title": "Thigh",
5
5
  "version": "0.1.0",
6
- "uses": ["x1c", "leg", "m3"],
6
+ "uses": ["x1c", "leg"],
7
7
  "engine": "manifold",
8
8
  "orientation": "The thigh's outer face on the bed: the hub, the knee's fixed ring and its posts all rise from the one flat face",
9
9
  "description": "From the hip's hexagon to the knee's motor. The drawing arm's upper arm, shorter and without its home switch or bands: printed as one part with the knee's fixed ring, so the knee's gearbox costs a sun, three planets and an output ring.",
@@ -27,7 +27,6 @@
27
27
  "hex_depth": {"value": "thick + collar - floor", "unit": "mm", "rule": "The socket's depth"},
28
28
  "floor": {"value": 3, "unit": "mm", "rule": "What the screw pulls against: a socket's floor"},
29
29
  "hex_fit": {"value": "x1c.fit + x1c.hole_comp", "unit": "mm", "rule": "Across the socket's flats, over the spindle's, printed"},
30
- "screw": {"value": "m3.clearance + x1c.hole_comp", "unit": "mm", "rule": "M3 clearance"},
31
30
  "gear": {"value": "leg.gear", "unit": "mm", "rule": "The fixed ring's face"},
32
31
  "arm_gap": {"value": "leg.ring_gap", "unit": "mm", "rule": "Between the fixed ring and the output ring"},
33
32
  "rim": {"value": 62, "unit": "mm", "rule": "Round the 54-tooth ring"},
@@ -42,8 +41,7 @@
42
41
  "rad": {"value": 0.017453293, "rule": "Radians in a degree"},
43
42
  "clip_at": {"value": "thick + gear + arm_gap + gear + leg.flange + clip_gap", "unit": "mm", "rule": "Each post's tip, where its clip goes on, just past the output's flange"},
44
43
  "clip_gap": {"value": 0.3, "unit": "mm", "rule": "The output turns under the clips with this to spare"},
45
- "pilot": {"value": 2.9, "unit": "mm", "rule": "An M3 screw self-tapped into a post", "kind": "community"},
46
- "pilot_depth": {"value": 8, "unit": "mm", "rule": "For an M3 × 10 through a clip"},
44
+ "pilot_depth": {"value": 8, "unit": "mm", "rule": "Each post's pilot, deep enough for its clip's screw"},
47
45
  "segments": {"value": 64, "rule": "Round enough"},
48
46
  "ring_segments": {"value": 96, "rule": "The rim's circle"},
49
47
  "hex_segments": {"value": 6, "rule": "A hexagon's sides"},
@@ -2,10 +2,10 @@
2
2
  "_doc": "A leg made from the drawing arm's parts: the stack of the same gearbox, with the arm's motor face as this leg's zero, what the leg is asked to stand up, and the stand it does that on. Examples chapter 14 explains each.",
3
3
  "name": "leg",
4
4
  "rules": {
5
- "plate": {"value": 5, "unit": "mm", "rule": "The hip housing's plate: enough for M3 screws into a NEMA 17 (1.5 × their size)", "kind": "default", "source": "EXAMPLES chapter 11's housing", "checked": "2026-11-09"},
5
+ "plate": {"value": 5, "unit": "mm", "rule": "The hip housing's plate: deep enough for the motor's four screws to bite, 1.5 times their thread", "kind": "default", "source": "EXAMPLES chapter 11's housing", "checked": "2026-11-09"},
6
6
  "gear": {"value": 8, "unit": "mm", "rule": "Each gear stage's face", "kind": "default", "source": "EXAMPLES chapter 11's gearbox", "checked": "2026-11-09"},
7
7
  "ring_gap": {"value": 0.4, "unit": "mm", "rule": "Between the fixed ring and the output ring", "kind": "default", "source": "EXAMPLES chapter 11's gearbox", "checked": "2026-11-09"},
8
- "flange": {"value": 5, "unit": "mm", "rule": "The output ring's flange: thick enough for four M3 screws to bite", "kind": "default", "source": "EXAMPLES chapter 12", "checked": "2026-11-09"},
8
+ "flange": {"value": 5, "unit": "mm", "rule": "The output ring's flange: thick enough for the spindle's four screws to bite", "kind": "default", "source": "EXAMPLES chapter 12", "checked": "2026-11-09"},
9
9
  "output_top": {"value": "plate + gear + ring_gap + gear + flange", "unit": "mm", "rule": "The top of the hip's output flange, from the motor's face", "kind": "default", "source": "The stack", "checked": "2026-11-09"},
10
10
  "disc": {"value": 3, "unit": "mm", "rule": "The spindle's disc, on the flange", "kind": "default", "source": "EXAMPLES chapter 12", "checked": "2026-11-09"},
11
11
  "bridge_gap": {"value": 0.6, "unit": "mm", "rule": "Between the spindle's disc and the bridge above it", "kind": "default", "source": "EXAMPLES chapter 12", "checked": "2026-11-09"},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-rulecad",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "description": "Start a rulecad project: npm create rulecad my-designs. A workspace with a soap tray to start from, ready to check, preview, export and share.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,6 +11,7 @@
11
11
  "template",
12
12
  "machines",
13
13
  "README.md",
14
+ "CHANGELOG.md",
14
15
  "LICENSE"
15
16
  ],
16
17
  "license": "MIT",
@@ -85,14 +85,78 @@ variable says which rule it comes from. Follow these steps; they're what makes a
85
85
  them with joints, name the positions in `poses`, and run `cad check --sweep` to find where parts collide on the way.
86
86
  See "Joints and poses" in the cad README.
87
87
  - A part is named in fits as `<item>.<part>`; an object that returns one unnamed shape has one part, `body`.
88
- - Where parts screw together, say so with `fasten`, which knows the screw:
88
+ - **A screwed joint is a `fasten`**, which knows the screw:
89
89
  `{ "screw": "M3 cap", "through": ["bracket"], "into": "base", "at": ["bracket.h1", "bracket.h2"] }` (anchors on the
90
- holes' axes), or `"holes": "bracket.body"` to use the part's own holes; `npx cad add fasten …` writes it. The check
91
- reads the holes from the parts as drawn: one axis through the stack, a clearance hole in each part passed, a pilot,
92
- insert or nut at the far end, the length chosen from what is sold, thread engaged, and the seat under the head.
93
- Report what it finds with its numbers, and fix the part, never the relation, to make it pass.
94
- - A gap fit can't tell whether holes line up. Where a board only rests on its screws' bosses, a holes fit follows them
95
- (`{ "holes": "pcb.board", "into": "case.body", "depth": "m2.insert_length" }`).
90
+ holes' axes), or `"holes": "bracket.body"` to use the part's own holes; `npx cad add fasten …` writes it. Draw each
91
+ part's holes with `v.fixings` (a clearance hole where the screw passes, a pilot, insert or nut seat where it ends),
92
+ and name the screw by thread and head with no length: the check chooses one. It reads the holes from the parts as
93
+ drawn: one axis through the stack, a clearance hole in each part passed, a pilot, insert or nut at the far end, the
94
+ length chosen from what is sold, thread engaged, the seat under the head and the key's way to it, and `cad list`
95
+ counts the screws. Report what it finds with its numbers, and fix the part, never the relation, to make it pass.
96
+ - **Beams are held to each other by a join**, not a fasten: `{ "kind": "blind", "a": "y1.a", "b": "x1.back@120" }`
97
+ (`npx cad add join …`), `b` the place on the other beam where a's end meets it. A blind or end-tap join taps a's end,
98
+ drills b and adds its screw to the fasten checks and the list. A bracket, gusset or splice join with `"fitting":
99
+ "printed"` adds its printed fitting, sized from `"load"` (N, default 100) by finite elements, and its screws into both
100
+ beams' slots: report the fitting's grams, margin and stiffness from `cad check` with that load, and say the stiffness
101
+ leaves out the slot nuts. A bought fitting is a rule set named in `"fitting"` (`fitting-motedis-bracket-20-b6`;
102
+ bracket, gusset, splice, hidden and anchor joins): its screws and nuts are its set's, its price goes on `cad list`,
103
+ and its stiffness is its set's estimate, so report it as one. Choose printed or bought from what `cad list` costs
104
+ and what each stiffness rests on, and say both. A `fitting.fit` failure means the set is made for another profile
105
+ or slot: choose another set, never edit the set to pass. The other kinds are checked where they meet and say their
106
+ fitting comes later (`join.fitting`). Move the beam to fix `join.geometry`, never the address, unless the
107
+ address is what was wrong; `join.stiffness` says whether it rests on an estimate or on the joint rig's
108
+ measurement (and its date): report it as it says. A `join.drop` is a prediction for a beam held by one join, to
109
+ measure and write back with `cad measured`, never a figure to tune.
110
+ - **Beams are cut and drilled by hand from their sheets and jigs**: `npx cad beams <project>/<assembly>` writes a
111
+ cut-and-drill sheet per mark, and `--jigs` writes the jigs as a plate in `exports/` (a drill guide per distinct
112
+ hole across a beam, a tap guide per tapped end, a cut-length stop per length, a squaring corner of the hand each square join takes),
113
+ each marked with the marks it is for. Report each jig's grams and margin and that it prints clean; a hole too far
114
+ from both ends for one print is a `jig.drill` warning: say to mark it from the sheet. A `jig.tap` or `jig.square`
115
+ warning is a tapped end or a join with no jig that fits: tap it by eye, or square it with an engineer's square.
116
+ - **A bay closed by a sheet is a `panel` item**: `{ "id": "front", "panel": { "sheet": "acrylic", "thickness": 3,
117
+ "bay": ["x1", "z2", "x2", "z1"], "out": [0, -1, 0] } }`. It is cut to the bay with its clips at a pitch, each
118
+ fastened into its slot; report its size and grams from `cad check` (`panel.size`) and the clips from `cad list`.
119
+ `"door": { "hinge": "z1" }` makes it a door on two printed hinges, turning on a joint: run `cad check --sweep` and
120
+ report what it finds. A turn-button latch shown shut blocks the door in its first degree, which is right.
121
+ - **A board or supply on a frame is a bought item with `"mount"`**: `{ "id": "psu", "bought": "supply-24v",
122
+ "variant": "LRS-50-24", "mount": { "on": "rail.top@-90" } }`. Its holes come from its rule set (`mount_holes`, x then
123
+ y for each); add them from the maker's drawing, with their source, before mounting a device whose set has none. A
124
+ wire along a beam is a run in its `via`, `{ "along": "rail.front", "from": 300, "to": 60 }`: report its length and
125
+ its clips from `wire.length` and `wire.run`.
126
+ - **Linear motion on a beam is a guide**: `"guides": [{ "kind": "rail", "rail": "rail-mgn12", "carriage": "MGN12H",
127
+ "on": "x1.top", "from": 50, "length": 300 }]`. Never draw a rail or carriage yourself, nor type its screws: the
128
+ guide places the rail, its screws into the slot at its pitch and each carriage on a sliding joint with its true
129
+ travel. Fix a table on a carriage with a fixed joint at `g1-carriage-1.top`. Run `cad check --sweep`, and report
130
+ `guide.fit`, the travel and each carriage's `joint.moment` margin; a fail there means a longer carriage
131
+ (`MGN12H`), a larger rail or the load nearer the carriage, never a changed rating.
132
+ On a V-slot beam the same guide can be wheels: `{ "kind": "wheels", "wheel": "v-wheel-solid", "on": "x1.top",
133
+ "from": 50, "length": 400 }` (the plate over that face, its wheels in the tracks either side). A plain T-slot is
134
+ refused for wheels: use a rail or a `slider` there. Report the wheels' `guide.fit` seat, the travel and the
135
+ plate's `joint.moment` margin, and say the wheels' ratings are estimates.
136
+ Two smooth rods and a lead screw are two guides: `{ "kind": "rods", "on": "x1.top", "from": 60, "length": 101,
137
+ "endstop": { "at": "x1.front@82" } }` and `{ "kind": "screw", "guide": "g1", "motor": { "model": "28byj48" } }`.
138
+ Never draw the holders, motor plate, coupler or carriage yourself: the guides place them by addresses and give the
139
+ motor its lead screw. Report the travel, `motor.torque`'s margin, `guide.coupler`, the bearings' `joint.moment`, the
140
+ endstop's home, and each printed part's grams and margin; if the endstop is refused, use the address it names.
141
+ - **A part screwed onto a beam is a `fasten` into a slot**: `"into": "x1.top"` (or `x1.top.2`, or `x1.top@120`, the
142
+ middle of its screws), the
143
+ part's holes drawn with `v.fixings` at the slot's spacing, `"nut"` the slot nut's kind. `fasten.slot` fails a hole off
144
+ a slot's centre line, with the distance: move the hole. `frame.nut` fails slide-in nuts in a slot that joins close
145
+ at both ends: use the kind it names (`"nut": "drop-in"`). `frame.preload` lists nuts to load before a join; tell
146
+ the user, and `cad order` shows them on the step.
147
+ - **A frame's build is `cad order`**: from bars to a square frame in numbered steps (cut, drill and tap, sides built
148
+ flat and squared, nuts to load, joins with their torque, the diagonals, then the rest). Give the user its steps and
149
+ its diagonals (`frame.square`: each and the difference to accept). If it is refused for a slot's nuts, change the
150
+ nut to the kind it names; never reorder the joins to get round it. Where a side is built on the frame, not flat,
151
+ the build says why; pass that on. Its load and "Slide ... screw into ... head first" steps give each nut and head a
152
+ way into its slot: pass them on as written. `cad check` counts the same steps.
153
+ - A fit with `"fastens": true` is for what holds parts without screws (pins, a press, a clip). An older assembly with
154
+ a holes fit (`{ "holes": "pcb.board", "into": "case.body", … }`) and a fit that fastens the same parts gets a
155
+ `fasten.suggest` note from `cad check`: `npx cad add fasten <project>/<assembly> --from-fits` puts the fasten in
156
+ their place. Check it after, and report what changed.
157
+ - A board screwed into its case is a `fasten` too, through the board's own mounting holes:
158
+ `{ "screw": "M2 cap", "through": ["pcb"], "into": "case", "holes": "pcb.board" }`, into bosses the case draws with
159
+ `v.fixings.insertBoss('M2', ...)` under `v.pcb.board_holes`.
96
160
  - A part built around another (a case around its board) reads it: `"uses": ["macropad/pcb"]`, then
97
161
  `pcb.board_w` and `v.pcb.board_holes`. Never copy another object's numbers by hand.
98
162
 
@@ -100,6 +164,8 @@ variable says which rule it comes from. Follow these steps; they're what makes a
100
164
  - `"engine": "pcb"` in the .json; `main(v)` returns a board built with `v.pcb` (see @rulecad/pcb's README).
101
165
  - Parts come from rule sets where one exists (`v.pcb.xiao`, `qwiic`, `jstph`, `header`), or any standard footprint by
102
166
  name (`v.pcb.part('U2', 'soic8', x, y)`). Turn parts in quarter turns with `rotation`, held in a variable.
167
+ - A board's mounting holes are named by their screws' thread, never typed: `v.pcb.mount('M2', x, y)` in its `holes`
168
+ is the thread's clearance hole from its rule set, as the fab drills it (`{ fit: 'close' }` or `'loose'` for the others).
103
169
  - Join pins with `nets` (`GND: ['U1.GND', 'J1.GND']`) and let the autorouter draw them; `cad check` runs the fab's
104
170
  design rules. Look at the copper preview: connectors should face the edge their plug comes from.
105
171
 
@@ -12,7 +12,21 @@ npx cad link home/soap-tray --md # a link that opens the model in
12
12
  npx cad new home/hook # your own design
13
13
  ```
14
14
 
15
+ A second example is a box with its lid screwed on:
16
+
17
+ ```sh
18
+ npx cad check home/lidded-box # the lid on the box, and each screw followed through its holes
19
+ npx cad list home/lidded-box # what to buy: 4 × M3x8 cap, the length the check chose
20
+ npx cad order home/lidded-box # how it goes together, with the key that turns the screws
21
+ ```
22
+
23
+ - `projects/home/objects/box.js` and `lid.js` draw the screws' holes with `v.fixings`, named by the thread (`'M3'`):
24
+ the pilot in each corner post and the clearance hole in the lid are sized from the thread's rule set and your
25
+ printer's, so no screw size is typed. `projects/home/assemblies/lidded-box.json` says how they screw together with
26
+ a `fasten`: the screw by thread and head (`M3 cap`), the part it passes and the part it ends in.
27
+
15
28
  - `projects/home/objects/soap-tray.json` holds the variables, `soap-tray.js` the shape ([JSCAD](https://openjscad.xyz)).
29
+ Assemblies, in `projects/home/assemblies/`, place objects together and check how they fit and fasten.
16
30
  - `rules/` holds the facts designs use, such as your printer's (`x1c.json`, copied in on first use). Measure your own
17
31
  printer and correct them: every design that uses them follows.
18
32
  - `cad.config.json` names the printer. For another printer, copy `rules/x1c.json` under a new name and change the
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://jonibach.github.io/rulecad/schemas/assembly.schema.json",
3
+ "title": "Box with its lid screwed on",
4
+ "kind": "fit",
5
+ "uses": [
6
+ "x1c"
7
+ ],
8
+ "items": [
9
+ { "id": "box", "object": "box" },
10
+ { "id": "lid", "object": "lid", "at": [0, 0, "box.height"] }
11
+ ],
12
+ "fits": [
13
+ { "a": "lid", "b": "box", "min": 0, "max": "x1c.fit", "note": "The lid sits on the box's rim" }
14
+ ],
15
+ "fasten": [
16
+ { "screw": "M3 cap", "through": ["lid"], "into": "box", "holes": "lid.body", "note": "Lid screwed to the box" }
17
+ ]
18
+ }
@@ -0,0 +1,20 @@
1
+ // A box whose lid (lid.js) is screwed on: a tub with a post in each corner, and a pilot down each post that the screw
2
+ // cuts its own thread in. The pilots come from v.fixings, named by the thread: their size is read from the thread's
3
+ // rule set and the printer's, so no screw size is typed here or in box.json. Z is up, the bed is z = 0.
4
+ import jscad from '@jscad/modeling'
5
+ const { cuboid } = jscad.primitives
6
+
7
+ // A block sitting on z = z0, centred on (cx, cy)
8
+ const block = (x, y, z0, h, cx = 0, cy = 0) => cuboid({ size: [x, y, h], center: [cx, cy, z0 + h / 2] })
9
+
10
+ // Where the screws go: one in each corner, inset from the outer faces (the lid reads the same numbers)
11
+ export const corners = (w, d, inset) => [[-1, -1], [1, -1], [1, 1], [-1, 1]].map(([sx, sy]) => [sx * (w / 2 - inset), sy * (d / 2 - inset)])
12
+
13
+ export function main (v) {
14
+ const post = (v.inset - v.wall) * 2
15
+ const places = corners(v.width, v.depth, v.inset)
16
+ const tub = v.ops.subtract(block(v.width, v.depth, 0, v.height), block(v.width - v.wall * 2, v.depth - v.wall * 2, v.floor, v.height))
17
+ const posts = places.map(([x, y]) => block(post, post, v.floor, v.height - v.floor, x, y))
18
+ const pilots = places.map(([x, y]) => v.fixings.hole('M3', { kind: 'pilot', depth: v.height - v.floor, at: [x, y, v.height] }))
19
+ return v.ops.subtract(v.ops.union(tub, ...posts), ...pilots)
20
+ }
@@ -0,0 +1,61 @@
1
+ {
2
+ "$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
3
+ "name": "box",
4
+ "title": "Box",
5
+ "version": "0.1.0",
6
+ "uses": [
7
+ "x1c"
8
+ ],
9
+ "material": "PLA",
10
+ "orientation": "Open side up on the bed. Walls and corner posts are straight up, so it prints without supports.",
11
+ "variables": {
12
+ "width": {
13
+ "value": 60,
14
+ "unit": "mm",
15
+ "rule": "Room for small things: keys, a watch, earrings",
16
+ "label": "Width",
17
+ "show": true,
18
+ "tweak": {
19
+ "min": 40,
20
+ "max": 160
21
+ },
22
+ "interface": true
23
+ },
24
+ "depth": {
25
+ "value": 40,
26
+ "unit": "mm",
27
+ "rule": "Room for small things, front to back",
28
+ "label": "Depth",
29
+ "show": true,
30
+ "tweak": {
31
+ "min": 30,
32
+ "max": 120
33
+ },
34
+ "interface": true
35
+ },
36
+ "height": {
37
+ "value": "x1c.layer * 100",
38
+ "unit": "mm",
39
+ "rule": "A whole number of layers, deep enough for the screws' pilots",
40
+ "label": "Height",
41
+ "show": true,
42
+ "interface": true
43
+ },
44
+ "wall": {
45
+ "value": "x1c.line * 4",
46
+ "unit": "mm",
47
+ "rule": "Four print lines: stiff, and no gaps between lines"
48
+ },
49
+ "floor": {
50
+ "value": "x1c.layer * 8",
51
+ "unit": "mm",
52
+ "rule": "Eight layers"
53
+ },
54
+ "inset": {
55
+ "value": "wall + x1c.line * 8",
56
+ "unit": "mm",
57
+ "rule": "Each screw this far in from the outer faces: the wall, then a post round the screw's pilot, eight lines from its centre to the wall",
58
+ "interface": true
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,11 @@
1
+ // The box's lid: a plate as wide and deep as the box (box.json), with a clearance hole over each of its corner posts.
2
+ // The holes come from v.fixings, named by the thread, at the places box.js puts the screws.
3
+ import jscad from '@jscad/modeling'
4
+ import { corners } from './box.js'
5
+ const { cuboid } = jscad.primitives
6
+
7
+ export function main (v) {
8
+ const plate = cuboid({ size: [v.box.width, v.box.depth, v.thick], center: [0, 0, v.thick / 2] })
9
+ const holes = corners(v.box.width, v.box.depth, v.box.inset).map(([x, y]) => v.fixings.hole('M3', { depth: v.thick, at: [x, y, v.thick] }))
10
+ return v.ops.subtract(plate, ...holes)
11
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://jonibach.github.io/rulecad/schemas/object.schema.json",
3
+ "name": "lid",
4
+ "title": "Lid",
5
+ "version": "0.1.0",
6
+ "uses": [
7
+ "x1c",
8
+ "home/box"
9
+ ],
10
+ "material": "PLA",
11
+ "orientation": "Flat on the bed, top side up. The screw holes go straight down, so it prints without supports.",
12
+ "variables": {
13
+ "thick": {
14
+ "value": "x1c.layer * 15",
15
+ "unit": "mm",
16
+ "rule": "Fifteen layers: stiff over the box, and a firm seat under each screw's head",
17
+ "label": "Thickness",
18
+ "show": true
19
+ }
20
+ }
21
+ }
@@ -2,5 +2,5 @@
2
2
  "name": "home",
3
3
  "description": "Things for the house.",
4
4
  "material": "PLA",
5
- "objects": ["soap-tray"]
5
+ "objects": ["soap-tray", "box", "lid"]
6
6
  }