knotflow Handbook Deutsch Lessons Modeller ↗ Source

Chapter 6

Vessels and walls

Cups, vases, pots, trays: for printing, every vessel needs a wall, equally thick everywhere, with a floor and a clean rim. This chapter shows the ways there, from the simplest to the most general.

Task Way
turned vessel (cup, pot) shell(revolve(outside), wall, open: [(0, 0, 1)]) or revolve(thicken(outside, wall))
outline pulled up (tray, box) shell(extrude(outline, h), wall, open: [(0, 0, 1)])
smooth free form (loft) shell(loft(…), wall), cut flat with between
move an outline inwards inset(outline, d), offset(curve, d)
holes in the wall perforate(shape, holes)

A wall is measured at right angles

How thick a wall is, is measured at right angles to it, not horizontally. For a slanted or curved wall that makes a difference: if you simply take 2 mm off the outer radius, the wall is thinner than 2 mm where it slants. All functions in this chapter therefore work with the offset: every point of the curve moves inwards by the wall thickness, at right angles to the curve. Why that is needed and how it is done is explained in lesson 3.3.

A cup in one line: shell

param wall = 2 in 0.8..5 "wall thickness [mm]"

let outside = chain([
  line((0, 0), (30, 0)),                              // the floor, from the axis outwards
  interpolate([(30, 0), (40, 35), (34, 80)])])        // the wall upwards

export shell(revolve(outside), wall, open: [(0, 0, 1)]) color "terracotta"

Which ends stay open is said by open: with the directions they face:

A direction no end faces is an error that names the ones there are ("its ends face (0, 0, 1)").

The example planter shows a plant pot with a set-in foot and a ledge under the rim, all from one profile and one shell.

Made yourself: thicken

thicken(curve, wall) turns a curve into a narrow, closed band: the curve, its offset beside it, joined straight at the ends. Turned, that is a cup as well:

param wall = 2 in 0.8..5 "wall thickness [mm]"

let outside = chain([
  line((0, 0), (30, 0)),
  interpolate([(30, 0), (40, 35), (34, 80)])])

export revolve(thicken(outside, wall)) color "terracotta"

The band lies to the left of the direction of travel. A profile that runs from the axis outwards and then up has the inside of the cup on its left; a negative value puts the wall outside.

Cut open: on the left with thicken, on the right with shell. The rim of thicken stands at right angles to the wall, that of shell is flat.

The difference is at the rim: thicken cuts the wall off at right angles to it, shell flat. In return, the result of thicken is a profile, an ordinary curve. You can keep working on it before turning it, for instance round its corners with fillet (chapter 8, as the example cup does).

Trays and boxes: shell with extrude

let section = rounded_rectangle(80, 50, 8)
export shell(extrude(section, 25), 2, open: [(0, 0, 1)]) color "teal"

A tray from a rectangle with round corners

Without open: you would get a closed hollow box; open: [(0, 0, 1)] leaves the top open. Inside, the corners become round where the outline bends inwards (see the example tray, with a corner cut out).

Free forms: shell with loft

A smooth surface that is closed all round also gets a wall with shell, for example a loft through curved sections. Two differences from turned profiles:

between(shape, z0, z1) solves both: it cuts a shape flat at z0 and z1. You build the loft a little longer than you need and then cut it to size. A floor is put in with union (chapter 7):

param height = 100 in 40..200 "height [mm]"
param wall   = 1.6 in 0.8..4  "wall [mm]"

// a section with six waves, at height t · height (t = 0 … 1), turned a little
fn wavy(t) = interpolate([radius(a) * (cos(a), sin(a)) | a <- range(0, 360, step: 10)], closed: true)
  |> rotate(t * 40) |> move(z: t * height)
fn radius(a) = 30 + 4 * cos(6 * a)

// from t = -0.1 to 1.1: a little longer than needed, then cut flat
let skin = loft([wavy(t) | t <- linspace(-0.1, 1.1, 7)])
let wall_only = between(shell(skin, wall), 0, height)

// the floor: the lowest section, reaching into the middle of the wall
let floor = extrude(inset(wavy(0), wall / 2), wall)

export union(wall_only, floor) color "sage"

A wavy, twisted vase with a flat rim and floor

The floor reaches about into the middle of the wall, not exactly to its inside. That way the two solids cut each other cleanly instead of only touching (chapter 7 says why that matters).

Angular lofts

A loft through polygons (polygon, polyline(…, closed: true)) has edges that twist with the loft. It gets a wall from shell too, and here open: works: without it both ends are closed, open: [(0, 0, 1)] leaves the top open; a flat floor stays at the bottom.

fn ring(t) = polygon(6, 30 * (1 - 0.3 * t)) |> rotate(t * 40) |> move(z: t * 100)

export shell(loft([ring(t) | t <- linspace(0, 1, 5)], degree: 3), 2, open: [(0, 0, 1)])

A twisted hexagonal vase, hollowed with a floor, cut open

The wall is exact to a hundredth of its thickness. If the loft twists so much that this does not work, shell says so.

Moving outlines: offset and inset

Corners stay sharp inside and become round outside, like a pen running along the curve at a fixed distance. A frame around a recess:

let outline = rounded_rectangle(60, 40, 6)
let border  = inset(outline, 3)

export difference(extrude(outline, 4), extrude(border, 4) |> move(z: 2))

Holes in the wall: perforate

perforate(shape, holes) cuts holes through a wall. Every hole is an outline that is pushed straight through the wall. For the most common case, horizontally from the axis outwards, there is radial_hole(outline, angle, height):

param height = 90  in 50..150 "height [mm]"
param radius = 35  in 20..60  "outer radius [mm]"
param wall   = 2   in 1..5    "wall [mm]"
param hole   = 4   in 2..8    "radius of the holes [mm]"

let outside = chain([line((0, 0), (radius, 0)), line((radius, 0), (radius, height))])
let cup = revolve(thicken(outside, wall))

// three rows of twelve holes, every second row turned by 15°
let rows = [20, 40, 60]
let holes = [radial_hole(circle(hole), a + 15 * (i % 2), z)
             | (i, z) <- enumerate(rows), a <- range(0, 360, step: 30)]

export perforate(cup, holes) color "blue"

A pencil cup with three rows of round holes

The example air_pot drills 874 honeycomb cells into a plant pot this way; lesson 3.5 explains how it works.

Holes, then additions, then openings

A pot with many holes, ribs and a tube is fastest in this order: join the solids and punch them with perforate, then add what is added, and last take away with difference what has to go through everything – in short (solids − cutouts) ∪ additions − openings:

param radius = 30  in 20..60  "Radius at the bottom [mm]"
param wall   = 1.6 in 1..4    "Wall [mm]"

let side = chain([line((0, 0), (radius, 0)), line((radius, 0), (radius + 5, 40))])
let pot  = revolve(thicken(side, wall))

// 1. the holes, while the pot is still smooth
let holes = [radial_hole(polygon(6, 2.5), 20 * k + 10 * (row % 2), 12 + 8 * row)
             | row <- [0 .. 2], k <- [0 .. 17]]
let punched = perforate(pot, holes)

// 2. what is added: a rib covers only the holes it touches
let rib = box(8, 1.5, 32) |> move(x: radius - 2, y: 3, z: 18)

// 3. what has to go through everything, last
let opening = cylinder((radius - 8, 3, 20), (radius + 12, 3, 20), 2)

export difference(union(punched, rib), opening) color "terracotta"

The example plant_pot builds a whole pot this way: wall, floor and tower with over 800 holes, twelve ribs, a water level tube and its bore.

Combined shapes: shell after union and difference

shell also hollows solids put together with union, difference or intersection. Each part must be made from a surface: turned, pulled up, or a closed smooth surface. A combined solid is closed all round; open: names the directions of the ends that should stay open.

let body   = revolve(polyline([(0, 0), (30, 0), (30, 80)]))
let handle = torus(20, 5) |> rotate(90, axis: (1, 0, 0)) |> move(x: 30, z: 40)

export shell(union(body, handle), 3, open: [(0, 0, 1)])

A mug and its handle hollowed together, cut open

What does not work, and what the message says

The most common messages; all of them, with their remedies, are in chapter 14.

Message what is going on remedy
the offset 6 mm leaves nothing The outline is narrower than two wall thicknesses: nothing is left inside. thinner wall or larger shape
the offset 3 mm falls apart near (15, 3) At this place the shape is narrower than two wall thicknesses (a neck, a notch); the offset would fall into two pieces. make it wider there or the wall thinner
the wall leaves nothing inside: it is thicker than the solid shell with a wall thicker than half the shape thinner wall
open: … is not the direction of an end of this shape open: names a direction no end faces take one of the directions named
a loft through smooth curves keeps its ends open … open: on a loft through curves between, a floor with union
hole 0: runs over a line where two of the combined solids meet a hole of perforate crosses where two combined solids meet (a wall joining its floor) move the hole away from that line or make it smaller; through the joint itself only difference (chapter 7)
the profile crosses itself near … The profile for revolve crosses itself, often because the wall is too thick at a tight bend thinner wall, gentler bend

Not possible yet:

More in lesson 3.8.