ZSLICEDOCS

Documentation

zslice

A slicer for FDM 3D printers, written from scratch in Zig. Click any line of the preview to see what it is and why it prints the way it does. It slices fast enough to slice again while you drag a slider. And it runs in your browser: try it at zslice.beetlebug.org, with no install.

Get started Settings Embed the library How a slicer works Source on GitHub

A boat test model, sliced by zslice
Zig 0.16C APIWebAssemblyGTK4 appAGPL-3.0-or-later

The documentation

Features

Fast

Click a line, see why

Settings for one layer, or for a range of layers

A settings panel that shows what each setting does

The settings panel, pinned at the right: Settings › Part › Layers › Top thickness. The preview shows only the skin lines, and the other lines fade

A preview that looks like the print

The top knob of the layer slider goes down through the Benchy and back up. Then the replay prints the first layers at 30x and 100x

Slicing

Plate, files, and printers

A library first

Build

zslice needs Zig 0.16. The Linux app also needs GTK 4, libsoup 3, json-glib, Meson, and a Vulkan driver.

zig build test                      # run the tests
zig build -Doptimize=ReleaseFast    # the command line tool: zig-out/bin/zslice
zig build lib -Doptimize=ReleaseFast  # libzslice.a, libzslice.so, zslice.h
zig build wasm                      # zig-out/web/zslice.wasm and zslice.mjs

The Linux app:

cd linux
meson setup build        # builds the core too (zig build lib)
ninja -C build
build/zslice-gtk part.stl

See linux/README.md for the packages.

Command line

zslice slice part.stl -m generic -f generic-petg -p fine -o part.gcode
zslice slice part.stl -o part.gcode -s project.wall_count=3 -s filament.nozzle_temp=220
zslice preview part.stl --layer 20 -o layer20.svg
zslice settings                     # all settings and their defaults
zslice profiles                     # the built-in profiles
zslice demo demo.stl                # write a test part

Settings

The settings have three groups, with different owners:

Each group can come from a profile file (TOML), with inheritance (extends) and overrides. See Profiles.

A project does not set speeds in mm/s. It sets a ratio of the speed that the machine and the filament allow. One project then works on different printers and with different filaments.

Embedding

Zig:

const zslice = @import("zslice");

var mesh = try zslice.Mesh.fromStl(gpa, stl_bytes);
defer mesh.deinit(gpa);
var settings: zslice.Settings = .{};
try settings.set("project.wall_count", "3");
const stats = try zslice.slice(gpa, &mesh, settings, writer);

C (include/zslice.h):

zs_mesh *mesh;
zs_mesh_load_stl(bytes, len, &mesh);
zs_settings *settings;
zs_settings_new(&settings);
zs_settings_set(settings, "project.wall_count", "3");
zs_slice(mesh, settings, write_callback, user_data, &stats);

JavaScript (web/zslice.mjs):

import { load } from "./zslice.mjs";
const zslice = await load(wasmBytes);
const { gcode, stats } = zslice.sliceStl(stlBytes, { "project.wall_count": 3 });

License

AGPL-3.0-or-later. See LICENSE. The sources that zslice uses, and the licenses of the code in its binaries, are in REFERENCES.md.

The screenshots show a slice of 3DBenchy by Creative Tools, licensed under CC BY-ND 4.0. The model is not in this repository.