OpenSCAD Tutorial
Lesson 4 · Variables and Modules
Name dimensions with variables
Hard-coded numbers are hard to change. With variables, one edit updates every place a dimension is used. That is what makes OpenSCAD models parametric.
This tray has a floor thickness thick and walls wall thick. Change width and the walls and pocket follow automatically.
OpenSCAD variables are not reassignable. Within one scope a variable has a single value for the whole script, and the last assignment wins: size = 10; cube(size); size = 20; draws a cube of size 20 and warns that size was overwritten. Think of variables as named constants. To compute a new value, give it a new name: inner = width - 2 * wall;.
Your task: make the tray 60 wide and 30 deep, with 2 mm walls, by changing only the variables.
Loading the OpenSCAD editor…
Step 10 of 16