Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
# Changelog

## 0.13.0 (2026-12-01)

New:

- Print groups: `part(print = "name")` makes the parts with one print
name one object in the print layout (`--print`, `layout: "print"`)
where they touch and move alike as the model opens (a hinged lid prints
apart from its box), so a model joined at its edges prints as one piece
instead of parts to glue. A box's bottom and walls print as one cup,
standing on its bottom however the box is placed, and its lid prints
beside it. An object lies on its first part, on the face away from the
rest of it; `print_on = true` on another part lays it on that one, and
`"back"` or `"front"` names the face. Parts glued on a part of a
group come with it unless they have a print name of their own.
`$print` sets the group for every part inside except glued ones, and
`print = ""` leaves one out. A group's 3MF object is named after it,
and its bodies carry the name as `object`; an object in no group is
named after its part.
- `print = "each"` prints every copy of a part as an object of its own,
joined only with the same copy of other parts with `print = "each"`
that touch it, so each piece of a chess set built from several parts
prints as one. `print("name") { ... }` sets the print group of the
parts inside.
`$print` at the top level of a program names every part in it,
wherever the line is, and is never listed as a setting.
- Without `print_on`, an object that would hang over air lies on
whichever face of its parts needs clearly the least support.
- `spin(from, to, ratio = 1, stage)` turns the parts inside on an axle
as the model opens, `ratio` whole turns, less than 0 the other way, so
a gear train plays at its tooth ratios. A spin() inside another turns
along with it, as a planet gear on its carrier. Laid out to 3D print, a
turning part prints apart from what it turns in. The gears example
turns.
- The libraries put what prints as one piece in print groups: `box()`
its bottom and walls, `enclosure()` its body, `flex_box()` its strip
and bottom and its lid, `drawers()` its carcass (lying on its back) and
each drawer, `ring_stack()` its rings and cores, and `stand()` a sign
with its base.
- A check for what needs supports: `kerf render --print` warns about each
object of the print layout that hangs over air, steeper than 45 degrees
with nothing under it, and `kerf check --print` lists them, with the
parts, the area and the height above the bed. `overhangs(bodies)` gives
the same from JavaScript.
- The playground downloads a 3MF or STL laid out to 3D print, and its 3D
view has a Print layout button that shows the objects the files hold
and the ones that need supports.
- The examples that print well as whole pieces have print groups: trays,
bins, shelves, stands, lanterns, enclosures, reliefs and sculptures,
with their lids, drawers and covers apart. Mechanisms keep their parts
loose.

Changes:

- In the print layout, a stack of glued layers lies on its bigger end, so
a lid glued over a smaller insert prints on the lid, not on the insert.

## 0.12.3 (2026-11-30)

Changes:
Expand Down
31 changes: 31 additions & 0 deletions LANGUAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,28 @@ material(thickness = 4, kerf = 0.12, name = "birch") {
top (or bottom) face; its `at` and `rotate` are measured on the face,
and the parts list says what it is glued to. With as many copies as
the part it is glued on, one goes on each.
- `print = "name"`: a print group. Laid out to 3D print (`--print`,
`layout: "print"`), the parts with one print name that touch, and
move alike as the model opens, are one object, as the assembly joins
them: a box's bottom and walls print as one cup, and its lid, in no
group, as an object of its own. An object lies on its first part, on
the face away from the rest of it, so the cup stands on its bottom
however the box is placed; if that would hang over air, it lies on a
face of one of its biggest parts that needs clearly less support. A
part glued on another prints with it unless it has a print name of
its own. `print = "each"` prints every copy of the part as an object
of its own, joined only with the same copy of other parts with
`print = "each"` that touch it: copy 3 of a chess piece's base with
copy 3 of each of its plates. `print = ""` leaves a part out of any
group. `print("name") { ... }` and `$print = "name"` give the name to
every part made inside them; at the top level of a program `$print`
names every part in it, wherever the line is, and is never a
setting. A glued part still goes with its host.
- `print_on = true`: laid out to 3D print, the object this part is in
lies on it, on its face away from the rest, as a shelf unit on its
back panel or a stool upside down on its seat. `"back"` or
`"front"` names the face. A stack of parallel layers lies on its
bigger end.
- `slots = ["name", ...]`: where the named parts' material passes through
this part in the assembly, slots are cut through it the shape of their
cross-section, at any angle, `clearance = 0.1` wider. Draw tabs on one
Expand Down Expand Up @@ -386,6 +408,15 @@ material(thickness = 4, kerf = 0.12, name = "birch") {
stage in turn, numbers first in number order, then names as they first
run (one named inside another first); `render()` returns them as
`stages`.
- `spin(from, to, ratio = 1, stage) { ... }`: the parts and hardware
inside turn on the axle from `from` to `to` while the model opens,
`ratio` whole turns, right-handed about that direction, less than 0
the other way: a gear, a wheel, a crank. Give meshing gears ratios as
their teeth go, one the other way:
`spin(from, to, ratio = -teeth_large / teeth_small)`. A spin() inside
another turns along with it, as a planet gear on its carrier, rather
than after it; it takes `stage` as hinge() does. Laid out to 3D print,
a part that turns prints apart from the parts it turns against.
- `hardware(kind, from, to, size = 6, up, sides = 24, shape = "rod", label)`
lists hardware the assembly needs, from one point to another: a dowel, a
screw, a magnet, paper. `size` is a diameter, or `[w, h]` for a flat
Expand Down
4 changes: 2 additions & 2 deletions alias/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kerfscript",
"version": "0.12.3",
"version": "0.13.0",
"description": "KerfScript: a programming language for laser cutting. Same package as @mylasertools/kerfscript.",
"type": "module",
"license": "AGPL-3.0-only",
Expand Down Expand Up @@ -52,6 +52,6 @@
"node": ">=20"
},
"dependencies": {
"@mylasertools/kerfscript": "0.12.3"
"@mylasertools/kerfscript": "0.13.0"
}
}
2 changes: 1 addition & 1 deletion desktop/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kerfscript-desktop"
version = "0.12.3"
version = "0.13.0"
description = "KerfScript: a programming language for laser cutting"
authors = ["MyLaserTools"]
license = "AGPL-3.0-only"
Expand Down
85 changes: 84 additions & 1 deletion docs/3d-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,88 @@ where they show: not under a layer glued over them or on the bed.
kerf render snow-scene.kerf -o snow-scene.3mf --print
```

### Print groups

Parts joined at an edge, not glued face to face, are objects of their own
unless they share a print group. Give the parts that print as one piece
the same `print` name, and leave the rest out:

```kerf
$thickness = 3;
part("tray", print = "tray", at = [0, 0, 0]) rect([100, 60]);
part("side", print = "tray", qty = 2, at = [[0, 3, 3], [0, 60, 3]], rotate = [90, 0, 0])
rect([100, 20]);
part("lid", at = [0, 0, 30]) rect([100, 60]);
```

The tray and its sides print as one piece with the lid beside it on the
same plate. In the 3MF the group is one object named after it ("tray"),
each part a piece of it in its colour, so the slicer joins them as it
slices. Only parts that touch join: two boxes of one group name, apart in
the assembly, are two objects. Parts that move as the model opens
(`hinge()`, `slide()`, `spin()`) join only parts that move with them,
so a hinged lid of two layers prints as one object beside its box, never
shut on it, and a gear on `spin()` prints apart from the frame it turns
in.

An object lies on its first part, on the face away from the rest of it,
so the tray stands on its bottom however the assembly turns it. If it
would hang over air that way, it is tried on both faces of each of its
parts, small ones too, and lies the way that needs clearly the least
support. `print_on = true` on a part lays the object on that part
instead, on its face away from the rest: a cabinet on its back panel, so
its shelves stand up and nothing hangs over air, or a sculpture on its
base. `print_on = "back"` or `"front"` names the face. A stack of
parallel layers lies on its bigger end: a lid glued over a smaller
insert prints on the lid.

Everything glued on a part of the group comes with it, unless it has a
print name of its own. `print = "each"` prints every copy of a part as
an object of its own, as coasters stacked in the assembly to show them.
Copies of several parts with `print = "each"` join where the same copy
of each touches: a chess set whose pieces are a base, a front plate and
a side plate, each part with `qty = 32`, prints 32 pieces, each one
object, none fused to the board or to the next piece. `print = ""`
takes a part out of any group. `print("body") { ... }` puts the parts
made inside it in that group, as `print("") { ... }` leaves them out,
whatever their names. `$print = "body"` at the top level of a program
puts every part in it in one group, wherever the line is, and is never
listed as a setting; inside a block it names the parts made in it. A glued part still goes with its host. Keep parts
that move or come out (a lid, a drawer, a perch, a cover over a ball) in
groups of their own, or in none, so they print loose.

The libraries group what prints as one piece: `box()` its bottom and
walls ("box"), `enclosure()` its body ("enclosure"), `flex_box()` its
strip and bottom ("box") and its lid ("lid"), `drawers()` its carcass
("carcass", lying on its back) and each drawer, `ring_stack()` its rings
and core plates, and `stand()` a sign with its base. `grid_dividers()`
leaves its dividers loose, to print flat and slot together.

### Hanging over air

A face that hangs over air needs supports to print: a shelf over nothing,
a crown over a ring of fins. `kerf render --print` warns about each
object with more than 20 mm² of it, and `kerf check file.kerf --print`
lists them:

```sh
kerf check stem-lab.kerf --print
```

A face counts as held up when solid of the same object is under it, or
beside it, lower, and no steeper than 45 degrees from upright. A ledge up
to 1.5 mm wide counts as held, and so does a gap of 0.3 mm or less, as a
slot's clearance. A bridge between two walls is listed too; a short one
often prints without supports. Lay the object another way with
`print_on` if it needs less support that way.

### In the playground

The playground's 3MF and STL buttons download the print layout. In the
3D view, **Print layout** shows it as the files have it, with the number
of objects and the ones that need supports, so you can see what prints as
one piece before you download.

Each layer takes its colour from its material: a colour in the name
(`material = "green"`, `"#cc3333 card"`) or a wood or sheet it names. A
stack with a part bent on a living hinge is laid out part by part, flat.
Expand Down Expand Up @@ -89,5 +171,6 @@ const print = toModel(result, '3mf', { layout: 'print', markHeight: 0.6 });
triangles in millimetres) for a viewer of your own, and `toGlb()`, `to3mf()`
and `toStl()` write them. The options are `layout` (`"assembled"`,
`"flat"` or `"print"`), `markHeight`, `lineWidth`, `slitWidth`, `hardware`
and `gap`.
and `gap`. `overhangs(bodies)` lists the objects of the print layout that
hang over air.
See the [JavaScript API](javascript.md).
9 changes: 7 additions & 2 deletions docs/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,18 @@ const print = toModel(render(source), '3mf', { layout: 'print', markHeight: 0.6

The format is `"glb"`, `"3mf"` or `"stl"`, and the result a `Uint8Array`.
`layout` is `"assembled"` (the default), `"flat"` (every part side by side,
front up) or `"print"` (each part with what is glued on it as one object of
coloured layers). Each entry of `result.assembly` with `glued` gives the
front up) or `"print"` (each print group, or part with what is glued on
it, as one object of coloured layers). Each entry of `result.assembly` with `glued` gives the
index of the entry it is glued on.
`meshBodies(result, options)` gives the solid bodies (positions and
triangles in millimetres, z up) for a viewer of your own; `toGlb()`,
`to3mf()` and `toStl()` write a list of them. `result.flat` lists every copy
of every part flat at its own origin, placed or not.
`overhangs(bodies)` takes the bodies of the print layout and returns the
objects that hang over air, each with its `object` name, the `parts`
that hang, the `area` in mm² and the lowest `height` above the bed;
`angle` (45 degrees from upright) and `minArea` (20 mm²) set what
counts.

## format()

Expand Down
4 changes: 2 additions & 2 deletions docs/versions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Versions

KerfScript 0.12.3 implements language version 0.3. The package version tracks
KerfScript 0.13.0 implements language version 0.3. The package version tracks
the software release; the language version tracks the syntax and behavior
of `.kerf` programs.

Expand Down Expand Up @@ -30,4 +30,4 @@ files used with a design. Applications that store designs should retain
that information and compare the output before upgrading the interpreter.

Pin the npm package to an exact version when your application needs a fixed
renderer, for example `@mylasertools/kerfscript@0.12.3`.
renderer, for example `@mylasertools/kerfscript@0.13.0`.
2 changes: 1 addition & 1 deletion editors/vscode/syntaxes/kerfscript.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
},
{
"comment": "Built-in modules",
"match": "\\b(rect|square|circle|ellipse|regular_polygon|star|polygon|path|text|line|polyline|arc|translate|rotate|scale|mirror|multmatrix|union|group|difference|intersection|hull|offset|pattern|spline|hatch|flow|contours|occlude|hide|paint|measure|fill_holes|largest|join_islands|close|stroke|outline|part|place|hinge|slide|call|step|hardware|light|material|finger_rect|finger_holes|tslot|living_hinge|children|echo|assert|box|divider|kerf_gauge|slot_gauge|joint_test|slotted_divider|grid_dividers|enclosure|enclosure_cutouts|vents|spur_gear|gear_window|rack|lantern_disc|peg_wheel|eccentric|snail_cam|tappets|cone_flat|fit|align|cam|geneva_wheel|geneva_lock|geneva_crank|ratchet|pawl|world_map|keyhole|keyholes|hanging_hole|hanging_loop|flex_rect|flex_box|flex_panel|narrow_hinge|flex_strip|wall|cam_lock|lock_key|ring_stack|halved_pair|symbol|tabs|slots|tab_rect|heart|teardrop|egg|lens|crescent|capsule|diamond|rounded_polygon|shield|arrow|chevron|banner|house|tag|ring|scalloped|flower|cloud|speech_bubble|stand|stand_tabs|stand_slots|figure|figure_layer|figure_parts|figure_shapes|figure_details|drawers|layered|ball|inlaid|scene_rails|scene_floor|standee|scene_figure|figure_base|drip_edge|wave_edge)\\s*(?=\\()",
"match": "\\b(rect|square|circle|ellipse|regular_polygon|star|polygon|path|text|line|polyline|arc|translate|rotate|scale|mirror|multmatrix|union|group|difference|intersection|hull|offset|pattern|spline|hatch|flow|contours|occlude|hide|paint|measure|fill_holes|largest|join_islands|close|stroke|outline|part|place|hinge|slide|spin|print|call|step|hardware|light|material|finger_rect|finger_holes|tslot|living_hinge|children|echo|assert|box|divider|kerf_gauge|slot_gauge|joint_test|slotted_divider|grid_dividers|enclosure|enclosure_cutouts|vents|spur_gear|gear_window|rack|lantern_disc|peg_wheel|eccentric|snail_cam|tappets|cone_flat|fit|align|cam|geneva_wheel|geneva_lock|geneva_crank|ratchet|pawl|world_map|keyhole|keyholes|hanging_hole|hanging_loop|flex_rect|flex_box|flex_panel|narrow_hinge|flex_strip|wall|cam_lock|lock_key|ring_stack|halved_pair|symbol|tabs|slots|tab_rect|heart|teardrop|egg|lens|crescent|capsule|diamond|rounded_polygon|shield|arrow|chevron|banner|house|tag|ring|scalloped|flower|cloud|speech_bubble|stand|stand_tabs|stand_slots|figure|figure_layer|figure_parts|figure_shapes|figure_details|drawers|layered|ball|inlaid|scene_rails|scene_floor|standee|scene_figure|figure_base|drip_edge|wave_edge)\\s*(?=\\()",
"captures": { "1": { "name": "support.function.builtin.kerfscript" } }
},
{
Expand Down
2 changes: 2 additions & 0 deletions examples/book-brace.kerf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ $kerf = 0.15; // [0:0.01:0.3]
clearance = 0.15; // [0:0.05:0.4]

/* [Hidden] */
// Laid out to 3D print, the parts that touch are one object
$print = "book-brace";
$material = "plywood";
t = $thickness;
assert(brace_height < height - 12, "Gusset must be lower than the upright");
Expand Down
2 changes: 2 additions & 0 deletions examples/bottle-tote.kerf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ $kerf = 0.15; // [0:0.01:0.3]
clearance = 0.15; // [0:0.05:0.4]

/* [Hidden] */
// Laid out to 3D print, the parts that touch are one object
$print = "bottle-tote";
$material = "plywood";
t = $thickness;
pitch = bottle_diameter + 2 * ease + t;
Expand Down
2 changes: 2 additions & 0 deletions examples/cable-harbour.kerf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ $kerf = 0.15; // [0:0.01:0.3]
clearance = 0.15; // [0:0.05:0.4]

/* [Hidden] */
// Laid out to 3D print, the parts that touch are one object
$print = "cable-harbour";
$material = "plywood";
t = $thickness;
w = bays * bay_width + (bays + 1) * t;
Expand Down
2 changes: 2 additions & 0 deletions examples/card-pocket.kerf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ $thickness = 3; // [2:0.5:6]
$kerf = 0.15; // [0:0.01:0.3]

/* [Hidden] */
// Laid out to 3D print, the parts that touch are one object
$print = "card-pocket";
$material = "plywood";
t = $thickness;
w = card_width + 2 * ease + 2 * t;
Expand Down
2 changes: 2 additions & 0 deletions examples/coaster-caddy.kerf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ $thickness = 3; // [2:0.5:6]
$kerf = 0.15; // [0:0.01:0.3]

/* [Hidden] */
// Laid out to 3D print, the parts that touch are one object
$print = "coaster-caddy";
$material = "plywood";
t = $thickness;
w = diameter + 2 * ease + 2 * t;
Expand Down
Loading
Loading