OpenSCAD Tutorial

Lesson 5 · Loops and Patterns

Repeat shapes with a for loop

A for loop creates one copy of its body for every value, then unions the copies into one shape.

  • [0 : 1 : 4] is a range: start, step, end. It means 0, 1, 2, 3, 4 — the end is included. The step is optional: [0 : 4] means the same thing.
  • [0 : 10 : 40] counts by tens.
  • A list like [4, 6, 9] gives exactly those values.

Use the loop variable to compute each copy's position and size.

Your task: the loop draws three growing pillars. Change the range so it draws five (i = 0 to 4).

Lesson 5 in under a minute
Loading the OpenSCAD editor…
Step 12 of 16