Hello World in OpenSCAD

Our first program will print the classic “hello world” message. Here’s the full source code.

echo("hello world");

To run the program, save the code in a file with a .scad extension and open it in OpenSCAD, then press F5 or click the “Preview” button.

Sometimes we’ll want to save our program into an STL file for 3D printing. We can do this using the “Export” feature.

First, preview the design to ensure it is correct:

# No command-line equivalent; perform in the OpenSCAD UI by clicking "Preview"

Next, export the STL file:

# No command-line equivalent; perform in the OpenSCAD UI by clicking "Export as STL"

# You'll then see:
# hello-world.stl

We can then use this STL file with a 3D printer or 3D printer software.

Now that we can run and build basic OpenSCAD scripts, let’s learn more about the language.