Rename SolveCraft to SolidCraft everywhere, with compatibility shims (#389)

* WIP deep rename (not for push)

* WIP2

* WIP3

* WIP4 wxs fix

* rustfmt

* Rename the remaining identifiers in merged crash-report code

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RjGw4gA5ZvKrU8MQP6sBgT

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
bherbruckandClaude Opus 5.5 authored and GitHub committed 2026-10-12 17:17:01 -04:00
1 parent 27415e4dd7
commit 296683229d
464 files changed
+3408 -2956

No files matched your search

@@ -0,0 +1,26 @@
//! The registry remains valid JSON and a closed pipeline reader must not cause a panic.
use std::process::{Command, Stdio};
#[test]
fn registry_output_is_complete_json() {
let output = Command::new(env!("CARGO_BIN_EXE_solidcraft-cli")).arg("commands").output().unwrap();
assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr));
let registry: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
let commands = registry.as_array().unwrap();
assert!(commands.iter().any(|command| command["id"] == "solid.box"));
assert!(commands.iter().any(|command| command["id"] == "engine.commands"));
assert!(output.stdout.ends_with(b"\n"));
assert!(output.stderr.is_empty());
}
#[test]
fn closed_registry_pipe_exits_without_panicking() {
let mut child = Command::new(env!("CARGO_BIN_EXE_solidcraft-cli")).arg("commands").stdout(Stdio::piped()).stderr(Stdio::piped()).spawn().unwrap();
// Close our read end before waiting. No sleeps or timing threshold are needed:
// the registry is larger than the pipe buffer, so it cannot all be written first.
drop(child.stdout.take());
let output = child.wait_with_output().unwrap();
assert!(output.status.success(), "status: {}; stderr: {}", output.status, String::from_utf8_lossy(&output.stderr));
assert!(output.stderr.is_empty(), "{}", String::from_utf8_lossy(&output.stderr));
}
@@ -0,0 +1,22 @@
# Design file corpus
Designs saved by older SolidCraft builds. `tests/design_corpus.rs` opens each one with the
current build and checks that it evaluates as it did when saved (the `.expected.json` next to
it is `solidcraft-cli eval` of that file by the build that saved it: bodies, volumes, areas,
world bounding boxes), that it is upgraded to the current file format, and that damaged and
hostile variants of it never panic.
| File | Saved by | Era |
|---|---|---|
| `m0-box-fillet-hole` | 3714342 | M0: sketch, parameters, extrude, fillet, cut |
| `m0-revolve-primitives` | 3714342 | M0: revolve, primitives, combine, chamfer, timeline edit |
| `components-arm` | 97d03e3 | components and occurrences: move, copy, Paste New, ground |
| `joints-hinge` | c2309eb | joints: revolute hinge driven by a parameter |
| `modern-sheet-metal` | bd98035 | sheet metal contour flange (oracle 72) |
| `modern-path-pattern` | bd98035 | pattern on path (oracle 53) |
| `modern-plastic` | bd98035 | shell, lip, boss, rest, snap fit, plastic rule |
| `naming-split-pieces` | 9a979cf | format 13 names: a slot splits the top; fillet, chamfer and offset face name its pieces by number (`F2:top#2`) |
| `split-body-pieces` | v0.3.2 (07e263d) | a slot along X cuts a block into two bodies; a fillet, a chamfer and an appearance refer to the pieces by body name (`Body1`, `Body1 (1)`) |
The scripts that made them are in `scripts/`. Never regenerate a file with a newer build: the
point is that it was written by the old one. Add new files for new eras instead.
@@ -0,0 +1,134 @@
{
"bodies": [
{
"area_mm2": 700.5299915783324,
"bbox": {
"max": [
10.0,
10.0,
10.000000000000007
],
"min": [
0.0,
0.0,
-6.080836915950756e-16
]
},
"center_of_mass": [
4.999999998722992,
4.999999999366269,
4.999999996470206
],
"density_g_cm3": 1.29,
"edges": 14,
"face_types": {
"cylinder": 1,
"plane": 6
},
"faces": 7,
"kernel": {
"edges": 18,
"faces": 8,
"shells": 1,
"vertices": 12
},
"mass_g": 1.1279207478827844,
"material": "Default",
"name": "Base",
"vertices": 10,
"volume_mm3": 874.3571689013833
}
],
"body_count": 1,
"params": [],
"sketches": [
{
"curves": 1,
"dof": 3,
"id": 11,
"name": "S1",
"profiles": 1,
"status": "solved"
}
],
"timeline": [
{
"error": null,
"id": 1,
"ms": 13.568090999999999,
"name": "Box1",
"rolled_back": false,
"suppressed": false,
"type": "BoxFeature",
"warning": null
},
{
"error": null,
"id": 4,
"ms": 1.004123,
"name": "Box2",
"rolled_back": false,
"suppressed": false,
"type": "BoxFeature",
"warning": null
},
{
"error": null,
"id": 5,
"ms": 6.818065,
"name": "Fillet1",
"rolled_back": false,
"suppressed": false,
"type": "FilletFeature",
"warning": null
},
{
"error": null,
"id": 9,
"ms": 0.223829,
"name": "Box2 (copy)",
"rolled_back": false,
"suppressed": false,
"type": "BoxFeature",
"warning": null
},
{
"error": null,
"id": 10,
"ms": 6.139636,
"name": "Fillet1 (copy)",
"rolled_back": false,
"suppressed": false,
"type": "FilletFeature",
"warning": null
},
{
"error": null,
"id": 11,
"ms": 0.045728,
"name": "S1",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 12,
"ms": 1537.323948,
"name": "Extrude1",
"rolled_back": false,
"suppressed": false,
"type": "ExtrudeFeature",
"warning": null
}
],
"total": {
"area_mm2": 700.5299915783324,
"edges": 14,
"faces": 7,
"mass_g": 1.1279207478827844,
"vertices": 10,
"volume_mm3": 874.3571689013833
}
}
@@ -0,0 +1,263 @@
{
"format": "solidcraft/1",
"name": "Untitled",
"units": "mm",
"params": [],
"features": [
{
"id": 1,
"name": "Box1",
"suppressed": false,
"body_names": [
"Base"
],
"type": "box",
"corner": [
0.0,
0.0,
0.0
],
"length": "10",
"width": "10",
"height": "10",
"operation": "new_body"
},
{
"id": 4,
"name": "Box2",
"suppressed": false,
"body_names": [
"ArmBody"
],
"component": 2,
"type": "box",
"corner": [
20.0,
0.0,
0.0
],
"length": "10",
"width": "4",
"height": "4",
"operation": "new_body"
},
{
"id": 5,
"name": "Fillet1",
"suppressed": false,
"component": 2,
"type": "fillet",
"edges": [
[
25.0,
4.0,
4.0
]
],
"radius": "1"
},
{
"id": 9,
"name": "Box2 (copy)",
"suppressed": false,
"component": 7,
"type": "box",
"corner": [
20.0,
0.0,
0.0
],
"length": "10",
"width": "4",
"height": "4",
"operation": "new_body"
},
{
"id": 10,
"name": "Fillet1 (copy)",
"suppressed": false,
"component": 7,
"type": "fillet",
"edges": [
[
25.0,
4.0,
4.0
]
],
"radius": "1"
},
{
"id": 11,
"name": "S1",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "origin",
"name": "XY"
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "c1.center",
"pos": [
5.0,
5.0
],
"fixed": false
}
],
"curves": [
{
"id": "c1",
"type": "circle",
"c": 1,
"r": 2.0,
"construction": false
}
],
"constraints": [],
"counters": {
"c": 1
}
}
},
{
"id": 12,
"name": "Extrude1",
"suppressed": false,
"type": "extrude",
"sketch": 11,
"profiles": {
"type": "all"
},
"extent": {
"distance": "10",
"direction": "positive"
},
"operation": "cut"
}
],
"next_id": 13,
"components": [
{
"id": 2,
"name": "Arm",
"parent": 0
},
{
"id": 7,
"name": "Arm (copy)",
"parent": 0
}
],
"occurrences": [
{
"id": 3,
"component": 2,
"parent": 0,
"name": "Arm:1",
"transform": [
[
1.0,
0.0,
0.0,
0.0
],
[
0.0,
1.0,
0.0,
0.0
],
[
0.0,
0.0,
1.0,
0.0
],
[
0.0,
50.0,
0.0,
1.0
]
],
"grounded": true
},
{
"id": 6,
"component": 2,
"parent": 0,
"name": "Arm:2",
"transform": [
[
1.0,
0.0,
0.0,
0.0
],
[
0.0,
1.0,
0.0,
0.0
],
[
0.0,
0.0,
1.0,
0.0
],
[
0.0,
70.0,
0.0,
1.0
]
],
"grounded": false
},
{
"id": 8,
"component": 7,
"parent": 0,
"name": "Arm (copy):1",
"transform": [
[
1.0,
0.0,
0.0,
0.0
],
[
0.0,
1.0,
0.0,
0.0
],
[
0.0,
0.0,
1.0,
0.0
],
[
0.0,
20.0,
0.0,
1.0
]
],
"grounded": false
}
]
}
@@ -0,0 +1,217 @@
{
"bodies": [
{
"area_mm2": 2820.0,
"bbox": {
"max": [
40.0,
30.0,
3.0
],
"min": [
0.0,
0.0,
0.0
]
},
"center_of_mass": [
20.0,
15.0,
1.5
],
"density_g_cm3": 1.29,
"edges": 12,
"face_types": {
"plane": 6
},
"faces": 6,
"kernel": {
"edges": 12,
"faces": 6,
"shells": 1,
"vertices": 8
},
"mass_g": 4.644,
"material": "Default",
"name": "Body1",
"vertices": 8,
"volume_mm3": 3600.0
},
{
"area_mm2": 1105.7821673177034,
"bbox": {
"max": [
40.00000000000002,
37.0,
8.000000000000002
],
"min": [
0.0,
29.0,
-6.661338147750943e-16
]
},
"center_of_mass": [
20.00000000000423,
32.99999999999611,
3.9999999999995404
],
"density_g_cm3": 1.29,
"edges": 2,
"face_types": {
"cylinder": 1,
"plane": 2
},
"faces": 3,
"kernel": {
"edges": 6,
"faces": 4,
"shells": 1,
"vertices": 4
},
"mass_g": 2.593268071855663,
"material": "Default",
"name": "Body2",
"vertices": 2,
"volume_mm3": 2010.2853270198937
},
{
"area_mm2": 2820.0,
"bbox": {
"max": [
40.0,
32.00000000000008,
37.000000000000064
],
"min": [
0.0,
29.000000000000075,
7.000000000000064
]
},
"center_of_mass": [
20.0,
30.500000000000075,
22.00000000000007
],
"density_g_cm3": 1.29,
"edges": 12,
"face_types": {
"plane": 6
},
"faces": 6,
"kernel": {
"edges": 12,
"faces": 6,
"shells": 1,
"vertices": 8
},
"mass_g": 4.643999999999996,
"material": "Default",
"name": "Body3",
"vertices": 8,
"volume_mm3": 3599.9999999999964
},
{
"area_mm2": 1105.782167317711,
"bbox": {
"max": [
40.00000000000002,
37.000000000000085,
8.000000000000064
],
"min": [
0.0,
29.000000000000075,
6.394884621840902e-14
]
},
"center_of_mass": [
20.000000000004935,
32.99999999999709,
3.999999999999749
],
"density_g_cm3": 1.29,
"edges": 2,
"face_types": {
"cylinder": 1,
"plane": 2
},
"faces": 3,
"kernel": {
"edges": 6,
"faces": 4,
"shells": 1,
"vertices": 4
},
"mass_g": 2.59326807185558,
"material": "Default",
"name": "Body4",
"vertices": 2,
"volume_mm3": 2010.2853270198293
}
],
"body_count": 4,
"params": [
{
"comment": "",
"error": null,
"expression": "90 deg",
"model": false,
"name": "open_angle",
"unit": "deg",
"value": 1.5707963267948966
}
],
"sketches": [],
"timeline": [
{
"error": null,
"id": 3,
"ms": 1.1335799999999998,
"name": "Box1",
"rolled_back": false,
"suppressed": false,
"type": "BoxFeature",
"warning": null
},
{
"error": null,
"id": 4,
"ms": 0.580462,
"name": "Cylinder1",
"rolled_back": false,
"suppressed": false,
"type": "CylinderFeature",
"warning": null
},
{
"error": null,
"id": 7,
"ms": 0.257673,
"name": "Box2",
"rolled_back": false,
"suppressed": false,
"type": "BoxFeature",
"warning": null
},
{
"error": null,
"id": 8,
"ms": 0.5234019999999999,
"name": "Cylinder2",
"rolled_back": false,
"suppressed": false,
"type": "CylinderFeature",
"warning": null
}
],
"total": {
"area_mm2": 7851.564334635414,
"edges": 28,
"faces": 18,
"mass_g": 14.474536143711237,
"vertices": 20,
"volume_mm3": 11220.570654039719
}
}
@@ -0,0 +1,225 @@
{
"format": "solidcraft/1",
"name": "Untitled",
"units": "mm",
"params": [
{
"name": "open_angle",
"expr": "90 deg",
"unit": "deg",
"model": false
}
],
"features": [
{
"id": 3,
"name": "Box1",
"suppressed": false,
"param_names": [
"d1",
"d2",
"d3"
],
"component": 1,
"type": "box",
"corner": [
0.0,
0.0,
0.0
],
"length": "40",
"width": "30",
"height": "3",
"operation": "new_body"
},
{
"id": 4,
"name": "Cylinder1",
"suppressed": false,
"param_names": [
"d4",
"d5"
],
"component": 1,
"type": "cylinder",
"base": [
0.0,
33.0,
4.0
],
"axis": [
1.0,
0.0,
0.0
],
"radius": "4",
"height": "40",
"operation": "new_body"
},
{
"id": 7,
"name": "Box2",
"suppressed": false,
"param_names": [
"d6",
"d7",
"d8"
],
"component": 5,
"type": "box",
"corner": [
0.0,
0.0,
0.0
],
"length": "40",
"width": "30",
"height": "3",
"operation": "new_body"
},
{
"id": 8,
"name": "Cylinder2",
"suppressed": false,
"param_names": [
"d9",
"d10"
],
"component": 5,
"type": "cylinder",
"base": [
0.0,
33.0,
4.0
],
"axis": [
1.0,
0.0,
0.0
],
"radius": "4",
"height": "40",
"operation": "new_body"
}
],
"next_id": 9,
"components": [
{
"id": 1,
"name": "LeafA",
"parent": 0
},
{
"id": 5,
"name": "LeafB",
"parent": 0
}
],
"occurrences": [
{
"id": 2,
"component": 1,
"parent": 0,
"name": "LeafA:1",
"transform": [
[
1.0,
0.0,
0.0,
0.0
],
[
0.0,
1.0,
0.0,
0.0
],
[
0.0,
0.0,
1.0,
0.0
],
[
0.0,
0.0,
0.0,
1.0
]
],
"grounded": true
},
{
"id": 6,
"component": 5,
"parent": 0,
"name": "LeafB:1",
"transform": [
[
1.0,
0.0,
0.0,
0.0
],
[
0.0,
6.123233995736766e-17,
-1.0,
0.0
],
[
0.0,
1.0,
6.123233995736766e-17,
0.0
],
[
0.0,
29.000000000000075,
37.000000000000064,
1.0
]
],
"grounded": false
}
],
"assembly": {
"joints": [
{
"id": 1,
"name": "Hinge",
"kind": "revolute",
"a": {
"occurrence": 2,
"snap": {
"type": "circle_center",
"pick": [
1.0,
37.0,
4.0
]
}
},
"b": {
"occurrence": 6,
"snap": {
"type": "circle_center",
"pick": [
1.0,
37.0,
4.0
]
}
},
"values": [
1.5707963267948966
],
"limits": [
null
],
"offset": 0.0,
"angle": 0.0
}
]
}
}
@@ -0,0 +1,128 @@
{
"bodies": [
{
"area_mm2": 5641.5699696719,
"bbox": {
"max": [
40.0,
30.0,
20.00000000000001
],
"min": [
0.0,
0.0,
-2.331468351865795e-15
]
},
"center_of_mass": [
20.0333953680467,
15.02475683626249,
9.999999936169297
],
"edges": 17,
"face_types": {
"cylinder": 2,
"plane": 6
},
"faces": 8,
"kernel": {
"edges": 21,
"faces": 9,
"shells": 1,
"vertices": 14
},
"name": "Body1",
"vertices": 12,
"volume_mm3": 22391.21832759239
}
],
"body_count": 1,
"params": [
{
"comment": "",
"error": null,
"expression": "40 mm",
"model": false,
"name": "width",
"unit": "mm",
"value": 40.0
}
],
"sketches": [
{
"curves": 4,
"dof": 4,
"id": 1,
"name": "Sketch1",
"profiles": 1,
"status": "solved"
},
{
"curves": 1,
"dof": 3,
"id": 4,
"name": "Sketch2",
"profiles": 1,
"status": "solved"
}
],
"timeline": [
{
"error": null,
"id": 1,
"ms": 0.043782999999999996,
"name": "Sketch1",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 2,
"ms": 1.609402,
"name": "Extrude1",
"rolled_back": false,
"suppressed": false,
"type": "ExtrudeFeature",
"warning": null
},
{
"error": null,
"id": 3,
"ms": 11.196359,
"name": "Fillet1",
"rolled_back": false,
"suppressed": false,
"type": "FilletFeature",
"warning": null
},
{
"error": null,
"id": 4,
"ms": 0.031249,
"name": "Sketch2",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 5,
"ms": 1378.231746,
"name": "Extrude2",
"rolled_back": false,
"suppressed": false,
"type": "ExtrudeFeature",
"warning": null
}
],
"total": {
"area_mm2": 5641.5699696719,
"edges": 17,
"faces": 8,
"vertices": 12,
"volume_mm3": 22391.21832759239
}
}
@@ -0,0 +1,208 @@
{
"format": "solidcraft/1",
"name": "Untitled",
"units": "mm",
"params": [
{
"name": "width",
"expr": "40 mm",
"unit": "mm",
"model": false
}
],
"features": [
{
"id": 1,
"name": "Sketch1",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "origin",
"name": "XY"
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "p1",
"pos": [
0.0,
0.0
],
"fixed": false
},
{
"id": "p2",
"pos": [
40.0,
0.0
],
"fixed": false
},
{
"id": "p3",
"pos": [
40.0,
30.0
],
"fixed": false
},
{
"id": "p4",
"pos": [
0.0,
30.0
],
"fixed": false
}
],
"curves": [
{
"id": "l5",
"type": "line",
"a": 1,
"b": 2,
"construction": false
},
{
"id": "l6",
"type": "line",
"a": 2,
"b": 3,
"construction": false
},
{
"id": "l7",
"type": "line",
"a": 3,
"b": 4,
"construction": false
},
{
"id": "l8",
"type": "line",
"a": 4,
"b": 1,
"construction": false
}
],
"constraints": [
{
"id": "k9",
"type": "horizontal",
"l": 0
},
{
"id": "k10",
"type": "horizontal",
"l": 2
},
{
"id": "k11",
"type": "vertical",
"l": 1
},
{
"id": "k12",
"type": "vertical",
"l": 3
}
],
"next_id": 13
}
},
{
"id": 2,
"name": "Extrude1",
"suppressed": false,
"type": "extrude",
"sketch": 1,
"profiles": {
"type": "all"
},
"extent": {
"distance": "width / 2",
"direction": "positive"
},
"operation": "new_body"
},
{
"id": 3,
"name": "Fillet1",
"suppressed": false,
"type": "fillet",
"edges": [
[
0.0,
0.0,
10.0
]
],
"radius": "3"
},
{
"id": 4,
"name": "Sketch2",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "origin",
"name": "XY"
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "c1.center",
"pos": [
20.0,
15.0
],
"fixed": false
}
],
"curves": [
{
"id": "c1",
"type": "circle",
"c": 1,
"r": 5.0,
"construction": false
}
],
"constraints": [],
"next_id": 2
}
},
{
"id": 5,
"name": "Extrude2",
"suppressed": false,
"type": "extrude",
"sketch": 4,
"profiles": {
"type": "all"
},
"extent": {
"distance": "20",
"direction": "positive"
},
"operation": "cut"
}
],
"next_id": 6
}
@@ -0,0 +1,155 @@
{
"bodies": [
{
"area_mm2": 835.4130709318358,
"bbox": {
"max": [
15.0,
15.0,
5.0
],
"min": [
-15.0,
0.0,
0.0
]
},
"center_of_mass": [
-5.1971813422033816e-8,
8.063488509334698,
2.500000003353729
],
"edges": 12,
"face_types": {
"cylinder": 2,
"plane": 4
},
"faces": 6,
"kernel": {
"edges": 28,
"faces": 14,
"shells": 1,
"vertices": 16
},
"name": "Body1",
"vertices": 8,
"volume_mm3": 981.8090960455798
},
{
"area_mm2": 693.6702600465544,
"bbox": {
"max": [
40.0,
10.0,
10.000000000000007
],
"min": [
30.0,
0.0,
-2.3775115272352145e-15
]
},
"center_of_mass": [
35.02683928802334,
4.999999999290639,
4.973160725428021
],
"edges": 17,
"face_types": {
"cylinder": 1,
"plane": 7
},
"faces": 8,
"kernel": {
"edges": 21,
"faces": 9,
"shells": 1,
"vertices": 14
},
"name": "Body2",
"vertices": 12,
"volume_mm3": 869.3724925404262
}
],
"body_count": 2,
"params": [],
"sketches": [
{
"curves": 4,
"dof": 8,
"id": 1,
"name": "Sketch1",
"profiles": 1,
"status": "solved"
}
],
"timeline": [
{
"error": null,
"id": 1,
"ms": 0.034476,
"name": "Sketch1",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 2,
"ms": 7.732595999999999,
"name": "Revolve1",
"rolled_back": false,
"suppressed": false,
"type": "RevolveFeature",
"warning": null
},
{
"error": null,
"id": 3,
"ms": 2.5985959999999997,
"name": "Box1",
"rolled_back": false,
"suppressed": false,
"type": "BoxFeature",
"warning": null
},
{
"error": null,
"id": 4,
"ms": 1.6926910000000002,
"name": "Cylinder1",
"rolled_back": false,
"suppressed": false,
"type": "CylinderFeature",
"warning": null
},
{
"error": null,
"id": 5,
"ms": 384.534019,
"name": "Combine1",
"rolled_back": false,
"suppressed": false,
"type": "CombineFeature",
"warning": null
},
{
"error": null,
"id": 6,
"ms": 150.763588,
"name": "Chamfer1",
"rolled_back": false,
"suppressed": false,
"type": "ChamferFeature",
"warning": null
}
],
"total": {
"area_mm2": 1529.0833309783902,
"edges": 29,
"faces": 14,
"vertices": 20,
"volume_mm3": 1851.181588586006
}
}
@@ -0,0 +1,171 @@
{
"format": "solidcraft/1",
"name": "Untitled",
"units": "mm",
"params": [],
"features": [
{
"id": 1,
"name": "Sketch1",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "origin",
"name": "XZ"
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "l1.start",
"pos": [
10.0,
0.0
],
"fixed": false
},
{
"id": "l1.end",
"pos": [
15.0,
0.0
],
"fixed": false
},
{
"id": "l2.end",
"pos": [
15.0,
5.0
],
"fixed": false
},
{
"id": "l3.end",
"pos": [
10.0,
5.0
],
"fixed": false
}
],
"curves": [
{
"id": "l1",
"type": "line",
"a": 1,
"b": 2,
"construction": false
},
{
"id": "l2",
"type": "line",
"a": 2,
"b": 3,
"construction": false
},
{
"id": "l3",
"type": "line",
"a": 3,
"b": 4,
"construction": false
},
{
"id": "l4",
"type": "line",
"a": 4,
"b": 1,
"construction": false
}
],
"constraints": [],
"next_id": 5
}
},
{
"id": 2,
"name": "Revolve1",
"suppressed": false,
"type": "revolve",
"sketch": 1,
"profiles": {
"type": "all"
},
"axis": {
"type": "sketch_axis",
"axis": "y"
},
"angle": "180 deg",
"operation": "new_body"
},
{
"id": 3,
"name": "Box1",
"suppressed": false,
"type": "box",
"corner": [
30.0,
0.0,
0.0
],
"length": "10",
"width": "10",
"height": "10",
"operation": "new_body"
},
{
"id": 4,
"name": "Cylinder1",
"suppressed": false,
"type": "cylinder",
"base": [
35.0,
5.0,
-5.0
],
"axis": [
0.0,
0.0,
1.0
],
"radius": "(4) / 2",
"height": "20",
"operation": "new_body"
},
{
"id": 5,
"name": "Combine1",
"suppressed": false,
"type": "combine",
"target": "Body2",
"tools": [
"Body3"
],
"operation": "cut",
"keep_tools": false
},
{
"id": 6,
"name": "Chamfer1",
"suppressed": false,
"type": "chamfer",
"edges": [
[
30.0,
5.0,
10.0
]
],
"distance": "1"
}
],
"next_id": 7
}
@@ -0,0 +1,122 @@
{
"bodies": [
{
"area_mm2": 16463.932136252846,
"bbox": {
"max": [
120.0,
60.0,
5.0000000000000036
],
"min": [
0.0,
0.0,
0.0
]
},
"center_of_mass": [
60.000000010005735,
29.965234604788655,
2.4999999999999867
],
"density_g_cm3": 1.29,
"edges": 26,
"face_types": {
"cylinder": 7,
"plane": 6
},
"faces": 13,
"kernel": {
"edges": 54,
"faces": 20,
"shells": 1,
"vertices": 36
},
"mass_g": 45.163625870882676,
"material": "Default",
"name": "Plate",
"vertices": 22,
"volume_mm3": 35010.56269060673
}
],
"body_count": 1,
"params": [],
"sketches": [
{
"curves": 4,
"dof": 8,
"id": 1,
"name": "Plate_sketch",
"profiles": 1,
"status": "solved"
},
{
"curves": 2,
"dof": 6,
"id": 3,
"name": "PathSketch",
"profiles": 1,
"status": "solved"
}
],
"timeline": [
{
"error": null,
"id": 1,
"ms": 0.093199,
"name": "Plate_sketch",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 2,
"ms": 9.166392,
"name": "Plate",
"rolled_back": false,
"suppressed": false,
"type": "ExtrudeFeature",
"warning": null
},
{
"error": null,
"id": 3,
"ms": 0.057569999999999996,
"name": "PathSketch",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 4,
"ms": 84.237259,
"name": "Hole1",
"rolled_back": false,
"suppressed": false,
"type": "ExtrudeFeature",
"warning": null
},
{
"error": null,
"id": 5,
"ms": 1093.817516,
"name": "PathPattern1",
"rolled_back": false,
"suppressed": false,
"type": "PathPatternFeature",
"warning": null
}
],
"total": {
"area_mm2": 16463.932136252846,
"edges": 26,
"faces": 13,
"mass_g": 45.163625870882676,
"vertices": 22,
"volume_mm3": 35010.56269060673
}
}
@@ -0,0 +1,238 @@
{
"format": "solidcraft/1",
"name": "Untitled",
"units": "mm",
"params": [],
"features": [
{
"id": 1,
"name": "Plate_sketch",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "origin",
"name": "XY"
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "l1.start",
"pos": [
0.0,
0.0
],
"fixed": false
},
{
"id": "l1.end",
"pos": [
120.0,
0.0
],
"fixed": false
},
{
"id": "l2.end",
"pos": [
120.0,
60.0
],
"fixed": false
},
{
"id": "l3.end",
"pos": [
0.0,
60.0
],
"fixed": false
}
],
"curves": [
{
"id": "l1",
"type": "line",
"a": 1,
"b": 2,
"construction": false
},
{
"id": "l2",
"type": "line",
"a": 2,
"b": 3,
"construction": false
},
{
"id": "l3",
"type": "line",
"a": 3,
"b": 4,
"construction": false
},
{
"id": "l4",
"type": "line",
"a": 4,
"b": 1,
"construction": false
}
],
"constraints": [],
"counters": {}
}
},
{
"id": 2,
"name": "Plate",
"suppressed": false,
"body_names": [
"Plate"
],
"param_names": [
"d1"
],
"type": "extrude",
"sketch": 1,
"profiles": {
"type": "curves",
"loops": [
[
"l1",
"l2",
"l3",
"l4"
]
]
},
"extent": {
"distance": "5",
"direction": "positive"
},
"operation": "new_body"
},
{
"id": 3,
"name": "PathSketch",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "origin",
"name": "XY"
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "a1.center",
"pos": [
60.0,
3.3333333333333335
],
"fixed": false
},
{
"id": "a1.start",
"pos": [
100.0,
15.0
],
"fixed": false
},
{
"id": "a1.end",
"pos": [
20.0,
15.000000000000002
],
"fixed": false
}
],
"curves": [
{
"id": "a1",
"type": "arc",
"c": 1,
"a": 2,
"b": 3,
"construction": false
},
{
"id": "c1",
"type": "circle",
"c": 2,
"r": 3.0,
"construction": false
}
],
"constraints": [],
"counters": {}
}
},
{
"id": 4,
"name": "Hole1",
"suppressed": false,
"body_names": [
"Plate"
],
"param_names": [
"d2"
],
"type": "extrude",
"sketch": 3,
"profiles": {
"type": "curves",
"loops": [
[
"c1"
]
]
},
"extent": {
"distance": "0",
"direction": "positive",
"through_all": true
},
"operation": "cut"
},
{
"id": 5,
"name": "PathPattern1",
"suppressed": false,
"param_names": [
"d3",
"d4"
],
"type": "pattern",
"features": [
"Hole1"
],
"pattern": {
"type": "path",
"path_sketch": 3,
"path": [
"a1"
],
"count": "7",
"spacing": "17.875031"
}
}
],
"next_id": 6
}
@@ -0,0 +1,126 @@
{
"bodies": [
{
"area_mm2": 24280.380636378435,
"bbox": {
"max": [
80.0,
50.0,
32.0
],
"min": [
0.0,
0.0,
0.0
]
},
"center_of_mass": [
39.89510389356416,
24.906013036240918,
10.936558895792075
],
"density_g_cm3": 1.29,
"edges": 82,
"face_types": {
"cone": 1,
"cylinder": 1,
"plane": 35
},
"faces": 37,
"kernel": {
"edges": 90,
"faces": 39,
"shells": 1,
"vertices": 60
},
"mass_g": 29.716687268283682,
"material": "Default",
"name": "Body1",
"vertices": 56,
"volume_mm3": 23036.19168084006
}
],
"body_count": 1,
"params": [
{
"comment": "",
"error": null,
"expression": "2 mm",
"model": false,
"name": "wall",
"unit": "mm",
"value": 2.0
}
],
"sketches": [],
"timeline": [
{
"error": null,
"id": 1,
"ms": 13.671479,
"name": "Box1",
"rolled_back": false,
"suppressed": false,
"type": "BoxFeature",
"warning": null
},
{
"error": null,
"id": 2,
"ms": 15.729548999999999,
"name": "Shell1",
"rolled_back": false,
"suppressed": false,
"type": "ShellFeature",
"warning": null
},
{
"error": null,
"id": 3,
"ms": 136.407014,
"name": "Lip1",
"rolled_back": false,
"suppressed": false,
"type": "LipFeature",
"warning": null
},
{
"error": null,
"id": 4,
"ms": 530.869306,
"name": "Boss1",
"rolled_back": false,
"suppressed": false,
"type": "BossFeature",
"warning": null
},
{
"error": null,
"id": 5,
"ms": 176.568115,
"name": "Rest1",
"rolled_back": false,
"suppressed": false,
"type": "RestFeature",
"warning": null
},
{
"error": null,
"id": 6,
"ms": 260.395779,
"name": "SnapFit1",
"rolled_back": false,
"suppressed": false,
"type": "SnapFitFeature",
"warning": null
}
],
"total": {
"area_mm2": 24280.380636378435,
"edges": 82,
"faces": 37,
"mass_g": 29.716687268283682,
"vertices": 56,
"volume_mm3": 23036.19168084006
}
}
@@ -0,0 +1,158 @@
{
"format": "solidcraft/1",
"name": "Untitled",
"units": "mm",
"params": [
{
"name": "wall",
"expr": "2 mm",
"unit": "mm",
"model": false
}
],
"features": [
{
"id": 1,
"name": "Box1",
"suppressed": false,
"param_names": [
"d1",
"d2",
"d3"
],
"type": "box",
"corner": [
0.0,
0.0,
0.0
],
"length": "80",
"width": "50",
"height": "30",
"operation": "new_body"
},
{
"id": 2,
"name": "Shell1",
"suppressed": false,
"param_names": [
"d4"
],
"type": "shell",
"faces": [
[
40.0,
25.0,
30.0
]
],
"thickness": "wall"
},
{
"id": 3,
"name": "Lip1",
"suppressed": false,
"param_names": [
"d5",
"d6"
],
"type": "lip",
"face": [
1.0,
25.0,
30.0
],
"width": "1",
"height": "2"
},
{
"id": 4,
"name": "Boss1",
"suppressed": false,
"param_names": [
"d7",
"d8",
"d9",
"d10"
],
"type": "boss",
"position": [
20.0,
20.0,
2.0
],
"direction": [
0.0,
0.0,
1.0
],
"diameter": "6",
"height": "10",
"hole_diameter": "2.5",
"draft": "1 deg"
},
{
"id": 5,
"name": "Rest1",
"suppressed": false,
"param_names": [
"d11",
"d12",
"d13",
"d14"
],
"type": "rest",
"position": [
60.0,
30.0,
2.0
],
"direction": [
0.0,
0.0,
1.0
],
"width": "8",
"length": "12",
"height": "3",
"thickness": "1"
},
{
"id": 6,
"name": "SnapFit1",
"suppressed": false,
"param_names": [
"d15",
"d16",
"d17",
"d18",
"d19"
],
"type": "snap_fit",
"position": [
40.0,
12.0,
2.0
],
"direction": [
0.0,
0.0,
1.0
],
"hook": [
0.0,
1.0,
0.0
],
"length": "12",
"thickness": "1.5",
"width": "6",
"catch_depth": "1",
"catch_length": "2"
}
],
"next_id": 7,
"plastic": {
"active": "ABS (1.5mm)"
}
}
@@ -0,0 +1,85 @@
{
"bodies": [
{
"area_mm2": 10411.967792188118,
"bbox": {
"max": [
70.0,
50.00000000000002,
32.500000000000014
],
"min": [
0.0,
-4.440892098500626e-14,
-5.329070518200751e-15
]
},
"center_of_mass": [
36.03765771659564,
24.999999999999982,
15.08756759282672
],
"density_g_cm3": 1.29,
"edges": 44,
"face_types": {
"cylinder": 4,
"plane": 10
},
"faces": 22,
"kernel": {
"edges": 44,
"faces": 22,
"shells": 1,
"vertices": 24
},
"mass_g": 15.605746095907175,
"material": "Default",
"name": "Body1",
"sheet_metal": true,
"vertices": 24,
"volume_mm3": 12097.477593726493
}
],
"body_count": 1,
"params": [],
"sketches": [
{
"curves": 3,
"dof": 8,
"id": 1,
"name": "Contour",
"profiles": 0,
"status": "solved"
}
],
"timeline": [
{
"error": null,
"id": 1,
"ms": 0.074984,
"name": "Contour",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 2,
"ms": 37.187197,
"name": "ContourFlange",
"rolled_back": false,
"suppressed": false,
"type": "ContourFlangeFeature",
"warning": null
}
],
"total": {
"area_mm2": 10411.967792188118,
"edges": 44,
"faces": 22,
"mass_g": 15.605746095907175,
"vertices": 24,
"volume_mm3": 12097.477593726493
}
}
@@ -0,0 +1,120 @@
{
"format": "solidcraft/1",
"name": "Untitled",
"units": "mm",
"params": [],
"features": [
{
"id": 1,
"name": "Contour",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "custom",
"plane": {
"origin": [
0.0,
0.0,
0.0
],
"x_dir": [
1.0,
0.0,
0.0
],
"y_dir": [
0.0,
0.0,
-1.0
]
}
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "l1.start",
"pos": [
0.0,
0.0
],
"fixed": false
},
{
"id": "l1.end",
"pos": [
40.0,
0.0
],
"fixed": false
},
{
"id": "l2.end",
"pos": [
40.0,
-30.0
],
"fixed": false
},
{
"id": "l3.end",
"pos": [
70.0,
-30.0
],
"fixed": false
}
],
"curves": [
{
"id": "l1",
"type": "line",
"a": 1,
"b": 2,
"construction": false
},
{
"id": "l2",
"type": "line",
"a": 2,
"b": 3,
"construction": false
},
{
"id": "l3",
"type": "line",
"a": 3,
"b": 4,
"construction": false
}
],
"constraints": [],
"counters": {}
}
},
{
"id": 2,
"name": "ContourFlange",
"suppressed": false,
"param_names": [
"d1"
],
"type": "sheet_contour",
"sketch": 1,
"curves": [
"l1",
"l2",
"l3"
],
"distance": "50"
}
],
"next_id": 3
}
@@ -0,0 +1,144 @@
{
"bodies": [
{
"area_mm2": 4078.7680390666596,
"bbox": {
"max": [
40.0,
30.000000000000014,
12.000000000000002
],
"min": [
0.0,
0.0,
0.0
]
},
"center_of_mass": [
19.25890231218174,
15.000000010054242,
5.04117761026949
],
"density_g_cm3": 1.29,
"edges": 30,
"face_types": {
"cylinder": 1,
"plane": 11
},
"faces": 12,
"kernel": {
"edges": 30,
"faces": 12,
"shells": 1,
"vertices": 20
},
"mass_g": 14.435720327850033,
"material": "Default",
"name": "Body1",
"vertices": 20,
"volume_mm3": 11190.480874302351
}
],
"body_count": 1,
"params": [],
"sketches": [
{
"curves": 4,
"dof": 2,
"id": 1,
"name": "Base",
"profiles": 1,
"status": "solved",
"visible": false
},
{
"curves": 4,
"dof": 4,
"id": 3,
"name": "SlotSketch",
"profiles": 1,
"status": "solved",
"visible": false
}
],
"timeline": [
{
"error": null,
"id": 1,
"ms": 0.09895799999999999,
"name": "Base",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 2,
"ms": 20.768292000000002,
"name": "Block",
"rolled_back": false,
"suppressed": false,
"type": "ExtrudeFeature",
"warning": null
},
{
"error": null,
"id": 3,
"ms": 0.057,
"name": "SlotSketch",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 4,
"ms": 136.28875,
"name": "Slot",
"rolled_back": false,
"suppressed": false,
"type": "ExtrudeFeature",
"warning": null
},
{
"error": null,
"id": 5,
"ms": 153.58625,
"name": "Round",
"rolled_back": false,
"suppressed": false,
"type": "FilletFeature",
"warning": null
},
{
"error": null,
"id": 6,
"ms": 169.174375,
"name": "Bevel",
"rolled_back": false,
"suppressed": false,
"type": "ChamferFeature",
"warning": null
},
{
"error": null,
"id": 7,
"ms": 47.772166,
"name": "Raise",
"rolled_back": false,
"suppressed": false,
"type": "OffsetFacesFeature",
"warning": null
}
],
"total": {
"area_mm2": 4078.7680390666596,
"edges": 30,
"faces": 12,
"mass_g": 14.435720327850033,
"vertices": 20,
"volume_mm3": 11190.480874302351
}
}
@@ -0,0 +1,373 @@
{
"format": "solidcraft/13",
"name": "Untitled",
"units": "mm",
"params": [],
"features": [
{
"id": 1,
"name": "Base",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "origin",
"name": "XY"
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "p1",
"pos": [
0.0,
0.0
],
"fixed": false
},
{
"id": "p2",
"pos": [
40.0,
0.0
],
"fixed": false
},
{
"id": "p3",
"pos": [
40.0,
30.0
],
"fixed": false
},
{
"id": "p4",
"pos": [
0.0,
30.0
],
"fixed": false
}
],
"curves": [
{
"id": "l1",
"type": "line",
"a": 1,
"b": 2,
"construction": false
},
{
"id": "l2",
"type": "line",
"a": 2,
"b": 3,
"construction": false
},
{
"id": "l3",
"type": "line",
"a": 3,
"b": 4,
"construction": false
},
{
"id": "l4",
"type": "line",
"a": 4,
"b": 1,
"construction": false
}
],
"constraints": [
{
"id": "k1",
"type": "horizontal",
"l": 0
},
{
"id": "k2",
"type": "horizontal",
"l": 2
},
{
"id": "k3",
"type": "vertical",
"l": 1
},
{
"id": "k4",
"type": "vertical",
"l": 3
},
{
"id": "k5",
"type": "coincident",
"p": 0,
"q": 1
}
],
"counters": {
"k": 5,
"l": 4,
"p": 4
}
}
},
{
"id": 2,
"name": "Block",
"suppressed": false,
"param_names": [
"d1"
],
"type": "extrude",
"sketch": 1,
"profiles": {
"type": "all"
},
"extent": {
"distance": "10",
"direction": "positive"
},
"operation": "new_body"
},
{
"id": 3,
"name": "SlotSketch",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "origin",
"name": "XY"
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "p1",
"pos": [
15.0,
-5.0
],
"fixed": false
},
{
"id": "p2",
"pos": [
25.0,
-5.0
],
"fixed": false
},
{
"id": "p3",
"pos": [
25.0,
35.0
],
"fixed": false
},
{
"id": "p4",
"pos": [
15.0,
35.0
],
"fixed": false
}
],
"curves": [
{
"id": "l1",
"type": "line",
"a": 1,
"b": 2,
"construction": false
},
{
"id": "l2",
"type": "line",
"a": 2,
"b": 3,
"construction": false
},
{
"id": "l3",
"type": "line",
"a": 3,
"b": 4,
"construction": false
},
{
"id": "l4",
"type": "line",
"a": 4,
"b": 1,
"construction": false
}
],
"constraints": [
{
"id": "k1",
"type": "horizontal",
"l": 0
},
{
"id": "k2",
"type": "horizontal",
"l": 2
},
{
"id": "k3",
"type": "vertical",
"l": 1
},
{
"id": "k4",
"type": "vertical",
"l": 3
}
],
"counters": {
"k": 4,
"l": 4,
"p": 4
}
}
},
{
"id": 4,
"name": "Slot",
"suppressed": false,
"param_names": [
"d2",
"d3"
],
"type": "extrude",
"sketch": 3,
"profiles": {
"type": "all"
},
"extent": {
"distance": "10",
"direction": "positive",
"start_offset": "5"
},
"operation": "cut"
},
{
"id": 5,
"name": "Round",
"suppressed": false,
"param_names": [
"d4"
],
"edge_refs": [
{
"dir": [
0.0,
-1.0,
0.0
],
"min": [
0.0,
0.0,
0.0
],
"max": [
40.0,
30.0,
10.0
]
}
],
"edge_names": [
"F2:side:l2|F2:top#2"
],
"type": "fillet",
"edges": [
[
40.0,
15.0,
10.0
]
],
"radius": "2"
},
{
"id": 6,
"name": "Bevel",
"suppressed": false,
"param_names": [
"d5"
],
"edge_refs": [
{
"dir": [
0.0,
1.0,
0.0
],
"min": [
0.0,
0.0,
0.0
],
"max": [
40.0,
30.000000000000007,
10.0
]
}
],
"edge_names": [
"F2:side:l4|F2:top#1"
],
"type": "chamfer",
"edges": [
[
0.0,
15.0,
10.0
]
],
"distance": "1.5"
},
{
"id": 7,
"name": "Raise",
"suppressed": false,
"param_names": [
"d6"
],
"face_names": [
"F2:top#1"
],
"type": "offset_face",
"faces": [
[
7.0,
15.0,
10.0
]
],
"distance": "2"
}
],
"next_id": 8
}
@@ -0,0 +1,15 @@
{"commands": [
{"command": "solid.box", "params": {"length": 10, "width": 10, "height": 10, "body_name": "Base"}},
{"command": "component.create", "params": {"name": "Arm"}},
{"command": "solid.box", "params": {"corner": [20, 0, 0], "length": 10, "width": 4, "height": 4, "body_name": "ArmBody"}},
{"command": "solid.fillet", "params": {"edges": [[25, 4, 4]], "radius": 1}},
{"command": "component.activate", "params": {"component": 0}},
{"command": "occurrence.move", "params": {"occurrence": 3, "translate": [0, 50, 0]}},
{"command": "occurrence.copy", "params": {"component": "Arm", "translate": [0, 20, 0]}},
{"command": "component.paste_new", "params": {"component": "Arm", "translate": [0, -30, 0]}},
{"command": "occurrence.ground", "params": {"occurrence": 3}},
{"command": "sketch.create", "params": {"plane": "XY", "name": "S1"}},
{"command": "sketch.circle.center", "params": {"center": [5, 5], "radius": 2}},
{"command": "sketch.finish", "params": {}},
{"command": "solid.extrude", "params": {"distance": 10, "operation": "cut"}}
]}
@@ -0,0 +1,14 @@
{"commands": [
{"command": "parameters.change", "params": {"name": "open_angle", "expression": "90 deg"}},
{"command": "component.create", "params": {"name": "LeafA"}},
{"command": "solid.box", "params": {"length": 40, "width": 30, "height": 3, "corner": [0, 0, 0]}},
{"command": "solid.cylinder", "params": {"base": [0, 33, 4], "axis": [1, 0, 0], "radius": 4, "height": 40, "operation": "new"}},
{"command": "component.activate", "params": {"component": "root"}},
{"command": "component.create", "params": {"name": "LeafB"}},
{"command": "solid.box", "params": {"length": 40, "width": 30, "height": 3, "corner": [0, 0, 0]}},
{"command": "solid.cylinder", "params": {"base": [0, 33, 4], "axis": [1, 0, 0], "radius": 4, "height": 40, "operation": "new"}},
{"command": "component.activate", "params": {"component": "root"}},
{"command": "occurrence.ground", "params": {"occurrence": 2, "grounded": true}},
{"command": "joint.create", "params": {"type": "revolute", "a": {"occurrence": "LeafA", "circle": [1, 37, 4]}, "b": {"occurrence": "LeafB", "circle": [1, 37, 4]}, "name": "Hinge"}},
{"command": "joint.drive", "params": {"joint": "Hinge", "value": "open_angle"}}
]}
@@ -0,0 +1,12 @@
{"commands": [
{"command": "parameters.change", "params": {"name": "width", "expression": "40 mm"}},
{"command": "sketch.create", "params": {"plane": "XY"}},
{"command": "sketch.rectangle.two_point", "params": {"p0": [0, 0], "p1": [40, 30]}},
{"command": "sketch.finish", "params": {}},
{"command": "solid.extrude", "params": {"distance": "width / 2"}},
{"command": "solid.fillet", "params": {"edges": [[0, 0, 10]], "radius": 3}},
{"command": "sketch.create", "params": {"plane": "XY"}},
{"command": "sketch.circle.center", "params": {"center": [20, 15], "radius": 5}},
{"command": "sketch.finish", "params": {}},
{"command": "solid.extrude", "params": {"distance": 20, "operation": "cut"}}
]}
@@ -0,0 +1,11 @@
{"commands": [
{"command": "sketch.create", "params": {"plane": "XZ"}},
{"command": "sketch.line", "params": {"points": [[10, 0], [15, 0], [15, 5], [10, 5]], "closed": true}},
{"command": "sketch.finish", "params": {}},
{"command": "solid.revolve", "params": {"axis": "y"}},
{"command": "solid.box", "params": {"length": 10, "width": 10, "height": 10, "corner": [30, 0, 0]}},
{"command": "solid.cylinder", "params": {"diameter": 4, "height": 20, "base": [35, 5, -5]}},
{"command": "solid.combine", "params": {"target": "Body2", "tools": ["Body3"], "operation": "cut"}},
{"command": "solid.chamfer", "params": {"edges": [[30, 5, 10]], "distance": 1}},
{"command": "timeline.edit", "params": {"feature": "Revolve1", "set": {"angle": "180 deg"}}}
]}
@@ -0,0 +1,197 @@
{
"commands": [
{
"command": "sketch.create",
"params": {
"name": "Plate_sketch",
"plane": "XY"
}
},
{
"command": "sketch.line",
"params": {
"construction": false,
"ids": [
"l1"
],
"points": [
[
0,
0
],
[
120,
0
]
]
}
},
{
"command": "sketch.line",
"params": {
"construction": false,
"ids": [
"l2"
],
"points": [
"l1.end",
[
120,
60
]
]
}
},
{
"command": "sketch.line",
"params": {
"construction": false,
"ids": [
"l3"
],
"points": [
"l2.end",
[
0,
60
]
]
}
},
{
"command": "sketch.line",
"params": {
"construction": false,
"ids": [
"l4"
],
"points": [
"l3.end",
"l1.start"
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"body_names": [
"Plate"
],
"direction": "positive",
"distance": 5,
"name": "Plate",
"operation": "new",
"profiles": [
{
"area_mm2": 7200.0,
"centroid_sketch": [
60.0,
30.0
],
"loops": [
{
"curves": [
"l1",
"l2",
"l3",
"l4"
],
"outer": true
}
],
"sketch": "Plate_sketch"
}
],
"sketch": "Plate_sketch"
}
},
{
"command": "sketch.create",
"params": {
"name": "PathSketch",
"plane": "XY"
}
},
{
"command": "sketch.arc.three_point",
"params": {
"end": [
20,
15
],
"id": "a1",
"start": [
100,
15
],
"through": [
60,
45
]
}
},
{
"command": "sketch.circle.center",
"params": {
"center": "a1.start",
"construction": false,
"id": "c1",
"radius": 3
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"body_names": [
"Plate"
],
"direction": "positive",
"name": "Hole1",
"operation": "cut",
"profiles": [
{
"area_mm2": 28.274334,
"centroid_sketch": [
100.0,
15.0
],
"loops": [
{
"curves": [
"c1"
],
"outer": true
}
],
"sketch": "PathSketch"
}
],
"sketch": "PathSketch",
"through_all": true
}
},
{
"command": "solid.pattern.path",
"params": {
"count": 7,
"features": [
"Hole1"
],
"name": "PathPattern1",
"path": [
"a1"
],
"path_sketch": "PathSketch",
"spacing": 17.875031
}
}
]
}
@@ -0,0 +1,10 @@
{"commands": [
{"command": "parameters.change", "params": {"name": "wall", "expression": "2 mm"}},
{"command": "solid.box", "params": {"length": 80, "width": 50, "height": 30}},
{"command": "solid.shell", "params": {"faces": [[40, 25, 30]], "thickness": "wall"}},
{"command": "plastic.lip", "params": {"face": [1, 25, 30], "width": 1, "height": 2}},
{"command": "plastic.boss", "params": {"position": [20, 20, 2], "diameter": 6, "height": 10, "hole_diameter": 2.5, "draft": "1 deg"}},
{"command": "plastic.rest", "params": {"position": [60, 30, 2], "width": 8, "length": 12, "height": 3, "thickness": 1}},
{"command": "plastic.snap_fit", "params": {"position": [40, 12, 2], "direction": [0, 0, 1], "hook": [0, 1, 0], "length": 12, "thickness": 1.5, "width": 6, "catch_depth": 1, "catch_length": 2}},
{"command": "plastic.manage_rules", "params": {"name": "ABS (1.5mm)", "active": true}}
]}
@@ -0,0 +1,96 @@
{
"commands": [
{
"command": "sketch.create",
"params": {
"name": "Contour",
"plane": {
"origin": [
0.0,
0.0,
0.0
],
"x_dir": [
1.0,
0.0,
0.0
],
"y_dir": [
0.0,
0.0,
-1.0
]
}
}
},
{
"command": "sketch.line",
"params": {
"construction": false,
"ids": [
"l1"
],
"points": [
[
0.0,
0.0
],
[
40.0,
0.0
]
]
}
},
{
"command": "sketch.line",
"params": {
"construction": false,
"ids": [
"l2"
],
"points": [
"l1.end",
[
40.0,
-30.0
]
]
}
},
{
"command": "sketch.line",
"params": {
"construction": false,
"ids": [
"l3"
],
"points": [
"l2.end",
[
70.0,
-30.0
]
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "sheet.flange",
"params": {
"curves": [
"l1",
"l2",
"l3"
],
"distance": 50,
"name": "ContourFlange",
"sketch": "Contour",
"type": "contour"
}
}
]
}
@@ -0,0 +1,111 @@
{
"commands": [
{
"command": "sketch.create",
"params": {
"plane": "XY",
"name": "Base"
}
},
{
"command": "sketch.rectangle.two_point",
"params": {
"p0": [
0,
0
],
"p1": [
40,
30
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"distance": 10,
"name": "Block"
}
},
{
"command": "sketch.create",
"params": {
"plane": "XY",
"name": "SlotSketch"
}
},
{
"command": "sketch.rectangle.two_point",
"params": {
"p0": [
15,
-5
],
"p1": [
25,
35
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"sketch": "SlotSketch",
"distance": 10,
"start_offset": 5,
"operation": "cut",
"name": "Slot"
}
},
{
"command": "solid.fillet",
"params": {
"edges": [
[
40,
15,
10
]
],
"radius": 2,
"name": "Round"
}
},
{
"command": "solid.chamfer",
"params": {
"edges": [
[
0,
15,
10
]
],
"distance": 1.5,
"name": "Bevel"
}
},
{
"command": "solid.offset_face",
"params": {
"faces": [
[
7,
15,
10
]
],
"distance": 2,
"name": "Raise"
}
}
]
}
@@ -0,0 +1,107 @@
{
"commands": [
{
"command": "sketch.create",
"params": {
"plane": "XY",
"name": "Base"
}
},
{
"command": "sketch.rectangle.two_point",
"params": {
"p0": [
0,
0
],
"p1": [
40,
30
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"distance": 10,
"name": "Block"
}
},
{
"command": "sketch.create",
"params": {
"plane": "XY",
"name": "SlotSketch"
}
},
{
"command": "sketch.rectangle.two_point",
"params": {
"p0": [
-5,
12
],
"p1": [
45,
18
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"sketch": "SlotSketch",
"distance": 10,
"operation": "cut",
"name": "Slot"
}
},
{
"command": "solid.fillet",
"params": {
"edges": [
[
20,
0,
10
]
],
"radius": 2,
"body": "Body1 (1)",
"name": "NearRound"
}
},
{
"command": "solid.chamfer",
"params": {
"edges": [
[
20,
30,
10
]
],
"distance": 1.5,
"body": "Body1",
"name": "FarBevel"
}
},
{
"command": "appearance.assign",
"params": {
"bodies": [
"Body1 (1)"
],
"color": "#cc3333"
}
}
]
}
@@ -0,0 +1,171 @@
{
"bodies": [
{
"area_mm2": 1962.6028137423857,
"bbox": {
"max": [
40.0,
30.0,
10.0
],
"min": [
0.0,
18.0,
0.0
]
},
"center_of_mass": [
20.0,
23.94794952681388,
4.957413249211356
],
"density_g_cm3": 1.29,
"edges": 15,
"face_types": {
"plane": 7
},
"faces": 7,
"kernel": {
"edges": 15,
"faces": 7,
"shells": 1,
"vertices": 10
},
"mass_g": 6.13395,
"material": "Default",
"name": "Body1",
"vertices": 10,
"volume_mm3": 4755.0
},
{
"area_mm2": 1963.9401350108699,
"bbox": {
"max": [
40.00000000000002,
12.000000000000002,
10.0
],
"min": [
-8.881784197001252e-15,
0.0,
0.0
]
},
"center_of_mass": [
20.00000000000079,
6.040035701025577,
4.967173993940324
],
"density_g_cm3": 1.29,
"edges": 15,
"face_types": {
"cylinder": 1,
"plane": 6
},
"faces": 7,
"kernel": {
"edges": 15,
"faces": 7,
"shells": 1,
"vertices": 10
},
"mass_g": 6.147677129601969,
"material": "Default",
"name": "Body1 (1)",
"vertices": 10,
"volume_mm3": 4765.64118573796
}
],
"body_count": 2,
"params": [],
"sketches": [
{
"curves": 4,
"dof": 2,
"id": 1,
"name": "Base",
"profiles": 1,
"status": "solved",
"visible": false
},
{
"curves": 4,
"dof": 4,
"id": 3,
"name": "SlotSketch",
"profiles": 1,
"status": "solved",
"visible": false
}
],
"timeline": [
{
"error": null,
"id": 1,
"ms": 0.07066700000000001,
"name": "Base",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 2,
"ms": 0.7462909999999999,
"name": "Block",
"rolled_back": false,
"suppressed": false,
"type": "ExtrudeFeature",
"warning": null
},
{
"error": null,
"id": 3,
"ms": 0.035125,
"name": "SlotSketch",
"rolled_back": false,
"suppressed": false,
"type": "Sketch",
"warning": null
},
{
"error": null,
"id": 4,
"ms": 9.647208000000001,
"name": "Slot",
"rolled_back": false,
"suppressed": false,
"type": "ExtrudeFeature",
"warning": null
},
{
"error": null,
"id": 5,
"ms": 3.443708,
"name": "NearRound",
"rolled_back": false,
"suppressed": false,
"type": "FilletFeature",
"warning": null
},
{
"error": null,
"id": 6,
"ms": 3.947834,
"name": "FarBevel",
"rolled_back": false,
"suppressed": false,
"type": "ChamferFeature",
"warning": null
}
],
"total": {
"area_mm2": 3926.5429487532556,
"edges": 30,
"faces": 14,
"mass_g": 12.281627129601969,
"vertices": 20,
"volume_mm3": 9520.64118573796
}
}
@@ -0,0 +1,366 @@
{
"format": "solidcraft/13",
"name": "Untitled",
"units": "mm",
"params": [],
"features": [
{
"id": 1,
"name": "Base",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "origin",
"name": "XY"
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "p1",
"pos": [
0.0,
0.0
],
"fixed": false
},
{
"id": "p2",
"pos": [
40.0,
0.0
],
"fixed": false
},
{
"id": "p3",
"pos": [
40.0,
30.0
],
"fixed": false
},
{
"id": "p4",
"pos": [
0.0,
30.0
],
"fixed": false
}
],
"curves": [
{
"id": "l1",
"type": "line",
"a": 1,
"b": 2,
"construction": false
},
{
"id": "l2",
"type": "line",
"a": 2,
"b": 3,
"construction": false
},
{
"id": "l3",
"type": "line",
"a": 3,
"b": 4,
"construction": false
},
{
"id": "l4",
"type": "line",
"a": 4,
"b": 1,
"construction": false
}
],
"constraints": [
{
"id": "k1",
"type": "horizontal",
"l": 0
},
{
"id": "k2",
"type": "horizontal",
"l": 2
},
{
"id": "k3",
"type": "vertical",
"l": 1
},
{
"id": "k4",
"type": "vertical",
"l": 3
},
{
"id": "k5",
"type": "coincident",
"p": 0,
"q": 1
}
],
"counters": {
"k": 5,
"l": 4,
"p": 4
}
}
},
{
"id": 2,
"name": "Block",
"suppressed": false,
"param_names": [
"d1"
],
"type": "extrude",
"sketch": 1,
"profiles": {
"type": "all"
},
"extent": {
"distance": "10",
"direction": "positive"
},
"operation": "new_body"
},
{
"id": 3,
"name": "SlotSketch",
"suppressed": false,
"type": "sketch",
"plane": {
"type": "origin",
"name": "XY"
},
"sketch": {
"points": [
{
"id": "origin",
"pos": [
0.0,
0.0
],
"fixed": true
},
{
"id": "p1",
"pos": [
-5.0,
12.0
],
"fixed": false
},
{
"id": "p2",
"pos": [
45.0,
12.0
],
"fixed": false
},
{
"id": "p3",
"pos": [
45.0,
18.0
],
"fixed": false
},
{
"id": "p4",
"pos": [
-5.0,
18.0
],
"fixed": false
}
],
"curves": [
{
"id": "l1",
"type": "line",
"a": 1,
"b": 2,
"construction": false
},
{
"id": "l2",
"type": "line",
"a": 2,
"b": 3,
"construction": false
},
{
"id": "l3",
"type": "line",
"a": 3,
"b": 4,
"construction": false
},
{
"id": "l4",
"type": "line",
"a": 4,
"b": 1,
"construction": false
}
],
"constraints": [
{
"id": "k1",
"type": "horizontal",
"l": 0
},
{
"id": "k2",
"type": "horizontal",
"l": 2
},
{
"id": "k3",
"type": "vertical",
"l": 1
},
{
"id": "k4",
"type": "vertical",
"l": 3
}
],
"counters": {
"k": 4,
"l": 4,
"p": 4
}
}
},
{
"id": 4,
"name": "Slot",
"suppressed": false,
"param_names": [
"d2"
],
"type": "extrude",
"sketch": 3,
"profiles": {
"type": "all"
},
"extent": {
"distance": "10",
"direction": "positive"
},
"operation": "cut"
},
{
"id": 5,
"name": "NearRound",
"suppressed": false,
"param_names": [
"d3"
],
"edge_refs": [
{
"dir": [
-1.0,
0.0,
0.0
],
"min": [
0.0,
0.0,
0.0
],
"max": [
40.0,
12.000000000000002,
10.0
]
}
],
"edge_names": [
"F2:side:l1|F2:top"
],
"type": "fillet",
"edges": [
[
20.0,
0.0,
10.0
]
],
"radius": "2",
"body": "Body1 (1)"
},
{
"id": 6,
"name": "FarBevel",
"suppressed": false,
"param_names": [
"d4"
],
"edge_refs": [
{
"dir": [
1.0,
0.0,
0.0
],
"min": [
0.0,
18.0,
0.0
],
"max": [
40.0,
30.0,
10.0
]
}
],
"edge_names": [
"F2:side:l3|F2:top"
],
"type": "chamfer",
"edges": [
[
20.0,
30.0,
10.0
]
],
"distance": "1.5",
"body": "Body1"
}
],
"next_id": 7,
"appearances": {
"bodies": {
"Body1 (1)": {
"name": "Custom",
"color": [
204,
51,
51
],
"opacity": 1.0
}
}
}
}
+289
View File
@@ -0,0 +1,289 @@
//! Designs saved by older SolidCraft builds (tests/corpus, see its README) open and evaluate as
//! they did when they were saved; damaged and hostile design files never panic.
use std::path::{Path, PathBuf};
use serde_json::{Value, json};
use solidcraft_engine::Session;
fn corpus() -> Vec<PathBuf> {
let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/corpus");
let mut v: Vec<PathBuf> =
std::fs::read_dir(&dir).unwrap().flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|x| x == "solidcraft")).collect();
v.sort();
assert!(v.len() >= 7, "corpus files in {}", dir.display());
v
}
fn open(path: &Path) -> Session {
let mut s = Session::default();
s.execute("doc.open", &json!({"path": path.to_string_lossy()})).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
s
}
/// Differences that are deliberate behaviour changes made before the file format had versions
/// (no migration can tell those files apart): (file, check, why).
const KNOWN: [(&str, &str, &str); 2] = [
(
"m0-revolve-primitives",
"Body1 bbox",
"partial revolves turn toward the sketch normal since ac43365 (as Fusion's do); M0 turned them the other way",
),
("components-arm", "body_count", "Measure counted only the root component's bodies then; it measures every placed body now"),
];
fn known(file: &str, check: &str) -> bool {
KNOWN.iter().any(|(f, c, _)| *f == file && *c == check)
}
/// Volumes and areas then came from coarser tessellation (and curved booleans and fillets have
/// become exact since): the same part within this relative tolerance (the oracle's).
const REL: f64 = 1e-3;
fn close(a: f64, b: f64, rel: f64) -> bool {
(a - b).abs() <= rel * b.abs().max(1.0)
}
#[test]
fn old_designs_open_and_evaluate_as_saved() {
let mut problems = Vec::new();
for p in corpus() {
let name = p.file_stem().unwrap_or_default().to_string_lossy().to_string();
let want: Value = serde_json::from_slice(&std::fs::read(p.with_extension("expected.json")).unwrap()).unwrap();
let mut s = open(&p);
for r in &s.model.results {
if let Some(e) = &r.error {
problems.push(format!("{name}: feature {}: {e}", r.id));
}
}
assert_eq!(s.doc.format, solidcraft_engine::doc::format::format_string(solidcraft_engine::doc::format::FORMAT), "{name}: upgraded");
let got = s.execute("inspect.measure", &json!({})).unwrap();
if got["body_count"] != want["body_count"] && !known(&name, "body_count") {
problems.push(format!("{name}: {} bodies, saved with {}", got["body_count"], want["body_count"]));
}
for w in want["bodies"].as_array().into_iter().flatten() {
let bname = w["name"].as_str().unwrap_or_default();
let Some(g) = got["bodies"].as_array().into_iter().flatten().find(|g| g["name"] == w["name"]) else {
problems.push(format!("{name}: body {bname} missing"));
continue;
};
for k in ["volume_mm3", "area_mm2"] {
let (a, b) = (g[k].as_f64().unwrap_or(f64::NAN), w[k].as_f64().unwrap_or(f64::NAN));
if !close(a, b, REL) {
problems.push(format!("{name}: {bname} {k} {a} (saved {b})"));
}
}
if known(&name, &format!("{bname} bbox")) {
continue;
}
for (end, i) in [("min", 0), ("min", 1), ("min", 2), ("max", 0), ("max", 1), ("max", 2)] {
let (a, b) = (g["bbox"][end][i].as_f64().unwrap_or(f64::NAN), w["bbox"][end][i].as_f64().unwrap_or(f64::NAN));
if (a - b).abs() > 1e-3 * b.abs().max(1.0) {
problems.push(format!("{name}: {bname} bbox {end}[{i}] {a} (saved {b})"));
}
}
}
// Saved again, it reads back the same.
let again = solidcraft_engine::doc::Document::from_json(&s.doc.to_json()).unwrap();
assert_eq!(again, *s.doc, "{name}: round trip");
}
assert!(problems.is_empty(), "{}", problems.join("\n"));
}
/// Names saved before format 14 were worked out from geometry, pieces of a split face numbered by
/// where their centres lay (`F2:top#2`). They keep naming the faces they named: marked as such,
/// they are found as the build that saved them found them, without new notes.
#[test]
fn names_saved_before_exact_history_find_the_faces_they_named() {
let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/corpus/naming-split-pieces.solidcraft");
let s = open(&path);
let feature = |name: &str| s.doc.features.iter().find(|f| f.name == name).unwrap_or_else(|| panic!("{name}"));
assert_eq!(feature("Round").edge_names, vec!["?F2:side:l2|F2:top#2".to_string()]);
assert_eq!(feature("Bevel").edge_names, vec!["?F2:side:l4|F2:top#1".to_string()]);
assert_eq!(feature("Raise").face_names, vec!["?F2:top#1".to_string()]);
for r in &s.model.results {
assert!(r.error.is_none() && r.warning.is_none(), "{}: {:?} {:?}", r.name, r.error, r.warning);
}
// The raised piece is the left one, as saved (the stored point is on it).
let state = s.model.state();
let solid = |p: [f64; 3]| state.bodies.iter().any(|b| b.body.contains(solidcraft_engine::geom::Vec3::new(p[0], p[1], p[2])));
assert!(solid([7.0, 15.0, 11.0]) && !solid([32.0, 15.0, 11.0]));
}
/// Body names saved before format 14 name the pieces of a split body in the kernel's shell order.
/// The features after the split that refer to a piece by its body name still find that piece:
/// the far one stays `Body1` (chamfered), the near one `Body1 (1)` (filleted, coloured).
#[test]
fn body_names_saved_before_exact_history_keep_their_pieces() {
let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/corpus/split-body-pieces.solidcraft");
let s = open(&path);
assert!(s.doc.features.iter().all(|f| f.shell_piece_order), "every saved feature keeps the shell order");
for r in &s.model.results {
assert!(r.error.is_none() && r.warning.is_none(), "{}: {:?} {:?}", r.name, r.error, r.warning);
}
let state = s.model.state();
let piece = |name: &str| state.bodies.iter().find(|b| b.name == name).unwrap_or_else(|| panic!("{name}"));
let solid = |name: &str, p: [f64; 3]| piece(name).body.contains(solidcraft_engine::geom::Vec3::new(p[0], p[1], p[2]));
assert!(solid("Body1", [20.0, 24.0, 5.0]) && solid("Body1 (1)", [20.0, 6.0, 5.0]));
assert!(s.doc.appearances.bodies.contains_key("Body1 (1)"));
}
/// A small deterministic generator (xorshift).
struct Rng(u64);
impl Rng {
fn next(&mut self) -> u64 {
self.0 ^= self.0 << 13;
self.0 ^= self.0 >> 7;
self.0 ^= self.0 << 17;
self.0
}
fn below(&mut self, n: usize) -> usize {
(self.next() % n.max(1) as u64) as usize
}
}
const HOSTILE: [&str; 14] =
["0", "-1", "1e308", "-1e308", "1e9", "4294967297", "\"\"", "\"1/0\"", "\"((((1\"", "null", "true", "[]", "{}", "\"nope\""];
/// Every JSON value in a document, as a path of keys and indices.
fn paths(v: &Value, at: &mut Vec<Value>, out: &mut Vec<Vec<Value>>) {
out.push(at.clone());
match v {
Value::Object(m) => {
for (k, x) in m {
at.push(json!(k));
paths(x, at, out);
at.pop();
}
}
Value::Array(a) => {
for (i, x) in a.iter().enumerate() {
at.push(json!(i));
paths(x, at, out);
at.pop();
}
}
_ => {}
}
}
fn at_mut<'a>(v: &'a mut Value, path: &[Value]) -> Option<&'a mut Value> {
let mut cur = v;
for k in path {
cur = match k {
Value::String(s) => cur.get_mut(s.as_str())?,
Value::Number(n) => cur.get_mut(n.as_u64()? as usize)?,
_ => return None,
};
}
Some(cur)
}
/// Open a file's bytes as File → Open does and evaluate them; any panic is a failure.
fn try_bytes(bytes: &[u8]) {
if let Ok(doc) = solidcraft_engine::io::read_design(bytes) {
let mut s = Session::new(doc);
let _ = s.execute("inspect.measure", &json!({}));
let _ = s.execute("document.inspect", &json!({}));
}
}
/// Hostile shapes that no mutation of a saved file produces: plane references that close a
/// cycle, which resolve through the model and back into the document.
fn generated() -> Vec<(String, Vec<u8>)> {
let to = |name: &str| json!({"type": "plane", "plane": {"type": "construction", "name": name}});
let plane = |id: u64, name: &str, side: Value| {
json!({"id": id, "name": name, "suppressed": false, "type": "construction_plane",
"plane": {"type": "midplane", "a": side, "b": {"type": "plane", "plane": {"type": "origin", "name": "XZ"}}}})
};
let design = |name: &str, features: Value| {
json!({"format": "solidcraft/11", "name": name, "units": "mm", "params": [], "next_id": 9, "features": features}).to_string().into_bytes()
};
// A sketch past the caps interactive editing enforces: solving it would size dense matrices
// by the point count and abort on the allocation.
let point = json!({"id": "p1", "pos": [0.0, 0.0], "fixed": false});
let oversized = json!([{"id": 1, "name": "Sketch1", "suppressed": false, "type": "sketch",
"plane": {"type": "origin", "name": "XY"},
"sketch": {"points": vec![point; 200_000], "curves": [], "constraints": []}}]);
vec![
("construction plane is its own side".into(), design("selfplane", json!([plane(1, "P1", to("P1"))]))),
("two construction planes refer to each other".into(), design("twoplanes", json!([plane(1, "P1", to("P2")), plane(2, "P2", to("P1"))]))),
("sketch with 200,000 points".into(), design("bigsketch", oversized)),
]
}
#[test]
fn damaged_and_hostile_design_files_never_panic() {
let mut rng = Rng(0x5eed_cafe_f00d_d00d);
// The cases come from one seeded sequence; trying them is independent, so threads share it.
let mut all_cases: Vec<(String, String, Vec<u8>)> = Vec::new();
for p in corpus() {
let name = p.file_name().unwrap_or_default().to_string_lossy().to_string();
let bytes = std::fs::read(&p).unwrap();
let doc: Value = serde_json::from_slice(&bytes).unwrap();
let mut all = Vec::new();
paths(&doc, &mut Vec::new(), &mut all);
let mut cases: Vec<(String, Vec<u8>)> = Vec::new();
// Truncated and bit-flipped files.
for _ in 0..8 {
let cut = rng.below(bytes.len());
cases.push((format!("truncated at {cut}"), bytes[..cut].to_vec()));
let mut b = bytes.clone();
let i = rng.below(b.len());
b[i] ^= 1 << rng.below(8);
cases.push((format!("bit flip at {i}"), b));
}
// Values replaced by hostile ones, and keys removed.
for _ in 0..25 {
let path = &all[rng.below(all.len())];
let mut v = doc.clone();
let h = HOSTILE[rng.below(HOSTILE.len())];
if let Some(slot) = at_mut(&mut v, path) {
*slot = serde_json::from_str(h).unwrap();
}
cases.push((format!("{path:?} = {h}"), v.to_string().into_bytes()));
let mut v = doc.clone();
if let Some((last, parent)) = path.split_last()
&& let (Some(Value::Object(m)), Value::String(k)) = (at_mut(&mut v, parent), last)
{
m.remove(k);
}
cases.push((format!("{path:?} removed"), v.to_string().into_bytes()));
}
// Features repeated many times; deep nesting; not JSON at all.
let mut v = doc.clone();
if let Some(Value::Array(fs)) = v.get_mut("features") {
let copy = fs.clone();
for _ in 0..2 {
fs.extend(copy.iter().cloned());
}
}
cases.push(("features repeated".into(), v.to_string().into_bytes()));
cases.push(("deep nesting".into(), format!("{}{}", "[".repeat(100_000), "]".repeat(100_000)).into_bytes()));
cases.push(("binary".into(), (0..4096u32).map(|i| (i.wrapping_mul(2_654_435_761) >> 24) as u8).collect()));
all_cases.extend(cases.into_iter().map(|(what, b)| (name.clone(), what, b)));
}
all_cases.extend(generated().into_iter().map(|(what, b)| ("generated".to_string(), what, b)));
let next = std::sync::atomic::AtomicUsize::new(0);
let threads = std::thread::available_parallelism().map_or(4, |n| n.get());
let failures: Vec<String> = std::thread::scope(|scope| {
let workers: Vec<_> = (0..threads)
.map(|_| {
scope.spawn(|| {
let mut failures = Vec::new();
while let Some((name, what, b)) = all_cases.get(next.fetch_add(1, std::sync::atomic::Ordering::Relaxed)) {
if std::env::var_os("CORPUS_TRACE").is_some() {
eprintln!("{name}: {what}");
}
if std::panic::catch_unwind(|| try_bytes(b)).is_err() {
failures.push(format!("{name}: {what}"));
}
}
failures
})
})
.collect();
workers.into_iter().flat_map(|w| w.join().unwrap()).collect()
});
assert!(failures.is_empty(), "panics:\n{}", failures.join("\n"));
}
+31
View File
@@ -0,0 +1,31 @@
//! Seed ranges must not crash or wrap, including at the last representable seed.
use std::process::Command;
#[test]
fn overflowing_seed_range_is_an_error_not_a_panic() {
let output =
Command::new(env!("CARGO_BIN_EXE_solidcraft-cli")).args(["fuzz", "--from", "18446744073709551615", "--count", "2"]).output().unwrap();
assert_eq!(output.status.code(), Some(1));
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(stderr.contains("seed range exceeds u64::MAX"), "{stderr}");
assert!(!stderr.contains("panicked"), "{stderr}");
}
#[test]
fn empty_seed_range_at_maximum_is_valid() {
let output =
Command::new(env!("CARGO_BIN_EXE_solidcraft-cli")).args(["fuzz", "--from", "18446744073709551615", "--count", "0"]).output().unwrap();
assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr));
assert!(String::from_utf8_lossy(&output.stdout).starts_with("0 seeds, 0 design steps,"));
}
#[test]
fn maximum_seed_runs_once_without_wrapping() {
let output = Command::new(env!("CARGO_BIN_EXE_solidcraft-cli"))
.args(["fuzz", "--from", "18446744073709551615", "--count", "1", "--steps", "0", "--timeout", "0"])
.output()
.unwrap();
assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr));
assert!(String::from_utf8_lossy(&output.stdout).starts_with("1 seeds,"));
}
@@ -0,0 +1,55 @@
//! Kill the process while it saves: the design file is always the old version or the new one,
//! whole, and opens.
use std::process::Command;
use std::time::Duration;
fn round_of(path: &std::path::Path) -> Option<String> {
let bytes = std::fs::read(path).ok()?;
let doc = solidcraft_engine::io::read_design(&bytes).ok()?;
doc.params.iter().find(|p| p.name == "save_round").map(|p| p.expr.clone())
}
#[test]
fn killed_mid_save_the_old_file_survives() {
let exe = env!("CARGO_BIN_EXE_solidcraft-cli");
let dir = std::env::temp_dir().join(format!("solidcraft-kill-mid-save-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let path = dir.join("design.solidcraft");
let ok = Command::new(exe).args(["save-stress", &path.to_string_lossy(), "1"]).status().unwrap();
assert!(ok.success());
assert_eq!(round_of(&path).as_deref(), Some("0"));
let mut kills = 0;
let mut seen = std::collections::BTreeSet::new();
let modified = || std::fs::metadata(&path).and_then(|m| m.modified()).ok();
for i in 0..25u64 {
let before = modified();
let mut child = Command::new(exe).args(["save-stress", &path.to_string_lossy(), "100000"]).spawn().unwrap();
// Wait until it is in its save loop (its first save replaced the file) and has reached a
// round that varies from kill to kill, however busy the machine is; then kill it a
// varying while later.
let target = i % 10;
let reached = || modified() != before && round_of(&path).and_then(|r| r.parse::<u64>().ok()).is_some_and(|r| r >= target);
let t0 = std::time::Instant::now();
while !reached() && t0.elapsed() < Duration::from_secs(20) && child.try_wait().unwrap().is_none() {
std::thread::sleep(Duration::from_millis(2));
}
std::thread::sleep(Duration::from_millis((i * 7) % 30));
if child.try_wait().unwrap().is_none() {
child.kill().unwrap();
kills += 1;
}
let _ = child.wait();
let round = round_of(&path);
assert!(round.is_some(), "after kill {i} the design file is torn or missing");
seen.insert(round);
let bak = solidcraft_engine::io::backup_path(&path);
if bak.exists() {
assert!(round_of(&bak).is_some(), "after kill {i} the backup is torn");
}
}
assert!(kills > 20, "the saver was killed while running ({kills})");
assert!(seen.len() > 5, "the saver got to saving before it was killed ({seen:?})");
let _ = std::fs::remove_dir_all(&dir);
}
+20
View File
@@ -0,0 +1,20 @@
//! The `solvecraft-cli` compatibility alias forwards to `solidcraft-cli`.
use std::process::Command;
#[test]
fn legacy_alias_forwards_with_a_deprecation_note() {
let out = Command::new(env!("CARGO_BIN_EXE_solvecraft-cli")).arg("--version").output().unwrap();
assert!(out.status.success(), "{out:?}");
let stdout = String::from_utf8_lossy(&out.stdout);
assert_eq!(stdout.trim(), format!("solidcraft-cli {}", env!("CARGO_PKG_VERSION")));
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(stderr.contains("deprecated") && stderr.contains("solidcraft-cli"), "{stderr}");
}
#[test]
fn legacy_alias_passes_the_exit_status_through() {
let alias = Command::new(env!("CARGO_BIN_EXE_solvecraft-cli")).arg("no-such-command").output().unwrap();
let real = Command::new(env!("CARGO_BIN_EXE_solidcraft-cli")).arg("no-such-command").output().unwrap();
assert_eq!(alias.status.code(), real.status.code());
assert_eq!(alias.stdout, real.stdout);
}
+18
View File
@@ -0,0 +1,18 @@
//! `mcp --connect` to a port where no app listens tells the user how to start one (#270).
use std::net::TcpListener;
use std::process::{Command, Stdio};
#[test]
fn mcp_connect_without_a_listening_app_names_the_control_flag() {
// A port that was free a moment ago: nothing listens on it.
let port = TcpListener::bind("127.0.0.1:0").unwrap().local_addr().unwrap().port();
let output = Command::new(env!("CARGO_BIN_EXE_solidcraft-cli"))
.args(["mcp", "--connect", &format!("127.0.0.1:{port}")])
.stdin(Stdio::null())
.output()
.unwrap();
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(!output.status.success(), "{stderr}");
assert!(stderr.contains("--control"), "say how to start the app with a control port: {stderr}");
}
+115
View File
@@ -0,0 +1,115 @@
//! Result reporting must not skip requested files or execute a script twice.
use std::path::{Path, PathBuf};
use std::process::{Command, Output};
use std::sync::atomic::{AtomicUsize, Ordering};
use serde_json::{Value, json};
static NEXT: AtomicUsize = AtomicUsize::new(0);
struct Scratch(PathBuf);
impl Scratch {
fn new() -> Self {
let dir = std::env::temp_dir().join(format!("solidcraft-run-results-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed)));
std::fs::create_dir(&dir).unwrap();
Self(dir)
}
fn script(&self) -> PathBuf {
let path = self.0.join("box.json");
std::fs::write(&path, json!({"commands": [{"command": "solid.box", "params": {"length": 2, "width": 3, "height": 4}}]}).to_string()).unwrap();
path
}
}
impl Drop for Scratch {
fn drop(&mut self) {
let _ = std::fs::remove_dir_all(&self.0);
}
}
fn cli() -> Command {
Command::new(env!("CARGO_BIN_EXE_solidcraft-cli"))
}
fn json_output(output: Output) -> Value {
assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr));
serde_json::from_slice(&output.stdout).unwrap()
}
fn body_count(path: &Path) -> Value {
json_output(cli().arg("eval").arg(path).output().unwrap())["body_count"].clone()
}
#[test]
fn results_still_save_and_export_the_script_once() {
let dir = Scratch::new();
let saved = dir.0.join("box.solidcraft");
let stl = dir.0.join("box.stl");
let obj = dir.0.join("box.obj");
let result = json_output(
cli().arg("run").arg(dir.script()).arg("--results").arg("--save").arg(&saved).arg("--out").arg(&stl).arg("--out").arg(&obj).output().unwrap(),
);
assert_eq!(result.as_array().unwrap().len(), 1);
assert_eq!(body_count(&saved), 1);
for exported in [&stl, &obj] {
assert!(std::fs::metadata(exported).unwrap().len() > 0);
assert_eq!(body_count(exported), 1);
}
}
#[test]
fn results_with_base_design_and_quiet_still_report_and_save() {
let dir = Scratch::new();
let script = dir.script();
let base = dir.0.join("base.solidcraft");
let saved = dir.0.join("combined.solidcraft");
json_output(cli().arg("run").arg(&script).arg("--save").arg(&base).output().unwrap());
let result = json_output(cli().args(["run", "--results", "--quiet", "--in"]).arg(&base).arg(&script).arg("--save").arg(&saved).output().unwrap());
assert_eq!(result.as_array().unwrap().len(), 1);
assert_eq!(body_count(&saved), 2);
assert_eq!(body_count(&base), 1);
}
#[test]
fn results_propagate_output_errors() {
let dir = Scratch::new();
for flag in ["--save", "--out"] {
let path = dir.0.join("missing").join(if flag == "--save" { "box.solidcraft" } else { "box.stl" });
let output = cli().arg("run").arg(dir.script()).arg("--results").arg(flag).arg(&path).output().unwrap();
assert_eq!(output.status.code(), Some(1));
assert!(!output.stderr.is_empty());
assert!(output.stdout.is_empty());
assert!(!path.exists());
}
}
#[test]
fn results_without_script_still_fail() {
let dir = Scratch::new();
let base = dir.0.join("base.solidcraft");
json_output(cli().arg("run").arg(dir.script()).arg("--save").arg(&base).output().unwrap());
let output = cli().args(["run", "--results", "--in"]).arg(&base).output().unwrap();
assert_eq!(output.status.code(), Some(1));
assert!(String::from_utf8_lossy(&output.stderr).contains("--results needs a script"));
}
/// Compatibility shim (docs/compatibility.md): a design saved before the rename, with the
/// legacy extension and format tag, still opens; re-saving writes the current tag.
#[test]
fn legacy_extension_and_format_tag_still_open() {
let dir = Scratch::new();
let saved = dir.0.join("box.solidcraft");
json_output(cli().arg("run").arg(dir.script()).arg("--save").arg(&saved).output().unwrap());
let text = std::fs::read_to_string(&saved).unwrap();
assert!(text.contains("\"solidcraft/"), "new designs carry the current tag");
let legacy = dir.0.join("old.solvecraft");
std::fs::write(&legacy, text.replace("\"solidcraft/", "\"solvecraft/")).unwrap();
assert_eq!(body_count(&legacy), 1);
let resaved = dir.0.join("resaved.solidcraft");
json_output(cli().args(["run", "--in"]).arg(&legacy).arg(dir.script()).arg("--save").arg(&resaved).output().unwrap());
assert_eq!(body_count(&resaved), 2);
assert!(std::fs::read_to_string(&resaved).unwrap().contains("\"solidcraft/"));
}