OpenSCAD CheatSheet
OpenSCAD CheatSheet
OpenSCAD
SCAD v2021.01
Syntax Modifier Characters Lists Functions
var = value; * disable list = […, …, …]; create a list concat
var = cond ? value_if_true : value_if_false; ! show only var = list[2]; index a list (from 0) lookup
var = function (x) x + x; # highlight / debug var = list.z; dot notation indexing (x/y/z) str
module name(…) { … } % transparent / background chr
name(); ord
function name(…) = … Boolean operations search
name();
include <….scad>
2D union() version
circle(radius | d=diameter) difference() version_num
use <….scad>
square(size,center) intersection() parent_module(idx)
square([width,height],center)
Constants polygon([points])
List Comprehensions Mathematical
undef undefined value polygon([points],[paths])
Generate [ for (i = range|list) i ] abs
PI mathematical constant π (~3.14159) text(t, size, font,
halign, valign, spacing, Generate [ for (init;condition;next) i ] sign
direction, language, script) Flatten [ each i ] sin
import("….ext", convexity) Conditions [ for (i = …) if (condition(i)) i ] cos
Operators
projection(cut) Conditions [ for (i = …) if (condition(i)) x else y ] tan
n + m Addition
Assignments [ for (i = …) let (assignments) a ] acos
n - m Subtraction
asin
n * m Multiplication 3D
atan
n / m Division sphere(radius | d=diameter) Flow Control
atan2
n % m Modulo cube(size, center) for (i = [start:end]) { … }
floor
n ^ m Exponentiation cube([width,depth,height], center) for (i = [start:step:end]) { … }
round
n < m Less Than cylinder(h,r|d,center) for (i = […,…,…]) { … }
ceil
n <= m Less or Equal cylinder(h,r1|d1,r2|d2,center) for (i = …, j = …, …) { … }
ln
b == c Equal polyhedron(points, faces, convexity) intersection_for(i = [start:end]) { … }
len
b != c Not Equal import("….ext", convexity) intersection_for(i = [start:step:end]) { … }
let
n >= m Greater or Equal linear_extrude(height,center,convexity,twist,slices) intersection_for(i = […,…,…]) { … }
log
n > m Greater Than rotate_extrude(angle,convexity) if (…) { … }
pow
b && c Logical And surface(file = "….ext",center,convexity) let (…) { … }
sqrt
b || c Logical Or
exp
!b Negation Transformations Type test functions rands
translate([x,y,z]) is_undef min
rotate([x,y,z]) is_bool max
Special variables is_num
rotate(a, [x,y,z]) norm
$fa minimum angle scale([x,y,z]) is_string cross
$fs minimum size resize([x,y,z],auto,convexity) is_list
$fn number of fragments mirror([x,y,z]) is_function
$t animation step multmatrix(m)
$vpr viewport rotation angles in degrees color("colorname",alpha)
$vpt viewport translation
Other
color("#hexvalue") echo(…)
$vpd viewport camera distance color([r,g,b,a]) render(convexity)
$vpf viewport camera field of view offset(r|delta,chamfer) children([idx])
$children number of module children hull() assert(condition, message)
$preview true in F5 preview, false for F6 minkowski(convexity) assign (…) { … }
Links: Official website | Code | Issues | Manual | MCAD library | Mailing list | Other links
Edit me on GitHub!
By Peter Uithoven @ Fablab Amersfoort (CC-BY)