Directories in OpenSCAD
Here’s the translation of the Go code example to OpenSCAD, formatted in Markdown suitable for Hugo:
Our first program will create a simple 3D model using OpenSCAD. Here’s the full source code:
To run this OpenSCAD script:
- Save the code in a file with a
.scad
extension, for example,hello_openscad.scad
. - Open the file in the OpenSCAD application.
- Click on “Compile and Render” (F6) to see the 3D model.
- The console output can be seen in the console window, usually at the bottom of the application.
OpenSCAD doesn’t have a traditional “hello world” text output, as it’s primarily used for creating 3D models. However, we can use the echo()
function to output messages to the console.
When you run this script, you’ll see a 3D scene with three objects:
- A cylinder in the center
- A cube to the right of the cylinder
- A sphere to the left of the cylinder
In the console, you’ll see the message:
This demonstrates basic shape creation, positioning, and console output in OpenSCAD.
OpenSCAD doesn’t have a build process like compiled languages. Instead, you typically work with .scad
files directly in the OpenSCAD application, and export to various 3D file formats (like STL) when you need to use the model in other applications or for 3D printing.
Now that we can create basic OpenSCAD models and use console output, let’s explore more features of the language.