@rulecad/cad 0.2.1 → 0.3.1
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 +2 -2
- package/README.md +12 -5
- package/lib/design.mjs +5 -5
- package/package.json +4 -4
package/AGENTS.md
CHANGED
|
@@ -50,8 +50,8 @@ variable says which rule it comes from. Follow these steps; they're what makes a
|
|
|
50
50
|
- A part is named in fits as `<item>.<part>`; an object that returns one unnamed shape has one part, `body`.
|
|
51
51
|
- A gap fit can't tell whether holes line up. Where a board screws into a part, add a holes fit
|
|
52
52
|
(`{ "holes": "pcb.board", "into": "case.body", "depth": "m2.insert_length" }`).
|
|
53
|
-
- A part built around another (a case around its board) reads it: `"uses": ["
|
|
54
|
-
`
|
|
53
|
+
- A part built around another (a case around its board) reads it: `"uses": ["macropad/pcb"]`, then
|
|
54
|
+
`pcb.board_w` and `v.pcb.board_holes`. Never copy another object's numbers by hand.
|
|
55
55
|
|
|
56
56
|
## Circuit boards
|
|
57
57
|
- `"engine": "pcb"` in the .json; `main(v)` returns a board built with `v.pcb` (see @rulecad/pcb's README).
|
package/README.md
CHANGED
|
@@ -96,11 +96,12 @@ which version it holds (`keyboard/keycap@0.1.0`, or `+changes` if it isn't a rel
|
|
|
96
96
|
|
|
97
97
|
- `value`: a number, or arithmetic over numbers and names (`+ - * /`, brackets, `min`, `max`, `round`). Rule sets are
|
|
98
98
|
`<namespace>.<rule>`; the object's own variables are bare names. Parsed, never evaluated as code.
|
|
99
|
-
- **Other objects' numbers:** `"uses": ["
|
|
100
|
-
`
|
|
101
|
-
outline (`board_x`, `board_y`, `board_w`, `board_d`) and, in code, its
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
- **Other objects' numbers:** `"uses": ["macropad/pcb"]` reads another object as a rule set named after it:
|
|
100
|
+
`pcb.board_w` in an expression, `v.pcb.board_w` in code. It gets the object's variables and, from a board, its
|
|
101
|
+
outline (`board_x`, `board_y`, `board_w`, `board_d`) and, in code, where each of its parts is (`v.pcb.board_parts`),
|
|
102
|
+
a shaped board's outline (`board_outline`) and its mounting holes (`v.pcb.board_holes`, each
|
|
103
|
+
`{ x, y, d }`). So a case follows its board: change the board and the case rebuilds around it. `"macropad/pcb@^0.2.0"`
|
|
104
|
+
also checks the version; `"macropad/pcb@0.2.0"` reads that release. `cad rules` shows each borrowed number with the
|
|
104
105
|
object and version it came from; two objects can't read each other.
|
|
105
106
|
- `show`: on the rules card `cad show` hands its target (six at most). `interface`: other parts depend on it (versioning will compare these).
|
|
106
107
|
- `tweak: { min, max }`: may be changed with `--set`. Variables without one are fixed by their rule.
|
|
@@ -121,6 +122,10 @@ which version it holds (`keyboard/keycap@0.1.0`, or `+changes` if it isn't a rel
|
|
|
121
122
|
text so punctuation stays small, each straight stroke thickened to whole print lines, dots drawn round, and ↑ ↓ ← →
|
|
122
123
|
as arrows), `anchor(face, size, at)` (where something goes on a face, by anchor), and `cut(a, b)` (a subtract that
|
|
123
124
|
only touches a's faces near b; JSCAD's own splits every face along b's planes, which can leave slivers far away).
|
|
125
|
+
- A rule set can also carry `"footprints"` (pad data from @rulecad/pcb's `fromKicad`, with its source), which a
|
|
126
|
+
board's code reads as `v.parts.footprints.usb_c`.
|
|
127
|
+
- An object or rule set named with a hyphen (`mx-switch`) is read with an underscore in expressions (`mx_switch.housing_top`),
|
|
128
|
+
since a hyphen there is a minus.
|
|
124
129
|
- Rules carry `kind`: spec (manufacturer), default (slicer), community (rule of thumb) or measured (your own test
|
|
125
130
|
print, which beats the rest), plus `source` and `checked`.
|
|
126
131
|
|
|
@@ -191,6 +196,8 @@ other items' variables, so a keycap can sit exactly where its slot meets the swi
|
|
|
191
196
|
Objects with `"role": "reference"` (the MX switch) model things you don't print: drawn faint, never exported.
|
|
192
197
|
- **plate** assemblies lay objects out on the bed: they're checked as one print and `export` writes one 3MF with an
|
|
193
198
|
object per part. Supports are kept.
|
|
199
|
+
- **Turning:** `"rotate": [0, 180, 0]` turns an item (degrees about x, y, z, in that order) about its own origin
|
|
200
|
+
before `at` moves it: a pod on a side mount, or a lid modelled face down as it prints.
|
|
194
201
|
- **Components:** an item can be a whole assembly (`"assembly": "keycap-on-switch"`). Its parts, fits and `requires`
|
|
195
202
|
come along, named per copy (`key-1-1.cap.cap`), and its overlaps are still checked inside each copy.
|
|
196
203
|
- **Repeats:** `"repeat": { "x": { "count": "plate.cols", "step": "plate.pitch" }, "y": { … } }` places a grid of
|
package/lib/design.mjs
CHANGED
|
@@ -46,10 +46,10 @@ export function locate(ref) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// ---------- objects that read each other ----------
|
|
49
|
-
// "uses": ["
|
|
50
|
-
// expression, v.
|
|
51
|
-
// board_w, board_d, and board_holes for
|
|
52
|
-
// its version; "
|
|
49
|
+
// "uses": ["macropad/pcb"] reads another object's numbers as a rule set named after it (pcb.board_w in an
|
|
50
|
+
// expression, v.pcb.board_w in code): its variables, and what a board tells the parts around it (board_x, board_y,
|
|
51
|
+
// board_w, board_d, and for code board_holes, board_parts (where each part is) and board_outline, for a shaped board). The object is built (cached) first. "macropad/pcb@^0.2.0" also checks
|
|
52
|
+
// its version; "macropad/pcb@0.2.0" reads that release instead of the working copy.
|
|
53
53
|
export const isObjectRef = (u) => String(u).includes('/');
|
|
54
54
|
const building = new Set();
|
|
55
55
|
export async function objectSets(d, object) {
|
|
@@ -69,7 +69,7 @@ export async function objectSets(d, object) {
|
|
|
69
69
|
rules[k] = { value: v, unit: units[k] ?? 'mm', rule: `${ref}'s ${k}`, kind: 'design', source: `${ref}@${version}` };
|
|
70
70
|
}
|
|
71
71
|
sets[u] = { name: base.name, rules };
|
|
72
|
-
if (b.circuit) extra[base.name] = { board_holes: (
|
|
72
|
+
if (b.circuit) { const e = await pcbEngine(), board = b.circuit.find((x) => x.type === 'pcb_board'); extra[base.name] = { board_holes: e.holes(b.circuit), board_parts: e.parts ? e.parts(b.circuit) : {}, ...(board.outline ? { board_outline: board.outline } : {}) }; }
|
|
73
73
|
}
|
|
74
74
|
} finally { building.delete(self); }
|
|
75
75
|
return { sets, extra };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/cad",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "The cad command: JSCAD designs from traceable rules, checked for printing and fit, versioned by what fits, shared as links and exported as Bambu 3MF.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
"directory": "packages/cad"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@rulecad/variables": "^0.1.
|
|
46
|
+
"@rulecad/variables": "^0.1.4",
|
|
47
47
|
"@rulecad/keyboard-layout": "^0.1.2",
|
|
48
48
|
"@rulecad/printcheck": "^0.1.0",
|
|
49
49
|
"@rulecad/fit": "^0.2.0",
|
|
50
50
|
"@rulecad/model-link": "^0.1.2",
|
|
51
51
|
"@rulecad/versions": "^0.1.0",
|
|
52
|
-
"@rulecad/shapes": "^0.
|
|
52
|
+
"@rulecad/shapes": "^0.2.0",
|
|
53
53
|
"@rulecad/rules": "^0.2.0",
|
|
54
54
|
"@jscad/modeling": "^2.12.0",
|
|
55
55
|
"three": "^0.186.1"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@rulecad/pcb": "^0.1.0 || ^0.2.0"
|
|
58
|
+
"@rulecad/pcb": "^0.1.0 || ^0.2.0 || ^0.3.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependenciesMeta": {
|
|
61
61
|
"@rulecad/pcb": {
|