@rulecad/cad 0.7.58 → 0.7.59
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 +13 -0
- package/bin/cad.mjs +3 -2
- package/lib/design.mjs +3 -0
- package/lib/links.mjs +1 -0
- package/lib/preview.mjs +4 -3
- package/package.json +1 -1
- package/schemas/assembly.schema.json +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ print (a hole's diameter, a seat's depth, a part's outline). Each release lists
|
|
|
5
5
|
its reason. A **fasten** is an entry in an assembly's `"fasten"` list: one screwed joint, naming the screw by thread
|
|
6
6
|
and head, the parts it passes through and the part it ends in.
|
|
7
7
|
|
|
8
|
+
## 0.7.59: routes kept between builds, assemblies shown as built
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `"show": "built"` on an assembly draws its references (bought parts, boards, a module) solid in `cad preview`
|
|
13
|
+
and on the model page, as the thing built; they still aren't printed or downloaded.
|
|
14
|
+
- The autorouter's results are kept in the workspace's `.cache/routes`, by their exact input (@rulecad/pcb's route
|
|
15
|
+
cache): a board rebuilt for anything but its routing (a change to the library, its finish or its checks) reuses its
|
|
16
|
+
route instead of searching again. `CAD_NO_CACHE` turns it off with the rest of the cache.
|
|
17
|
+
|
|
18
|
+
### Printed sizes that moved
|
|
19
|
+
|
|
20
|
+
None.
|
|
8
21
|
## 0.7.58: frame checks (Frames 3)
|
|
9
22
|
|
|
10
23
|
### Added
|
package/bin/cad.mjs
CHANGED
|
@@ -751,8 +751,9 @@ async function assembly(cmd, ref) {
|
|
|
751
751
|
marks = (await import('../lib/motorsvg.mjs')).workMarks(s);
|
|
752
752
|
}
|
|
753
753
|
const size = (await import('@rulecad/printcheck')).bounds(s.triangles).size.map((n) => fmt(n)).join(' × ');
|
|
754
|
-
const
|
|
755
|
-
|
|
754
|
+
const built = s.a.show === 'built' // (show: built: references drawn solid, as the thing built)
|
|
755
|
+
const faint = [...new Set(s.parts.filter((p) => p.role !== 'part' && !(built && p.role === 'reference')).map((p) => `${p.object || p.item}${p.role === 'support' ? ' supports' : ''}`))]; // each kind once
|
|
756
|
+
await preview([...s.parts, ...wireTubesOf(s)], { title: check ? `${title}: the motor at work` : title, meta: `${size} mm · ${versions}${faint.length ? ` · faint: ${faint.join(', ')}` : ''}`, out, explode: !!opt('explode'), marks, built });
|
|
756
757
|
// each motor at work beside it: its curve with the working point, and the torque through its train (said before
|
|
757
758
|
// the picture, which stays the last line, for whatever reads it)
|
|
758
759
|
if (s.motion?.drives?.length && !pose && !opt('explode') && !check) {
|
package/lib/design.mjs
CHANGED
|
@@ -126,6 +126,9 @@ export function variantSet(d, object, set = {}) {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
const CACHE = paths.cache('builds'), CACHE_VERSION = 3;
|
|
129
|
+
// The autorouter's results too, by its exact input (@rulecad/pcb reads RULECAD_ROUTE_CACHE): a board rebuilt for anything
|
|
130
|
+
// but its routing (a change to the library, its finish, its checks) reuses its route instead of searching again
|
|
131
|
+
if (!process.env.CAD_NO_CACHE) process.env.RULECAD_ROUTE_CACHE ||= paths.cache('routes');
|
|
129
132
|
const source = (f) => fs.readFileSync(new URL(f, import.meta.url), 'utf8');
|
|
130
133
|
// What every build is made with: this code, the shape helpers and JSCAD's version (an upgrade rebuilds everything);
|
|
131
134
|
// boards also with the board engine (engineId: its code and tscircuit's version), loaded only for boards
|
package/lib/links.mjs
CHANGED
|
@@ -89,6 +89,7 @@ export async function assemblyModel(s, { title, versions, filaments: fil = {}, n
|
|
|
89
89
|
}
|
|
90
90
|
const model = {
|
|
91
91
|
title, version: versions, src: `${s.project}/${s.name}`, // object versions are in version: the file name stays short
|
|
92
|
+
...(s.a?.show === 'built' ? { show: 'built' } : {}), // its references drawn solid on the page
|
|
92
93
|
rules: [],
|
|
93
94
|
...sheet([...new Map(s.objects.filter((o) => o.built?.entries).map((o) => [o.objName, o.built.entries])).entries()], { noRules }),
|
|
94
95
|
// Its boards' 2D views (copper, schematic), so one link holds the whole build: tabs over the 3D model
|
package/lib/preview.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// preview(parts, { title, meta, out, explode }) -> out: a 1800 × 1200 PNG of six views (front, side, 3/4, top, bottom, 3/4 below),
|
|
2
|
-
// parts: [{ name, role, label, item, triangles }]; supports and references are drawn faint (lines only)
|
|
2
|
+
// parts: [{ name, role, label, item, triangles }]; supports and references are drawn faint (lines only), but references
|
|
3
|
+
// solid with built (an assembly with show: built); explode drops
|
|
3
4
|
// supports below and, in an assembly, lifts each kind of object above the one before (plate, switches, keycaps); a part
|
|
4
5
|
// with `lift` (a screw, a nut: lib/fasten.mjs) goes with the part it sits in (`with`) and then out along its own axis.
|
|
5
6
|
// rendered by headless Chrome from lib/preview/page.html, served on this Mac only for the few seconds it takes.
|
|
@@ -19,9 +20,9 @@ const CHROME = process.env.CAD_CHROME || [
|
|
|
19
20
|
].find((f) => fs.existsSync(f));
|
|
20
21
|
const THREE = path.dirname(createRequire(import.meta.url).resolve('three')); // wherever npm put it
|
|
21
22
|
|
|
22
|
-
export async function preview(parts, { title = '', meta = '', out, explode = false, marks = null }) {
|
|
23
|
+
export async function preview(parts, { title = '', meta = '', out, explode = false, marks = null, built = false }) {
|
|
23
24
|
const flat = (tris) => { const positions = []; for (const t of tris) for (let i = 1; i < t.length - 1; i++) positions.push(...t[0], ...t[i], ...t[i + 1]); return positions; };
|
|
24
|
-
const data = JSON.stringify({ title, meta, explode, marks, parts: parts.map((p) => ({ name: p.name, role: p.role, label: p.label, item: p.object || p.item, ...(p.lift ? { lift: p.lift, with: p.with } : {}), positions: flat(p.triangles) })) });
|
|
25
|
+
const data = JSON.stringify({ title, meta, explode, marks, parts: parts.map((p) => ({ name: p.name, role: built && p.role === 'reference' ? 'part' : p.role, label: p.label, item: p.object || p.item, ...(p.lift ? { lift: p.lift, with: p.with } : {}), positions: flat(p.triangles) })) });
|
|
25
26
|
const server = http.createServer((req, res) => {
|
|
26
27
|
const u = new URL(req.url, 'http://x').pathname;
|
|
27
28
|
const send = (type, body) => { res.writeHead(200, { 'Content-Type': type }); res.end(body); };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/cad",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.59",
|
|
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": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"title": { "type": "string" },
|
|
12
12
|
"description": { "type": "string" },
|
|
13
13
|
"note": { "type": "string" },
|
|
14
|
+
"show": { "enum": ["built"], "description": "built: the assembly is a picture of the thing built, so its references (bought parts, boards, a module) are drawn solid in previews and on the model page, as its printed parts are; they still aren't printed or downloaded" },
|
|
14
15
|
"kind": { "enum": ["fit", "plate"] },
|
|
15
16
|
"packed": { "type": "object", "description": "Written by cad plates: which assembly this plate is for, its filament, its material (each plate is one plastic: the project's, or a printed beam's own) and gap, and each part's build hash, so a changed part re-packs only its plate", "required": ["of", "filament", "gap", "parts"], "additionalProperties": false, "properties": { "of": { "type": "string" }, "filament": { "type": "string" }, "material": { "type": "string" }, "gap": { "type": "number" }, "parts": { "type": "object" } } },
|
|
16
17
|
"uses": { "type": "array", "items": { "type": "string" } },
|