knotflow Handbook Deutsch Lessons Modeller ↗ Source

Chapter 13

Printing

A model in knotflow is exact: circles are circles, surfaces are smooth. A printer knows nothing of that. Most home printers work with FDM (fused deposition modeling): a hot nozzle lays down molten plastic track by track, layer by layer, from the bottom up. Which tracks those are is worked out by the slicer, a program that cuts the file of triangles into layers and plans the nozzle's path for each layer.

This chapter shows what matters on the way: closed solids, the tolerance, STL or 3MF, how a part lies on the print bed, splitting large parts, and some rules that make a print succeed.

Closed solids

A slicer has to know for every point whether it lies inside or outside. That only works if the triangles form a hull without gaps: every edge between exactly two triangles, all facing out. That is called a closed solid. Slicers often say manifold (at every edge exactly two faces, nowhere a hole or a third face) or "watertight".

kf render checks it on every run:

edges: 72 – open 0, more than two triangles 0, flipped 0  →  closed solid ✓
parts: 4

In the browser the status line warns when the STL is not closed: "· 66 open edges"; the tooltip says why, and gives the 3MF where it differs. Copies (instance) that stand apart the modeller checks once by their shape; if there would still be more than 2 million triangles to read, the status line says "· STL not checked" – then kf render checks the file. Where does an open solid come from?

export extrude(arc(20, 0, 180), 10)

An arc is an open curve. Pulled up, it gives a bent sheet without thickness, and kf render reports NOT a closed solid ✗. A wall needs a thickness:

export extrude(thicken(arc(20, 0, 180), 1.2), 10)

thicken makes a closed outline of the curve, 1.2 mm wide (chapter 6). Closed curves, revolve of a profile reaching the axis and loft through closed sections give closed solids by themselves; open ends get flat lids. Boolean operations on closed solids give closed ones again as long as the parts clearly cut each other; where they only touch along an edge or at a point, they do not (chapter 7, "Rules that save trouble").

kf check file.stl checks an STL the same way, also one from another program, binary or ASCII.

Units

knotflow computes in millimetres. An STL file has no unit; slicers assume millimetres, which fits. If a model appears 25 times too small in the slicer, it assumed inches; change the unit when importing. 3MF writes the unit into the file.

The tolerance

For the file, the exact surfaces are cut into triangles. The tolerance is the largest deviation of the triangles from the exact surface. A ball of radius 20 mm:

tolerance triangles STL
0.2 mm 1,088 54 KB
0.05 mm 3,968 0.2 MB
0.01 mm 48,640 2.4 MB

For organic forms (chapter 12) it is not the tolerance that decides but voxel and simplify.

Preview and exact computation

In the browser the view should follow your typing and dragging. If the exact model would take too long (more than about 2 seconds, while dragging a slider more than 0.15 s), it shows a preview: tolerance at least 0.1 mm, voxels twice as large, no simplify. The status line then says "· preview"; a click on it computes the exact model.

save STL and save 3MF always compute exactly, even when the view is showing a preview. On the command line the preview is --draft, for quick trials; kf then warns that the file is not meant for printing.

STL or 3MF

STL 3MF
content only triangles triangles, objects, colours, unit
several exports one heap of triangles one object each, in its colour
copies with instance every copy in full the shape once, the copies as references
size large usually a quarter to a fifth, much less with many copies
read by every slicer the common slicers

The chain with 46 links is 58 MB as STL, 0.26 MB as 3MF. For multi-colour prints 3MF is the way: every export with a colour of its own becomes an object of its own, to which you assign a filament in the slicer. The colour from color is only the display colour; which filament is printed is set in the slicer. An example with two colours is name_tag.

kf render name_tag.kf -o name_tag.3mf

How the part lies on the print bed

The slicer puts the model on the print bed with its lowest point. Which side is at the bottom is up to the model. A part lies well with a large flat side at the bottom and as little overhang above it as possible. A pin lying down touches the bed only along a line; standing up, a whole circle rests on it:

let pin = cylinder((0, 0, 0), (60, 0, 0), 8)

export pin |> rotate(-90, axis: (0, 1, 0))

rotate(shape, angle, axis:) turns around an axis through the origin; here the x axis becomes the z axis. You can also turn a part in the slicer. In the model, though, the position is kept, and several parts lie right next to each other.

It also pays to think of strength: the layers stick to each other less well than a track holds together. A hook that has to carry load therefore lies better flat, so that its bend runs along the tracks and not across the layers.

Splitting large parts

What is larger than the print bed, or would only print with many supports, is printed in parts. A sphere, say, in two halves, each with its cut face down:

param r = 40 in 20..80 "radius [mm]"

let ball  = sphere(r)
let north = between(ball, 0, r + 1)
let south = between(ball, -r - 1, 0) |> rotate(180, axis: (1, 0, 0))

export [north |> move(x: -r - 5), south |> move(x: r + 5)]

Rules of thumb for printing

The values are for common FDM printers with a 0.4 mm nozzle. It is best to make each of them a param; then you adjust it without touching the model.

Wall thickness. At least two nozzle widths, that is 0.8 mm, better 1.2 mm or more. Slicers often simply leave out thinner walls.

Overhangs. What hangs over by more than about 45° from the vertical needs supports. A profile with a slope instead of a horizontal edge prints without. The rings in fidget_rings are shells of a ball, cut flat at the top and bottom: that keeps the overhang of their surfaces below 45°, and they print in one piece without supports.

Gaps between moving parts. Parts that are to move need 0.2 to 0.5 mm of play, depending on the printer. fidget_rings has gap for this, with the hint "larger if they stick". The quickest way to the right value is a small series:

for g in 0.25 0.35 0.45; do kf render fidget_rings.kf -D gap=$g -o fidget-$g.stl; done

Holes. Printed holes come out a little narrower than drawn. For screws or axles add 0.1 to 0.2 mm to the radius.

Fine details. Letters need strokes at least about 1 mm wide and 0.6 mm high; for engravings the same holds for the depth.

A flat underside. Something with a round underside touches the print bed in a single point. between(shape, z0, z1) cuts a shape off horizontally:

export between(sphere(20), -14, 20) |> move(z: 14)

Catching impossible values. With assert the model itself says when a combination of parameters cannot be printed:

param wall   = 1.2 in 0.2..3 "wall thickness [mm]"
param nozzle = 0.4 in 0.2..1 "nozzle [mm]"

let checked = assert(wall >= 2 * nozzle, "the wall needs at least two nozzle widths: make wall larger")

export shell(cylinder((0, 0, 0), (0, 0, 40), 20), wall, open: [(0, 0, 1)])

assert(condition, message) stops the computation with the message if the condition does not hold. With -D wall=0.5, kf render reports the error at this line. In the browser the message appears below the slider, with a button "back to …" to the last value that worked. fidget_rings checks in this way whether every ring holds in the next one.

Further reading

How surfaces become triangles and why a solid has to be closed: lesson 1.3. The preview: lesson 4.3. What is in a 3MF file: lesson 4.6.