create-rulecad 0.3.14 → 0.3.16
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/CHANGELOG.md +56 -0
- package/README.md +5 -2
- package/index.mjs +3 -2
- package/machines/arm/projects/arm/assemblies/arm.json +18 -4
- package/machines/arm/projects/arm/objects/base.js +6 -4
- package/machines/arm/projects/arm/objects/base.json +5 -6
- package/machines/arm/projects/arm/objects/bridge.js +4 -2
- package/machines/arm/projects/arm/objects/bridge.json +5 -4
- package/machines/arm/projects/arm/objects/clip.js +3 -1
- package/machines/arm/projects/arm/objects/clip.json +1 -2
- package/machines/arm/projects/arm/objects/forearm.js +10 -5
- package/machines/arm/projects/arm/objects/forearm.json +8 -4
- package/machines/arm/projects/arm/objects/holder.js +5 -2
- package/machines/arm/projects/arm/objects/holder.json +2 -3
- package/machines/arm/projects/arm/objects/housing.js +6 -3
- package/machines/arm/projects/arm/objects/housing.json +6 -6
- package/machines/arm/projects/arm/objects/output.js +3 -1
- package/machines/arm/projects/arm/objects/output.json +1 -2
- package/machines/arm/projects/arm/objects/spindle.js +5 -2
- package/machines/arm/projects/arm/objects/spindle.json +8 -7
- package/machines/arm/projects/arm/objects/upper.js +6 -3
- package/machines/arm/projects/arm/objects/upper.json +5 -6
- package/machines/arm/rules/arm.json +3 -3
- package/machines/leg/projects/leg/assemblies/stand.json +12 -2
- package/machines/leg/projects/leg/objects/bridge.js +4 -2
- package/machines/leg/projects/leg/objects/bridge.json +5 -4
- package/machines/leg/projects/leg/objects/carriage.js +3 -1
- package/machines/leg/projects/leg/objects/carriage.json +2 -3
- package/machines/leg/projects/leg/objects/clip.js +3 -1
- package/machines/leg/projects/leg/objects/clip.json +1 -2
- package/machines/leg/projects/leg/objects/collar.js +3 -1
- package/machines/leg/projects/leg/objects/collar.json +1 -2
- package/machines/leg/projects/leg/objects/foot.js +3 -1
- package/machines/leg/projects/leg/objects/foot.json +1 -2
- package/machines/leg/projects/leg/objects/housing.js +6 -3
- package/machines/leg/projects/leg/objects/housing.json +6 -6
- package/machines/leg/projects/leg/objects/output.js +3 -1
- package/machines/leg/projects/leg/objects/output.json +1 -2
- package/machines/leg/projects/leg/objects/shin.js +4 -2
- package/machines/leg/projects/leg/objects/shin.json +6 -4
- package/machines/leg/projects/leg/objects/spindle.js +5 -2
- package/machines/leg/projects/leg/objects/spindle.json +8 -7
- package/machines/leg/projects/leg/objects/thigh.js +5 -2
- package/machines/leg/projects/leg/objects/thigh.json +2 -4
- package/machines/leg/rules/leg.json +2 -2
- package/package.json +2 -1
- package/template/AGENTS.md +20 -7
- package/template/README.md +14 -0
- package/template/projects/home/assemblies/lidded-box.json +18 -0
- package/template/projects/home/objects/box.js +20 -0
- package/template/projects/home/objects/box.json +61 -0
- package/template/projects/home/objects/lid.js +11 -0
- package/template/projects/home/objects/lid.json +21 -0
- 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"
|
|
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
|
-
"
|
|
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
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.3.16",
|
|
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",
|
package/template/AGENTS.md
CHANGED
|
@@ -21,6 +21,10 @@ variable says which rule it comes from. Follow these steps; they're what makes a
|
|
|
21
21
|
- When a part must fit something whose model exists (a maker's CAD, a model site), measure that model:
|
|
22
22
|
`npx cad measure <file> --rules <name> --source <url> --licence "…"`. Look at the drawing in `.preview/measure/`,
|
|
23
23
|
then rename the draft rules for what they are and say in each `rule` what the feature does.
|
|
24
|
+
- For a beam (an aluminium extrusion) the kit has no profile for, measure the maker's model or a DXF of its section:
|
|
25
|
+
`npx cad measure <beam.stl|section.dxf> --profile <name> --source <url> --licence "…"`. It writes a draft profile
|
|
26
|
+
set and the section's outline into this workspace's `rules/`. Look at the drawing, check the slot figures against
|
|
27
|
+
the maker's sheet, and never copy the outline out of the workspace: it is the maker's shape.
|
|
24
28
|
- Model it from those rules, then `npx cad match <project>/<object> <file>`: report the worst places with their numbers,
|
|
25
29
|
and look at the sections picture. A deliberate clearance shows as an even offset; anything else is a finding.
|
|
26
30
|
- Don't copy the shape of a model whose licence is non-commercial, no-derivatives or share-alike into a design under
|
|
@@ -81,14 +85,21 @@ variable says which rule it comes from. Follow these steps; they're what makes a
|
|
|
81
85
|
them with joints, name the positions in `poses`, and run `cad check --sweep` to find where parts collide on the way.
|
|
82
86
|
See "Joints and poses" in the cad README.
|
|
83
87
|
- A part is named in fits as `<item>.<part>`; an object that returns one unnamed shape has one part, `body`.
|
|
84
|
-
-
|
|
88
|
+
- **A screwed joint is a `fasten`**, which knows the screw:
|
|
85
89
|
`{ "screw": "M3 cap", "through": ["bracket"], "into": "base", "at": ["bracket.h1", "bracket.h2"] }` (anchors on the
|
|
86
|
-
holes' axes), or `"holes": "bracket.body"` to use the part's own holes; `npx cad add fasten …` writes it.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
- A fit with `"fastens": true` is for what holds parts without screws (pins, a press, a clip). An older assembly with
|
|
97
|
+
a holes fit (`{ "holes": "pcb.board", "into": "case.body", … }`) and a fit that fastens the same parts gets a
|
|
98
|
+
`fasten.suggest` note from `cad check`: `npx cad add fasten <project>/<assembly> --from-fits` puts the fasten in
|
|
99
|
+
their place. Check it after, and report what changed.
|
|
100
|
+
- A board screwed into its case is a `fasten` too, through the board's own mounting holes:
|
|
101
|
+
`{ "screw": "M2 cap", "through": ["pcb"], "into": "case", "holes": "pcb.board" }`, into bosses the case draws with
|
|
102
|
+
`v.fixings.insertBoss('M2', ...)` under `v.pcb.board_holes`.
|
|
92
103
|
- A part built around another (a case around its board) reads it: `"uses": ["macropad/pcb"]`, then
|
|
93
104
|
`pcb.board_w` and `v.pcb.board_holes`. Never copy another object's numbers by hand.
|
|
94
105
|
|
|
@@ -96,6 +107,8 @@ variable says which rule it comes from. Follow these steps; they're what makes a
|
|
|
96
107
|
- `"engine": "pcb"` in the .json; `main(v)` returns a board built with `v.pcb` (see @rulecad/pcb's README).
|
|
97
108
|
- Parts come from rule sets where one exists (`v.pcb.xiao`, `qwiic`, `jstph`, `header`), or any standard footprint by
|
|
98
109
|
name (`v.pcb.part('U2', 'soic8', x, y)`). Turn parts in quarter turns with `rotation`, held in a variable.
|
|
110
|
+
- A board's mounting holes are named by their screws' thread, never typed: `v.pcb.mount('M2', x, y)` in its `holes`
|
|
111
|
+
is the thread's clearance hole from its rule set, as the fab drills it (`{ fit: 'close' }` or `'loose'` for the others).
|
|
99
112
|
- Join pins with `nets` (`GND: ['U1.GND', 'J1.GND']`) and let the autorouter draw them; `cad check` runs the fab's
|
|
100
113
|
design rules. Look at the copper preview: connectors should face the edge their plug comes from.
|
|
101
114
|
|
package/template/README.md
CHANGED
|
@@ -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
|
+
}
|