OpenSCAD For Loop Grid example

OpenSCAD examples
/

For Loop Grid

Beginner

Profiles & patterns

Lesson 7 of 22

Generate many related solids from two loop variables and a height formula.

Try changing:

columnsrowsspacingradiusrise

Low compile complexity. Cost grows with rows × columns × facet count.

How this model works

OpenSCAD ranges include both endpoints, so [0 : columns - 1] produces exactly columns positions. Each height depends on both X and Y indices. These pillars are intentionally disconnected: STL can contain multiple shells, and that alone is not a compiler failure.

main.scad

Loading draft

Ctrl/Cmd+Enter or F5: preview · F6: render · Ctrl/Cmd+F: search · Ctrl+Space: complete · Tab: leave editor

0 messages

Make it your own

Change the height formula from x + y to abs(x - y). Add a thin base under the grid if you want one connected object.

Change one parameter at a time and inspect the result. Use the workspace reset action to return to this lesson’s original model.

FAQ