2. Intro
What is OpenSCAD?
● 3D modeling program based on constructive solid
geometry
● Dynamically typed language
● Open Source: https://github.com/openscad/openscad
● Windows, Mac OS X, Linux (14 - 23 MB), web app
(openscad.net)
● GUI or CLI usage
3. Intro
Why OpenSCAD?
● Free to obtain and for commercial use
● Parametric - easy to adjust object to customize use
● Simple language
● Large amount of existing code freely available (Github,
Thingiverse, etc.)
● Large user community
● Well established - been around since 2010
● Produces solid, watertight 3D objects
● Good online documentation
4. Intro
Differentiators from other 3D CAD?
● Declarative, procedure oriented programming
● Interactive design - but not by interacting directly with
rendered model on screen
● Customizers
○ Thingiverse
○ Built into development version of OpenSCAD
● Computational generation of shapes (e.g. fractal shaped
object)
5. Resources
● www.openscad.org
● cheatsheet: www.openscad.org/cheatsheet
● manual: en.wikibooks.org/wiki/OpenSCAD_User_Manual
● Libraries
○ OpenSCAD general library of relativity
■ github.com/davidson16807/relativity.scad/wiki
■ www.thingiverse.com/thing:349943
○ MCAD library
■ github.com/openscad/MCAD
■ Lots of resources for mechanical design
● Alternative language interfaces
○ SolidPython: github.com/SolidCode/SolidPython
○ OpenJSCAD: openjscad.org
● Web based OpenSCAD: openscad.net
7. Quick GUI Overview
● Preview/Render pane
● Code pane
○ detachable
○ supports external editor (Design->Automatic Reload and Preview)
● Console pane
○ detachable
● Customizer pane
○ detachable
○ not currently available in stables releases
8. Workflow
● Iterate (until happy with design)
○ Write OpenSCAD code
○ Preview using F5 (generates CSG representation for OpenGL
rendering)
● Render to full geometry using F6 (generates CGAL
representation, surfaces, edges, vertices)
● Export to a format for import into subsequent tool
○ e.g. STL for import into siicer
○ export formats: STL, OFF, AMF, DXF, SVG, CSG, PNG
9. Concepts - 2D Shapes
● Circle
● Square (actually rectangle)
● Polygon
● Text
12. Concepts - Boolean Operations
● Union
○ combines multiple shapes into a single object
● Difference
○ removes/subtracts second and remaining shapes from the first
shape
● Intersection
○ leaves the parts that are common to all of the shapes included
13. Concepts - Extrusions
● Linear
○ extends a 2D object in the X/Y plane in the Z direction
● Rotational
○ rotates a 2D object defined in the X/Y plane around the Z axis
14. Concepts - Surface
● Creates a 3D object from:
○ height map data file
○ PNG image where grayscale indicates height
○ Can be used to create a lithophane
21. Language - List Comprehensions
● Used to generate a list
● Examples
○ Squares: squares = [ for(i=[0:10]) i*i ]; echo (squares);
○ Divisible by 3: div3 = [ for(i=[0:20]) if (i%3 == 0) i ]; echo (div3);
22. Language - Modules
● Operates like a subroutine in other languages and does
not return a value
● Most often used for constructing higher order 2D or 3D
objects from simpler ones
● Format: module name (comma_sep_param_list) { … }
23. Language - Functions
● Operates like a function in other languages although
defined as a single expression returning a value
● Most often used for constructing higher order 2D or 3D
objects from simpler ones
● Format: function name (params) = expression yielding a
value
● Example - Factorial
function factorial(n) = ( n==1 ? 1 : n * factorial(n-1) );
fact=factorial(10);
echo(fact=fact);
24. Language - Looping
● Often used to create multiple instances of objects
parameterized by the loop variable
● Format
○ for (var = [start:end]) { actions }
○ for (var = [start:step:end]) { actions }
26. Language - Math Functions
● abs, sign, sin, cos, tan, acos, asin, atan, atan2, floor, round,
ceil, ln, len, let, log, pow, sqrt, exp, rands, min, max
27. Language - Libraries
● include <filename>
○ inserts contents of file at that point in the including file
○ included file is OpenSCAD formatted
○ modules and functions are defined
○ commands are executed
● use <filename>
○ modules and functions are defined
○ included file is OpenSCAD formatted
○ NO commands are executed
● import <STL/OFF/DXF file>
○ imports and renders file