@mylasertools/kerfscript 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/render.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type AssemblyPart } from './assembly.cjs';
1
2
  import { type LayerDef, type Limits } from './evaluator.cjs';
2
3
  import { type LayerPath } from './export/svg.cjs';
3
4
  import { type Layer } from './geometry.cjs';
@@ -51,6 +52,7 @@ export interface RenderResult {
51
52
  paths: LayerPath[];
52
53
  svg: string;
53
54
  parts: PartInfo[];
55
+ assembly: AssemblyPart[];
54
56
  layers: LayerDef[];
55
57
  warnings: string[];
56
58
  echoes: string[];
package/dist/render.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type AssemblyPart } from './assembly.js';
1
2
  import { type LayerDef, type Limits } from './evaluator.js';
2
3
  import { type LayerPath } from './export/svg.js';
3
4
  import { type Layer } from './geometry.js';
@@ -51,6 +52,7 @@ export interface RenderResult {
51
52
  paths: LayerPath[];
52
53
  svg: string;
53
54
  parts: PartInfo[];
55
+ assembly: AssemblyPart[];
54
56
  layers: LayerDef[];
55
57
  warnings: string[];
56
58
  echoes: string[];
@@ -61,16 +61,17 @@ The URL should point to a font file provided by your application.
61
61
 
62
62
  ### Result
63
63
 
64
- | Field | Contents |
65
- | ----------------- | ------------------------------------------------------------------------------------- |
66
- | `svg` | Combined SVG containing all sheets |
67
- | `width`, `height` | Combined SVG dimensions in millimetres |
68
- | `sheets` | Each sheet's dimensions, material, thickness, SVG, DXF, paths and placed items |
69
- | `parts` | Part names, quantities, dimensions, piece counts, cut lengths and material properties |
70
- | `paths` | Layer paths with `name`, `mode`, `color`, `d`, `regions` and `lines` |
71
- | `layers` | Layer definitions in output order |
72
- | `warnings` | Problems that did not stop the render |
73
- | `echoes` | Output from the program's `echo()` calls |
64
+ | Field | Contents |
65
+ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
66
+ | `svg` | Combined SVG containing all sheets |
67
+ | `width`, `height` | Combined SVG dimensions in millimetres |
68
+ | `sheets` | Each sheet's dimensions, material, thickness, SVG, DXF, paths and placed items |
69
+ | `parts` | Part names, quantities, dimensions, piece counts, cut lengths and material properties |
70
+ | `assembly` | One entry per copy of a part with `name`, `copy`, `thickness`, `outline`, a 4 × 4 `matrix` and `placed`, for showing the design put together. Parts without `at` or `rotate` have `placed: false` |
71
+ | `paths` | Layer paths with `name`, `mode`, `color`, `d`, `regions` and `lines` |
72
+ | `layers` | Layer definitions in output order |
73
+ | `warnings` | Problems that did not stop the render |
74
+ | `echoes` | Output from the program's `echo()` calls |
74
75
 
75
76
  Use `result.svg` for a combined preview. Use `result.sheets[i].svg` or
76
77
  `.dxf` to export individual sheets, particularly when they use different
@@ -29,6 +29,38 @@ part("tag") {
29
29
  }
30
30
  ```
31
31
 
32
+ ## Assembly
33
+
34
+ Give a part a place in 3D and apps can show the design put together.
35
+ `rotate` turns the part and `at` moves it. The turn happens first, the same
36
+ as OpenSCAD's `translate(at) rotate(r)`. Each part is drawn flat with its
37
+ thickness standing up along +Z.
38
+
39
+ ```kerf
40
+ material(thickness = 3) {
41
+ part("base", at = [0, 0, 0]) rect([100, 60]);
42
+ part("wall", at = [0, 3, 3], rotate = [90, 0, 0]) rect([100, 40]);
43
+ }
44
+ ```
45
+
46
+ A part with copies takes one placement for all of them, or a list with one
47
+ for each copy:
48
+
49
+ ```kerf
50
+ part("leg", qty = 4, at = [[0, 0, 0], [80, 0, 0], [0, 40, 0], [80, 40, 0]],
51
+ rotate = [90, 0, 0]) rect([20, 60]);
52
+ ```
53
+
54
+ `box()` from `kerf/box` places its panels itself, so every box assembles.
55
+ Parts without `at` or `rotate` lie flat beside the assembled view, each copy
56
+ in rows to its right, and the render names them in a warning. When placed
57
+ parts run into each other, the render warns which two collide. That is what
58
+ a finger edge set to `"out"` where it should be `"in"` looks like, or a part
59
+ placed one thickness off. Joints that interlock exactly do not count, and
60
+ neither does an overlap smaller than about a cubic millimetre, the kind of
61
+ nick a laser kerf or a press fit takes up. A tab half a millimetre out of its
62
+ slot is well over that and gets a warning.
63
+
32
64
  ## Materials
33
65
 
34
66
  `material()` sets the thickness, kerf and material name for its parts:
package/docs/versions.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Versions
2
2
 
3
- KerfScript 0.3.0 implements language version 0.1. The package version tracks
3
+ KerfScript 0.4.0 implements language version 0.1. The package version tracks
4
4
  the software release; the language version tracks the syntax and behavior
5
5
  of `.kerf` programs.
6
6
 
@@ -30,4 +30,4 @@ files used with a design. Applications that store designs should retain
30
30
  that information and compare the output before upgrading the interpreter.
31
31
 
32
32
  Pin the npm package to an exact version when your application needs a fixed
33
- renderer, for example `@mylasertools/kerfscript@0.3.0`.
33
+ renderer, for example `@mylasertools/kerfscript@0.4.0`.
@@ -60,7 +60,9 @@ Every response has `ok`. When it is `false`, `error` holds the message and
60
60
  exits with an error code for a bad program.
61
61
 
62
62
  - `render`: `svg` (all sheets, for preview), `width`, `height`, `parts`,
63
- `warnings`, `echoes` and `sheets`. Each sheet has `width`, `height`,
63
+ `assembly`, `warnings`, `echoes` and `sheets`. `assembly` is the same as
64
+ from [`render()`](javascript.md): one entry per copy of a part, with its
65
+ outline, thickness and placement. Each sheet has `width`, `height`,
64
66
  `material`, `thickness`, `svg` and `dxf`; write one file per sheet to cut.
65
67
  - `params`: `parameters`, as from [`parameters()`](javascript.md).
66
68
  - `version`: `version` (package) and `language`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mylasertools/kerfscript",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "KerfScript: a programming language for laser cutting. Write parametric 2D parts with cut, score and engrave layers, kerf compensation and joinery, and export SVG or DXF.",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",