@rulecad/cad 0.2.1 → 0.3.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/README.md +8 -1
- package/lib/design.mjs +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -98,7 +98,8 @@ which version it holds (`keyboard/keycap@0.1.0`, or `+changes` if it isn't a rel
|
|
|
98
98
|
`<namespace>.<rule>`; the object's own variables are bare names. Parsed, never evaluated as code.
|
|
99
99
|
- **Other objects' numbers:** `"uses": ["node/carrier"]` reads another object as a rule set named after it:
|
|
100
100
|
`carrier.board_w` in an expression, `v.carrier.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, its
|
|
101
|
+
outline (`board_x`, `board_y`, `board_w`, `board_d`) and, in code, where each of its parts is (`v.carrier.board_parts`),
|
|
102
|
+
a shaped board's outline (`board_outline`) and its mounting holes (`v.carrier.board_holes`, each
|
|
102
103
|
`{ x, y, d }`). So a case follows its board: change the board and the case rebuilds around it. `"node/carrier@^0.2.0"`
|
|
103
104
|
also checks the version; `"node/carrier@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.
|
|
@@ -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 (`pod-th`) is read with an underscore in expressions (`pod_th.width`),
|
|
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
|
@@ -48,7 +48,7 @@ export function locate(ref) {
|
|
|
48
48
|
// ---------- objects that read each other ----------
|
|
49
49
|
// "uses": ["node/carrier"] reads another object's numbers as a rule set named after it (carrier.board_w in an
|
|
50
50
|
// expression, v.carrier.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 board_holes for
|
|
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. "node/carrier@^0.2.0" also checks
|
|
52
52
|
// its version; "node/carrier@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();
|
|
@@ -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.0",
|
|
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": {
|