knotflow Handbook Deutsch Lessons Modeller ↗ Source

Chapter 1

Getting started

knotflow describes a model as text: a few lines that say what it is made of and what its sizes depend on. Change a number, and the whole model is made anew. The result is a file for the 3D printer (STL or 3MF) or a picture.

This chapter shows the way from the first model to the file for the printer. Some programming experience helps, but is not needed.

In the browser

The quickest way needs no installation: fliegendreck.codefloe.page/knotflow.

A model of your own is started under Project → Open folder … (Chrome and Edge): the browser then reads and writes the .kf files directly in that folder. So you can work on them in another editor at the same time. Other browsers have Download as ZIP.

The first model

// A twisted vase of hexagons
param height = 120 in 40..300 "height [mm]"
param radius = 40  in 20..100 "radius [mm]"
param twist  = 60  in 0..180  "twist at the top [°]"

fn ring(t) = polygon(6, radius * (1 - 0.3 * t)) |> rotate(t * twist) |> move(z: t * height)

export loft([ring(t) | t <- linspace(0, 1, 8)], degree: 3)

Line by line:

All sizes are millimetres, all angles degrees.

Errors

An error is underlined red in the text; below it stands what is wrong, usually with a hint how it was meant. Write x ** 2 as in Python, for instance, and knotflow says: "powers are written with ^: 2 ^ 3". The messages are in English, like the names of the functions.

On your own computer

Everything the browser does, kf, the command-line program, does as well:

kf render vase.kf -o vase.stl

It is worth it if you want to work in your own editor, compute many models at once or teach the language to an AI assistant. Chapter 2 shows how to install kf and everything it can do.

What comes next

If you want to understand how knotflow works inside (NURBS, the interpreter, Boolean operations), you will find it in the lessons.