Upload
john-oliva
View
76
Download
4
Embed Size (px)
Citation preview
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
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
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)
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
Installation
● www.openscad.org/downloads.html
● Latest stable releases○ Mac OS X: 2015.03-3○ Windows: 2015.03-2○ Linux: 2015.03-2
● Much more recent development snapshots
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
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
Concepts - Transforms
● Translate
● Scale
● Rotate
● Mirror
● Color
● Others: resize, multmatrix, offset, hull, minkowski
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
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
Concepts - Surface
● Creates a 3D object from:
○ height map data file
○ PNG image where grayscale indicates height
○ Can be used to create a lithophane
Language - Types
● No declaration required
● Numbers (integer, floating point)
● Boolean (true/false)
● String
● Vector
● Undefined (undef)
Language - Variables
● variable_name = expression
● Variable values at calculated at compile-time, not run-time
● Special variables - start with $○ $fa minimum angle○ $fs minimum size○ $fn minimum # of fragments○ $t animation step○ Others: $vpr, $vpt, $vpd
Language - Operators
● arithmetic: *, /, +, -, %
● relational: <, >, <=, >=, ==, !=
● logical: &&, ||, !
● conditional: exp ? val1 : val2
● vector: +, -
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);
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) { … }
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);
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 }
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
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