Introduction

OpenSCAD is an open source parametric design tool for creating solid 3D CAD objects. The application supports Constructive Solid Geometry (CSG) modeling through text commands. It is free and available for Linux/UNIX, MS Windows and Mac OS X.

OpenSCAD focuses on the CAD aspects of 3D modeling and is good for creating 3D models of machine parts or for any part where you want to specify parameters. It is not an interactive modeller. Instead it reads in statements that describe the object and it renders the 3D model from that code. This gives you full control over the modelling process and enables you to easily change any step in the process or make designs that are defined by configurable parameters.

OpenSCAD provides two main modelling techniques:
  1. Constructive Solid Geometry
  2. Extrusion of 2D outlines


Numbers in OpenSCAD are in millimeters. So circle(5); or circle(r=5); draws a circle with a radius of 5mm.
If you do not have OpenSCAD installed yet, download the latest Development Snapshot from openscad.org

When you open OpenSCAD you will see the interface:


To display the axes in the model view press Command+2 (MAC) or CTRL+2 (Windows and Linux).


Statements in OpenSCAD end with a semi-colon.
cube([10,10,20]);


OpenSCAD does not automatically indent your code, but you are encouraged to use indents for readability
difference(){
    cylinder(h = 5, r = 20);
    translate(v=[0,0,-1])
    cylinder(h = 7, r = 4);
}


To comment out a single line begin the comment with a double-slash (//)
//this is a comment

myVar=10;//this is also a single-line comment


To comment out multiple lines, begin the comment with slash-star and end the comment with star-slash:
/* This is a multi-line comment.
I started the comment on the line above.
I will complete the comment on the line below.
*/


Press F5 to render. This will show you what your model looks like in the model view


Press F6 to compile and render. This will create a model that is ready to export as an stl file:


You can use %(the Background Modifier) to ignore the subtree for the normal rendering process and draw it in transparent gray. In other words to ghost an object. This is handy when you want to see what is being differenced:


There is also * (the Disable Modifier), which will ignore the entire subtree.
difference() {
        cylinder (h = 4, r=1, center = true, $fn=100);
        *rotate ([90,0,0]) cylinder (h = 4, r=0.9, center = true, $fn=100);
}


$fn sets the resolution. This can be at the top of your file.

Here is how to set the resolution to 128.
$fn=128;


You can move the rendered object by:
  • Dragging with left mouse button to rotate the view. You can see the rotate values at the bottom of the window.
  • Dragging with the right mouse button to translate (move) the view. You can see the translate values in the bottom of the window.
  • Dragging north and south with the right mouse while holding down the SHIFT key. will zoom in and out.
  • Using the mouse scroll to zoom in and out. The Viewport line at the bottom of the window will show a change in the distance value.
  • Use the following quick key combinations to control the view:
  • If you get lost, click View>Reset View

View Options

Show Edges (CTRL/⌘+1)

If Show Edges is enabled, both OpenCSG and CGAL mode will render edges as well as faces, CGAL will even show vertices. In CGAL grid mode, this option has no effect.


Enabling this option shows the difference between OpenCSG and CGAL quite clearly: While in CGAL mode you see an edge drawn everywhere it belongs, OpenCSG will not show edges resulting from boolean operations – this is because they were never explicitly calculated but are just where one object's Z clipping begins or ends.

Show Axes (CTRL/⌘+2)

If Show Axes is enabled, the origin of the global coordinate system will be indicated by an orthogonal axes indicator. Additionally, a smaller axes indicator with axes names will be shown in the lower left corner of the viewing area. The smaller axes indicator is marked x, y, z and coloured red, green, blue respectively.

Show Crosshairs (CTRL/⌘+3)

If Show Crosshairs is enabled, the center of the viewport will be indicated by four lines pointing in the room diagonal directions of the global coordinate system. This is useful when aligning the viewing area to a particular point in the model to keep it centered on screen during rotation.

Animation

The Animate option adds an animation bar to the lower edge of the screen. As soon as FPS and Steps are set (reasonable values to begin with are 10 and 100, respectively), the current Time is incremented by 1/Steps, FPS times per second, until it reaches 1, when it wraps back to 0.

Every time Time is changed, the program is re-evaluated with the variable $t set to the current time.

To see how animate works, download spiderbot and run the main.scad files

Importing an stl file

To bring in an stl file:
  1. make sure the file is watertight.
  2. Make sure your scad file is saved and you know its path
  3. Use this syntax:
    import("path/example.stl");