+49 831 5701 5286

OpenSCAD – Program 3D parts!


OpenSCAD is a really great program for creating 3D parts. These features stand out in particular:

  1. First, you create highly complex geometries with a few lines of text.
  2. Second, you can make the parts parameterizable. That means you make a template and then by changing your variables the whole part changes.
  3. Finally, OpenSCAD is wonderfully suited for applications such as 3D printing, as formats such as STL, AMF can be exported. There is even a direct interface to OctoPrint in version 2021.01!
  4. You can find great libraries on the OpenSCAD website. For example, for the parameterized creation of screws and housings.
  5. In addition, the software can be used commercially or privately free of charge. The open source software is provided under a GNU GPL license.
Startseite » Ideas blog » 3D » design » OpenSCAD – Program 3D parts!

How does OpenSCAD work?

When you open the program for the first time and open a new file, you will see two main areas of the program.

OpenSCAD areas
  1. Here you can see the editor. Here you will enter your code later. Thereby this code describes e.g. circles, rectangles and extrusions from them. An extrusion is nothing more than a closed 2D shape that is pulled into the third dimension. For example, extruding a circle creates a cylinder.
  2. You will also see the preview window. There, after each save or render, the part is shown. You can also move it there with the mouse functions, rotate it or zoom in and out.

Create OpenSCAD basic shapes

Now we will show you how to create simple basic shapes in OpenSCAD.

Create cuboid with two lines of code

Create OpenSCAD cuboid
This is how you can create a cuboid in OpenSCAD.

First, let’s create a cuboid with two lines of code! In the first line we say that our extrusion should have a depth of 40 mm. In the second line we create a rectangle with side lengths of 20 mm and 10 mm. By setting “center = true” we center the rectangle around the origin. Make sure that there is no semicolon after the first line. Only after the second line you use the semicolon. Why is that? Since the extrusion refers to the rectangle, no semicolon must be placed between extrusion and rectangle here. After that, the command is over. That is why the separator is set.

square([20, 10], center = true);

Furthermore, for the cuboid there is the possibility of creation with only one line of code. Via the cube command with the width, depth and height parameters as well as the centering. When centering, the cuboid is centered in all directions.

cube([20,10,40], center=true);

Create cylinder with two lines of code

Create cylinder in OpenSCAD
So you can create a cylinder with 2 lines of code.

Next, we create a cylinder in OpenSCAD. The principle corresponds to that of the cuboid. Only this time we take a circle as the basic shape. Also, the centering option is eliminated because the circle automatically gets the center on the origin. Thus, in the example, we obtain a cylinder with the radius of 20 mm and a depth of 40 mm.


For a cylinder there is also the possibility in OpenSCAD to use only one line of code. The first parameter describes the height or depth, the second the radius and the third centers the cylinder.


OpenSCAD – Create complex shapes

To be able to create complex shapes yourself, you should have understood the basic shapes. Now we will create a third shape from two simple shapes. After that we will show you a spiral extrusion. We can recommend the cheat sheet for the functions here.

Create plate with hole

Now we create a plate with a hole in the middle.

Plate with hole in OpenSCAD
Creating a plate with a hole in OpenSCAD is relatively simple.

For this we use the functions for the cube and the cylinder. Here we create the plate using the cube function and the hole using the cylinder function. Then we put both forms terminated with semicolons into the function difference. Thus, the second mold is removed from the first mold and we get the plate with the hole in the middle.

difference() {
    cube([40,30,10], center=true);

Create spiral in OpenSCAD

Finally, we will show you how easy it is to create a beautiful spiral shape in OpenSCAD. Also, this time we color our part red.

OpenSCAD Spiral
Create a spiral in OpenSCAD.

To get our spiral shape we use a rectangle as 2D shape in the last line. In the line above, we drag the shape upwards and rotate it by -360° using the twist parameter. If we were to omit the minus sign from the angle, we would simply rotate in the other direction. Then we use the scale parameter to scale down to 0 while dragging the shape upwards. Then we set the precision or the number of slices with the slices parameter. The coloring is achieved by the color command.

linear_extrude(height = 30, twist = -360,scale=0,slices=500)
square([20, 10], center = true);

A really nice shape and that only in 3 lines of code! We are really excited!

Export 3D parts

To use your created 3D part for subsequent steps you can export it in different formats. For example, the STL or AMF format for a slice process such as with PrusaSlicer. The export function can be found under File->Export.

Export function in OpenSCAD
You can export to these formats in OpenSCAD.

OpenSCAD is whacky!

In summary, it can be said that this open source program offers a very different approach than most CAD programs. Great geometries can be created with just a few lines of code. Getting started with the program is relatively quick and playful.

However, the operation is more suitable for people who like to approach a 3D part with the help of code. In addition, through a series of libraries prefabricated parts are customizable to your own ideas.

If you are interested in a more graphical interface we can recommend the articles about FreeCAD (OpenSource) and Onshape (proprietary).


Leave a Reply