Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Wave 359/509: Kernel rig: flat DXF cases, outline, cut and bend line lengths, an ellipse exact and as arcs, and no sheet refused (and 1 more)

jyviko88aaf50bf178
diff --git a/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-as-arcs/expected.json b/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-as-arcs/expected.json
new file mode 100644
index 0000000000..daa5ec2ff4
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-as-arcs/expected.json
@@ -0,0 +1,23 @@
+{
+ "sources": [],
+ "what": "sheet.export_dxf with curves: arcs of a 100 x 60 x 2 plate with a 20 x 12 elliptical cut-out: the ellipse becomes tangent arcs",
+ "source": "analytic",
+ "method": "curves: arcs writes the ellipse as tangent arcs and lines within 0.001 mm, for machines that read only those: on layer CUT no ELLIPSE and no SPLINE, and their length is the ellipse's perimeter 51.053998 (within 0.001 mm of the curve, the length to 1e-3 relative)",
+ "body_count": 1,
+ "files": [
+ {
+ "path": "flat.dxf",
+ "dxf": {
+ "CUT": {
+ "ELLIPSE": 0,
+ "SPLINE": 0,
+ "length_mm": 51.053997725577524
+ },
+ "OUTLINE": {
+ "LINE": 4,
+ "length_mm": 320.0
+ }
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-as-arcs/recipe.json b/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-as-arcs/recipe.json
new file mode 100644
index 0000000000..c8214a1adf
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-as-arcs/recipe.json
@@ -0,0 +1,86 @@
+{
+ "commands": [
+ {
+ "command": "sheet.manage_rules",
+ "params": {
+ "name": "Steel 2",
+ "thickness": "2 mm",
+ "active": true,
+ "bend_radius": "2 mm",
+ "k_factor": 0.5
+ }
+ },
+ {
+ "command": "sketch.create",
+ "params": {
+ "plane": "XY",
+ "name": "Base"
+ }
+ },
+ {
+ "command": "sketch.rectangle.two_point",
+ "params": {
+ "p0": [
+ 0,
+ 0
+ ],
+ "p1": [
+ 100,
+ 60
+ ]
+ }
+ },
+ {
+ "command": "sketch.finish",
+ "params": {}
+ },
+ {
+ "command": "sheet.flange",
+ "params": {
+ "type": "base",
+ "sketch": "Base"
+ }
+ },
+ {
+ "command": "sketch.create",
+ "params": {
+ "plane": "XY",
+ "name": "Ellipse"
+ }
+ },
+ {
+ "command": "sketch.ellipse",
+ "params": {
+ "center": [
+ 50,
+ 30
+ ],
+ "major": [
+ 60,
+ 30
+ ],
+ "minor_radius": 6
+ }
+ },
+ {
+ "command": "sketch.finish",
+ "params": {}
+ },
+ {
+ "command": "solid.extrude",
+ "params": {
+ "sketch": "Ellipse",
+ "through_all": true,
+ "direction": "symmetric",
+ "operation": "cut"
+ }
+ },
+ {
+ "command": "sheet.export_dxf",
+ "params": {
+ "path": "$OUT/flat.dxf",
+ "curves": "arcs"
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-exact/expected.json b/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-exact/expected.json
new file mode 100644
index 0000000000..205363bbcf
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-exact/expected.json
@@ -0,0 +1,25 @@
+{
+ "sources": [],
+ "what": "sheet.export_dxf of a 100 x 60 x 2 plate with a 20 x 12 elliptical cut-out, curves exact (the default): the cut-out is one ELLIPSE",
+ "source": "analytic",
+ "method": "the cut-out is an ellipse, semi-axes 10 and 6: written exactly, one ELLIPSE on layer CUT, no arcs or splines; its perimeter (Ramanujan's second formula, exact to 1e-9 here) 51.053998. OUTLINE: 4 lines, 320 long",
+ "body_count": 1,
+ "volume_mm3": 11623.008881569225,
+ "files": [
+ {
+ "path": "flat.dxf",
+ "dxf": {
+ "CUT": {
+ "ELLIPSE": 1,
+ "ARC": 0,
+ "SPLINE": 0,
+ "length_mm": 51.053997725577524
+ },
+ "OUTLINE": {
+ "LINE": 4,
+ "length_mm": 320.0
+ }
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-exact/recipe.json b/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-exact/recipe.json
new file mode 100644
index 0000000000..3893d9d564
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-export-dxf-ellipse-exact/recipe.json
@@ -0,0 +1,85 @@
+{
+ "commands": [
+ {
+ "command": "sheet.manage_rules",
+ "params": {
+ "name": "Steel 2",
+ "thickness": "2 mm",
+ "active": true,
+ "bend_radius": "2 mm",
+ "k_factor": 0.5
+ }
+ },
+ {
+ "command": "sketch.create",
+ "params": {
+ "plane": "XY",
+ "name": "Base"
+ }
+ },
+ {
+ "command": "sketch.rectangle.two_point",
+ "params": {
+ "p0": [
+ 0,
+ 0
+ ],
+ "p1": [
+ 100,
+ 60
+ ]
+ }
+ },
+ {
+ "command": "sketch.finish",
+ "params": {}
+ },
+ {
+ "command": "sheet.flange",
+ "params": {
+ "type": "base",
+ "sketch": "Base"
+ }
+ },
+ {
+ "command": "sketch.create",
+ "params": {
+ "plane": "XY",
+ "name": "Ellipse"
+ }
+ },
+ {
+ "command": "sketch.ellipse",
+ "params": {
+ "center": [
+ 50,
+ 30
+ ],
+ "major": [
+ 60,
+ 30
+ ],
+ "minor_radius": 6
+ }
+ },
+ {
+ "command": "sketch.finish",
+ "params": {}
+ },
+ {
+ "command": "solid.extrude",
+ "params": {
+ "sketch": "Ellipse",
+ "through_all": true,
+ "direction": "symmetric",
+ "operation": "cut"
+ }
+ },
+ {
+ "command": "sheet.export_dxf",
+ "params": {
+ "path": "$OUT/flat.dxf"
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-export-dxf-flange-and-hole/expected.json b/tests/kernel-cases/sheet-metal/cov-export-dxf-flange-and-hole/expected.json
new file mode 100644
index 0000000000..9680c74928
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-export-dxf-flange-and-hole/expected.json
@@ -0,0 +1,41 @@
+{
+ "sources": [],
+ "what": "sheet.export_dxf of an 80 x 40 x 2 base with a 20 mm flange on its y = 0 edge and a 10 mm hole: outline, cut and bend line",
+ "source": "analytic",
+ "method": "T = 2, R = 2, K = 0.5: flat = base 80 x (40 - 4) + bend zone BA = (pi/2)(R + K*T) = 4.712389 + leg 20 - 4 = 16: 80 x 56.712389. OUTLINE: its 4 sides (each may be split where the zone meets the panels: 4 to 8 lines), length 2*(80 + 56.712389); CUT: the hole, 1 circle, length 10*pi; BEND_UP: the flange's bend line (it bends up), 80 long; no BEND_DOWN, no arcs",
+ "body_count": 1,
+ "results": [
+ {
+ "step": 8,
+ "json": {
+ "bends": 1
+ }
+ }
+ ],
+ "files": [
+ {
+ "path": "flat.dxf",
+ "dxf": {
+ "OUTLINE": {
+ "LINE": [
+ 4,
+ 8
+ ],
+ "ARC": 0,
+ "length_mm": 273.42477796076935
+ },
+ "CUT": {
+ "CIRCLE": 1,
+ "length_mm": 31.41592653589793
+ },
+ "BEND_UP": {
+ "length_mm": 80.0
+ },
+ "BEND_DOWN": {
+ "LINE": 0,
+ "LWPOLYLINE": 0
+ }
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-export-dxf-flange-and-hole/recipe.json b/tests/kernel-cases/sheet-metal/cov-export-dxf-flange-and-hole/recipe.json
new file mode 100644
index 0000000000..7a1bfcbca6
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-export-dxf-flange-and-hole/recipe.json
@@ -0,0 +1,81 @@
+{
+ "commands": [
+ {
+ "command": "sheet.manage_rules",
+ "params": {
+ "name": "Steel 2",
+ "thickness": "2 mm",
+ "active": true,
+ "bend_radius": "2 mm",
+ "k_factor": 0.5
+ }
+ },
+ {
+ "command": "sketch.create",
+ "params": {
+ "plane": "XY",
+ "name": "Base"
+ }
+ },
+ {
+ "command": "sketch.rectangle.two_point",
+ "params": {
+ "p0": [
+ 0,
+ 0
+ ],
+ "p1": [
+ 80,
+ 40
+ ]
+ }
+ },
+ {
+ "command": "sketch.finish",
+ "params": {}
+ },
+ {
+ "command": "sheet.flange",
+ "params": {
+ "type": "base",
+ "sketch": "Base"
+ }
+ },
+ {
+ "command": "sheet.flange",
+ "params": {
+ "type": "edge",
+ "edges": [
+ [
+ 40,
+ 0,
+ 2
+ ]
+ ],
+ "height": 20
+ }
+ },
+ {
+ "command": "solid.hole",
+ "params": {
+ "position": [
+ 40,
+ 25,
+ 0
+ ],
+ "direction": [
+ 0,
+ 0,
+ 1
+ ],
+ "diameter": 10
+ }
+ },
+ {
+ "command": "sheet.export_dxf",
+ "params": {
+ "path": "$OUT/flat.dxf"
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-export-dxf-without-a-sheet-refused/expected.json b/tests/kernel-cases/sheet-metal/cov-export-dxf-without-a-sheet-refused/expected.json
new file mode 100644
index 0000000000..05ce3dcf47
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-export-dxf-without-a-sheet-refused/expected.json
@@ -0,0 +1,8 @@
+{
+ "sources": [],
+ "what": "sheet.export_dxf in a design with a box and no sheet metal body",
+ "source": "invariants",
+ "method": "there is no flat pattern to write: a clean refusal that says how to start a sheet",
+ "outcome": "refused",
+ "refusal": "there is no sheet metal body"
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-export-dxf-without-a-sheet-refused/recipe.json b/tests/kernel-cases/sheet-metal/cov-export-dxf-without-a-sheet-refused/recipe.json
new file mode 100644
index 0000000000..d10795bfb7
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-export-dxf-without-a-sheet-refused/recipe.json
@@ -0,0 +1,18 @@
+{
+ "commands": [
+ {
+ "command": "solid.box",
+ "params": {
+ "length": 20,
+ "width": 10,
+ "height": 2
+ }
+ },
+ {
+ "command": "sheet.export_dxf",
+ "params": {
+ "path": "$OUT/flat.dxf"
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-perforate-keeps-clear-of-a-bend-zone/expected.json b/tests/kernel-cases/sheet-metal/cov-perforate-keeps-clear-of-a-bend-zone/expected.json
new file mode 100644
index 0000000000..079f05b503
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-perforate-keeps-clear-of-a-bend-zone/expected.json
@@ -0,0 +1,20 @@
+{
+ "sources": [],
+ "what": "sheet.perforate, a square field over a 40 x 20 x 1 base with a 10 mm flange on its x = 40 edge: no hole within the margin of the bend zone",
+ "source": "analytic",
+ "method": "T = 1, R = 1, K = 0.5: the flange sets the base back R + T = 2 (flat x 0..38), its bend zone is BA = (pi/2)(R + K*T) = 2.356194 wide (x 38..40.356194), its leg 10 - 2 = 8 (to x 48.356194). 1 mm holes, pitch 4, margin 1 (clear 1.5): rows y 1.5, 5.5, 9.5, 13.5, 17.5 (5); per row x 1.5, 5.5, ..., 45.5 (<= 46.8562) less those within 1.5 of the zone (37.5 and 41.5): 9 on the base, 1 on the flange (45.5): 50 holes",
+ "body_count": 1,
+ "results": [
+ {
+ "step": 8,
+ "json": {
+ "perforations": [
+ {
+ "count": 50,
+ "pattern": "square"
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-perforate-keeps-clear-of-a-bend-zone/recipe.json b/tests/kernel-cases/sheet-metal/cov-perforate-keeps-clear-of-a-bend-zone/recipe.json
new file mode 100644
index 0000000000..6bb2a12470
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-perforate-keeps-clear-of-a-bend-zone/recipe.json
@@ -0,0 +1,72 @@
+{
+ "commands": [
+ {
+ "command": "sheet.manage_rules",
+ "params": {
+ "name": "Steel 1",
+ "thickness": "1 mm",
+ "active": true,
+ "bend_radius": "1 mm",
+ "k_factor": 0.5
+ }
+ },
+ {
+ "command": "sketch.create",
+ "params": {
+ "plane": "XY",
+ "name": "Base"
+ }
+ },
+ {
+ "command": "sketch.rectangle.two_point",
+ "params": {
+ "p0": [
+ 0,
+ 0
+ ],
+ "p1": [
+ 40,
+ 20
+ ]
+ }
+ },
+ {
+ "command": "sketch.finish",
+ "params": {}
+ },
+ {
+ "command": "sheet.flange",
+ "params": {
+ "type": "base",
+ "sketch": "Base"
+ }
+ },
+ {
+ "command": "sheet.flange",
+ "params": {
+ "type": "edge",
+ "edges": [
+ [
+ 40,
+ 10,
+ 1
+ ]
+ ],
+ "height": 10
+ }
+ },
+ {
+ "command": "sheet.perforate",
+ "params": {
+ "diameter": "1",
+ "pitch": "4",
+ "margin": "1",
+ "pattern": "square"
+ }
+ },
+ {
+ "command": "sheet.flat_pattern",
+ "params": {}
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-perforate-pitch-no-larger-than-the-hole-refused/expected.json b/tests/kernel-cases/sheet-metal/cov-perforate-pitch-no-larger-than-the-hole-refused/expected.json
new file mode 100644
index 0000000000..279761d4fa
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-perforate-pitch-no-larger-than-the-hole-refused/expected.json
@@ -0,0 +1,8 @@
+{
+ "sources": [],
+ "what": "sheet.perforate with a pitch equal to the hole's diameter: the holes would touch",
+ "source": "invariants",
+ "method": "holes 2 mm across at a 2 mm pitch leave no web between them; the documented rule is pitch > diameter, so the field is refused",
+ "outcome": "refused",
+ "refusal": "pitch > diameter"
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-perforate-pitch-no-larger-than-the-hole-refused/recipe.json b/tests/kernel-cases/sheet-metal/cov-perforate-pitch-no-larger-than-the-hole-refused/recipe.json
new file mode 100644
index 0000000000..6fca887850
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-perforate-pitch-no-larger-than-the-hole-refused/recipe.json
@@ -0,0 +1,53 @@
+{
+ "commands": [
+ {
+ "command": "sheet.manage_rules",
+ "params": {
+ "name": "Steel 1",
+ "thickness": "1 mm",
+ "active": true,
+ "bend_radius": "1 mm",
+ "k_factor": 0.5
+ }
+ },
+ {
+ "command": "sketch.create",
+ "params": {
+ "plane": "XY",
+ "name": "Base"
+ }
+ },
+ {
+ "command": "sketch.rectangle.two_point",
+ "params": {
+ "p0": [
+ 0,
+ 0
+ ],
+ "p1": [
+ 30,
+ 20
+ ]
+ }
+ },
+ {
+ "command": "sketch.finish",
+ "params": {}
+ },
+ {
+ "command": "sheet.flange",
+ "params": {
+ "type": "base",
+ "sketch": "Base"
+ }
+ },
+ {
+ "command": "sheet.perforate",
+ "params": {
+ "diameter": "2",
+ "pitch": "2",
+ "margin": "1"
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-perforate-square-field-on-a-plate/expected.json b/tests/kernel-cases/sheet-metal/cov-perforate-square-field-on-a-plate/expected.json
new file mode 100644
index 0000000000..65b7970309
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-perforate-square-field-on-a-plate/expected.json
@@ -0,0 +1,26 @@
+{
+ "sources": [],
+ "what": "sheet.perforate, a square field of 2 mm holes at 5 mm pitch, 1 mm margin, over a 30 x 20 x 1 plate",
+ "source": "analytic",
+ "method": "holes start at margin + radius = 2 from the flat's lower-left corner and step 5: x 2, 7, ..., 27 (6, each <= 30 - 2), y 2, 7, 12, 17 (4): 24 holes, open area 24*pi*1^2. The field is stored, not cut into the B-rep: the body stays the 30 x 20 x 1 plate, V = 600, 6 faces",
+ "body_count": 1,
+ "volume_mm3": 600.0,
+ "faces": 6,
+ "results": [
+ {
+ "step": 7,
+ "json": {
+ "perforations": [
+ {
+ "count": 24,
+ "pattern": "square",
+ "diameter": 2.0,
+ "pitch": 5.0,
+ "margin": 1.0,
+ "open_area_mm2": 75.39822368615503
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-perforate-square-field-on-a-plate/recipe.json b/tests/kernel-cases/sheet-metal/cov-perforate-square-field-on-a-plate/recipe.json
new file mode 100644
index 0000000000..d0b798eaff
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-perforate-square-field-on-a-plate/recipe.json
@@ -0,0 +1,58 @@
+{
+ "commands": [
+ {
+ "command": "sheet.manage_rules",
+ "params": {
+ "name": "Steel 1",
+ "thickness": "1 mm",
+ "active": true,
+ "bend_radius": "1 mm",
+ "k_factor": 0.5
+ }
+ },
+ {
+ "command": "sketch.create",
+ "params": {
+ "plane": "XY",
+ "name": "Base"
+ }
+ },
+ {
+ "command": "sketch.rectangle.two_point",
+ "params": {
+ "p0": [
+ 0,
+ 0
+ ],
+ "p1": [
+ 30,
+ 20
+ ]
+ }
+ },
+ {
+ "command": "sketch.finish",
+ "params": {}
+ },
+ {
+ "command": "sheet.flange",
+ "params": {
+ "type": "base",
+ "sketch": "Base"
+ }
+ },
+ {
+ "command": "sheet.perforate",
+ "params": {
+ "diameter": "2",
+ "pitch": "5",
+ "margin": "1",
+ "pattern": "square"
+ }
+ },
+ {
+ "command": "sheet.flat_pattern",
+ "params": {}
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-perforate-staggered-field-on-a-plate/expected.json b/tests/kernel-cases/sheet-metal/cov-perforate-staggered-field-on-a-plate/expected.json
new file mode 100644
index 0000000000..c1eee3e7ec
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-perforate-staggered-field-on-a-plate/expected.json
@@ -0,0 +1,38 @@
+{
+ "sources": [],
+ "what": "sheet.perforate, a staggered (60 degree) field of 1 mm holes at 3 mm pitch, 1 mm margin, over a 20 x 10 x 1 plate, exported to DXF",
+ "source": "analytic",
+ "method": "clear = radius + margin = 1.5; rows every 3*sqrt(3)/2 = 2.598 from y 1.5: y 1.5, 4.098, 6.696 (9.294 > 8.5); even rows x 1.5, 4.5, ..., 16.5 (6), the odd row shifted 1.5: x 3, ..., 18 (6): 18 holes. In the DXF, 18 circles on layer PERFORATION, length 18*pi*1; the plate's outline 4 lines, 60 long. The B-rep is not cut: V = 200",
+ "body_count": 1,
+ "volume_mm3": 200.0,
+ "faces": 6,
+ "results": [
+ {
+ "step": 7,
+ "json": {
+ "perforations": [
+ {
+ "count": 18,
+ "pattern": "staggered",
+ "open_area_mm2": 14.137166941154069
+ }
+ ]
+ }
+ }
+ ],
+ "files": [
+ {
+ "path": "flat.dxf",
+ "dxf": {
+ "PERFORATION": {
+ "CIRCLE": 18,
+ "length_mm": 56.548667764616276
+ },
+ "OUTLINE": {
+ "LINE": 4,
+ "length_mm": 60.0
+ }
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/sheet-metal/cov-perforate-staggered-field-on-a-plate/recipe.json b/tests/kernel-cases/sheet-metal/cov-perforate-staggered-field-on-a-plate/recipe.json
new file mode 100644
index 0000000000..a2b02cd51d
--- /dev/null
+++ b/tests/kernel-cases/sheet-metal/cov-perforate-staggered-field-on-a-plate/recipe.json
@@ -0,0 +1,63 @@
+{
+ "commands": [
+ {
+ "command": "sheet.manage_rules",
+ "params": {
+ "name": "Steel 1",
+ "thickness": "1 mm",
+ "active": true,
+ "bend_radius": "1 mm",
+ "k_factor": 0.5
+ }
+ },
+ {
+ "command": "sketch.create",
+ "params": {
+ "plane": "XY",
+ "name": "Base"
+ }
+ },
+ {
+ "command": "sketch.rectangle.two_point",
+ "params": {
+ "p0": [
+ 0,
+ 0
+ ],
+ "p1": [
+ 20,
+ 10
+ ]
+ }
+ },
+ {
+ "command": "sketch.finish",
+ "params": {}
+ },
+ {
+ "command": "sheet.flange",
+ "params": {
+ "type": "base",
+ "sketch": "Base"
+ }
+ },
+ {
+ "command": "sheet.perforate",
+ "params": {
+ "diameter": "1",
+ "pitch": "3",
+ "margin": "1"
+ }
+ },
+ {
+ "command": "sheet.flat_pattern",
+ "params": {}
+ },
+ {
+ "command": "sheet.export_dxf",
+ "params": {
+ "path": "$OUT/flat.dxf"
+ }
+ }
+ ]
+}