@rulecad/cad 0.7.83 → 0.7.89
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 +29 -0
- package/README.md +5 -3
- package/lib/explain.mjs +6 -1
- package/lib/optimise.mjs +7 -1
- package/package.json +4 -4
- package/schemas/problem.schema.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,35 @@ 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.89: fewer triangles by default
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- A solid (3D) optimised result's surface is thinned by default to within 0.1 mm of where it was drawn (`outline.reduce`,
|
|
12
|
+
which was off unless given). Every 3D result's mesh has fewer triangles and its volume and grams move a little: on the
|
|
13
|
+
bracket bench's printable result 75,592 triangles become 21,124, the volume 27.808 cm³ becomes 27.806 cm³ (0.007%
|
|
14
|
+
less) and the weight stays 35.04 g of PLA. `"outline": { "reduce": false }` keeps every triangle, as before. Results
|
|
15
|
+
are drawn again from their cached densities; nothing is optimised again.
|
|
16
|
+
- cad's share of the densities key (the text of `holdEmpty` and `optimised()`) is pinned by a test, so an edit there,
|
|
17
|
+
a comment included, that would optimise every cached problem again is made on purpose.
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Printed fittings may be sized from the kit's new second-maker plastics (`pla-prusament`, `petg-polylite`,
|
|
22
|
+
`asa-polylite`); a project's material that has no rule set is refused naming them too.
|
|
23
|
+
- A design's expressions read the ends of a rule's range (`pa_cf.strength_z.low`), and `cad why` explains one as the
|
|
24
|
+
rule it comes from.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- `cad why` explains a rule of a set whose name has a hyphen, written as an expression writes it
|
|
29
|
+
(`pla_prusament.strength_z`, `pla_prusament.strength_z.low`, `mx_switch.housing_top`), as `cad values` already read
|
|
30
|
+
it; it stopped with `no variable or rule` before.
|
|
31
|
+
|
|
32
|
+
### Printed sizes that moved
|
|
33
|
+
|
|
34
|
+
- An optimised solid's surface moves by no more than 0.1 mm (its outline's corners, as above). Bolt holes and kept
|
|
35
|
+
regions are cut and added exactly afterwards, so they do not move.
|
|
36
|
+
|
|
8
37
|
## 0.7.83: stalled motors and joints swept together on the frame
|
|
9
38
|
### Added
|
|
10
39
|
|
package/README.md
CHANGED
|
@@ -1611,10 +1611,12 @@ regions exactly. The surface is a big mesh, so set the object's `"engine": "mani
|
|
|
1611
1611
|
surface is also kept within the printer's overhang limit: faces smoothing tipped past it are tipped back. An
|
|
1612
1612
|
`analysis` of a solid part voxelises it on the problem's grid.
|
|
1613
1613
|
|
|
1614
|
-
The surface
|
|
1614
|
+
The surface is drawn with many small triangles, and `cad optimise` thins them by default: the surface stays within
|
|
1615
1615
|
0.1 mm of where it was drawn (a quarter of an X1C's print line), closed, with no more overhang and no new tips, and
|
|
1616
|
-
`cad optimise` says how many triangles it had and has. On the bracket bench's printable result that
|
|
1617
|
-
triangles to 21,124 and 27.808 cm³ to 27.806 cm
|
|
1616
|
+
`cad optimise` says how many triangles it had and has. On the bracket bench's printable result that takes 75,592
|
|
1617
|
+
triangles to 21,124 and 27.808 cm³ to 27.806 cm³ (35.04 g of PLA at 1.26 g/cm³ either way, 0.003 g apart), a quarter
|
|
1618
|
+
of the size in a file or a link. `"outline": { "reduce": 0.05 }` keeps the surface closer (31,154 triangles on the
|
|
1619
|
+
bracket), and `"outline": { "reduce": false }` keeps every triangle it was drawn with.
|
|
1618
1620
|
|
|
1619
1621
|
A part prints in one orientation and is loaded in another. Draw it as it prints, and turn it back for its analysis:
|
|
1620
1622
|
`"rotate"` (degrees about x, then y, then z, as JSCAD's `rotate`) then `"move"` (mm) put it in the problem's frame.
|
package/lib/explain.mjs
CHANGED
|
@@ -37,8 +37,13 @@ export function valuesOf(b, names = []) {
|
|
|
37
37
|
export async function why(ref, name, { depth = 12 } = {}) {
|
|
38
38
|
const builds = new Map(), seen = new Set();
|
|
39
39
|
const get = async (r) => builds.get(r) || (builds.set(r, await build(locate(r))), builds.get(r));
|
|
40
|
+
// A rule as an expression writes it (pla_prusament.strength_z) is the entry of the set named with a hyphen
|
|
41
|
+
// (pla-prusament), as variables reads it: a - is a minus in an expression
|
|
42
|
+
const entry = (b, n) => b.entries.find((x) => x.name === n) || (n.includes('.') ? b.entries.find((x) => x.name === n.slice(0, n.indexOf('.')).replace(/_/g, '-') + n.slice(n.indexOf('.'))) : undefined);
|
|
40
43
|
const node = async (r, n, d) => {
|
|
41
|
-
const b = await get(r),
|
|
44
|
+
const b = await get(r), end = /^[^.]+\.[^.]+\.(low|high)$/.exec(n)?.[1], base = end && entry(b, n.slice(0, -end.length - 1));
|
|
45
|
+
// An end of a rule's range (pa_cf.strength.low): the rule's own entry, its value that end, reading the rule
|
|
46
|
+
const e = base ? { ...base, value: base[end], expr: undefined, rule: `the ${end} end of the range ${base.name} is found in (${base.rule})` } : entry(b, n);
|
|
42
47
|
if (!e) throw Object.assign(new Error(`${r}: no variable or rule "${n}"`), { code: 'var.unknown' });
|
|
43
48
|
const out = { name: n, value: e.value, unit: e.unit || '', object: r, ...(e.expr ? { expr: e.expr } : {}), ...(e.rule ? { rule: e.rule } : {}),
|
|
44
49
|
...(e.kind ? { kind: e.kind } : {}), ...(e.source ? { source: e.source } : {}) };
|
package/lib/optimise.mjs
CHANGED
|
@@ -37,6 +37,12 @@ export async function readProblem(project, ref) {
|
|
|
37
37
|
const link = { key, name, object: null };
|
|
38
38
|
return reading.run([...chain, link], () => readOne(project, ref, link));
|
|
39
39
|
}
|
|
40
|
+
// A solid result's surface is thinned by default to within this many mm of where it was drawn: a quarter of an X1C's
|
|
41
|
+
// 0.42 mm print line, so the printer cannot tell. On the bracket bench's printable result it takes 75,592 triangles to
|
|
42
|
+
// 21,124 and 27.808 cm³ to 27.806 (35.04 g of PLA either way). "outline": { "reduce": false } keeps every triangle.
|
|
43
|
+
// Fewer triangles is on unless outline.reduce is false: within outline.reduce mm of the surface as drawn, closed, and no
|
|
44
|
+
// more overhang or tips. (Said here, not in optimised(), whose text is part of the densities key: see densityCode)
|
|
45
|
+
const REDUCE = 0.1;
|
|
40
46
|
const reading = new AsyncLocalStorage();
|
|
41
47
|
async function readOne(project, ref, link) {
|
|
42
48
|
const [name, variant] = String(ref).split(':'), file = problemFile(project, name);
|
|
@@ -142,7 +148,7 @@ async function readOne(project, ref, link) {
|
|
|
142
148
|
...(p.input_spring != null ? { input_spring: ev(p.input_spring) } : {}),
|
|
143
149
|
};
|
|
144
150
|
if (dim === 2 && !(problem.thickness > 0)) throw new Error(`${path.basename(file)}: a flat (2D) problem needs a thickness`);
|
|
145
|
-
const outline = { smooth: p.outline?.smooth ?? 4, minArea: p.outline?.min_area != null ? ev(p.outline.min_area) : problem.cell ** 2 * 2, fine: p.outline?.fine != null ? ev(p.outline.fine) : 1.25, ...(p.outline?.reduce
|
|
151
|
+
const outline = { smooth: p.outline?.smooth ?? 4, minArea: p.outline?.min_area != null ? ev(p.outline.min_area) : problem.cell ** 2 * 2, fine: p.outline?.fine != null ? ev(p.outline.fine) : 1.25, ...(dim === 3 && p.outline?.reduce !== false ? { reduce: p.outline?.reduce != null ? ev(p.outline.reduce) : REDUCE } : {}) }; // fine: the cells a printable solid is cleaned and drawn on, mm (its own cells if smaller)
|
|
146
152
|
// A printable solid's surface is kept within the printer's overhang limit too (smoothing can tip faces past it)
|
|
147
153
|
// (outline.tip: faces the smoothing left steeper than the limit are tipped back to it too; off unless asked, since
|
|
148
154
|
// tipped corners leave dips that slice as islands, and the layers step out no further for it)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/cad",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.89",
|
|
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": {
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
"url": "https://github.com/JoniBach/rulecad/issues"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@rulecad/variables": "^0.3.
|
|
61
|
+
"@rulecad/variables": "^0.3.7",
|
|
62
62
|
"@rulecad/keyboard-layout": "^0.1.2",
|
|
63
63
|
"@rulecad/printcheck": "^0.3.3",
|
|
64
64
|
"@rulecad/fit": "^0.4.0",
|
|
65
65
|
"@rulecad/model-link": "^0.3.2",
|
|
66
66
|
"@rulecad/versions": "^0.1.6",
|
|
67
67
|
"@rulecad/shapes": "^0.4.8",
|
|
68
|
-
"@rulecad/rules": "^0.3.
|
|
68
|
+
"@rulecad/rules": "^0.3.28",
|
|
69
69
|
"@jscad/modeling": "^2.12.0",
|
|
70
70
|
"three": "^0.186.1",
|
|
71
71
|
"@rulecad/fea": "^0.2.14",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@rulecad/flexures": "^0.5.12",
|
|
74
74
|
"@rulecad/gears": "^0.3.4",
|
|
75
75
|
"@rulecad/motors": "^0.1.6",
|
|
76
|
-
"@rulecad/fixings": "^0.1.
|
|
76
|
+
"@rulecad/fixings": "^0.1.8",
|
|
77
77
|
"@rulecad/robots": "^0.1.4",
|
|
78
78
|
"@rulecad/frames": "^0.1.13"
|
|
79
79
|
},
|
|
@@ -150,8 +150,8 @@
|
|
|
150
150
|
"description": "3D with an overhang direction: faces the smoothing left steeper than the printer's limit are tipped back to it as well (off by default: tipped corners can leave dips that slice as islands, and the sliced overhang is no smaller for it; the bracket example's 160 mm² of lean is the same either way)"
|
|
151
151
|
},
|
|
152
152
|
"reduce": {
|
|
153
|
-
"$ref": "#/$defs/expr",
|
|
154
|
-
"description": "3D: fewer triangles, the surface kept within this many mm of where it was drawn
|
|
153
|
+
"anyOf": [{ "$ref": "#/$defs/expr" }, { "const": false }],
|
|
154
|
+
"description": "3D: fewer triangles, the surface kept within this many mm of where it was drawn, closed, and no more overhang or tips than it had. 0.1 mm (a quarter of a print line) unless given; false keeps every triangle the surface was drawn with"
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
},
|