OpenSCAD CheatSheet

3D
Primitives

cube(); cube(size); cube(size, center); cube([width, height, depth]); cube([width, height, depth], center); cylinder(); cylinder(height); cylinder(height, radius); cylinder(height, radius, center); cylinder(height, bottom_radius, top_radius); cylinder(height, bottom_radius, top_radius, center); sphere(); sphere(radius); polyhedron([[x, y, z],…], [[p1, p2, p3,…],…]); polyhedron([[x, y, z],…], [[p1, p2, p3,…],…], convexity);

Mathematical
Functions

abs(value); ceil(value); exp(value); floor(value); ln(value); len([v1, v2, v3,…]); log(value); lookup(lookup_key, [[key, value],…]); max(value, value); min(value, value); norm([v1, v2, v3,…]); pow(base, exponent); rands(minimum, maximum, number_of_returns); rands(minimum, maximum, number_of_returns, seed); round(value); sign(value); sqrt(value); cross([v1, v2, v3], [v1, v2, v3], …);

2D
Primitives

square(); square(size); square(size, center); square([width, height]); square([width, height], center); circle(); circle(radius); polygon([[x, y],…], [[p1, p2, p3, …],…]); polygon([[x, y],…], [[p1, p2, p3, …],…], convexity);

String
Functions

len("value"); str("value", value, [v1, v2, v3,…],…); search("match", "value"); search("match", "value", returns_per_match); search("match", "value", returns_per_match, index_column);

Special
Variables

$fa  Min fragment angle $fs  Min fragment size $fn  # of fragments $t   Animation step $vpr Viewport rotation $vpt Viewport translation $vpd Viewport camera distance $children # of child nodes in a module $parent_modules # of modules in the stack

Import
Functions

import("filename"); include <filename>; use <filename>; dxf_dim(file, layer, name, [origin_x, origin_y], scale); dxf_cross(file, layer, [origin_x, origin_y], scale); surface(file, center, invert, convexity);

Modifier
Characters

% Background # Debug ! Root * Disable

CSG
Modeling

union() {} difference() {} intersection() {} render(convexity) {}

Transformation
Functions

scale([x, y, z]); resize([x, y, z]); rotate([x, y, z]); rotate(degree, [x, y, z]); translate([x, y, z]); mirror([x, y, z]); multmatrix(m = []) {} color("name"); color([red, green, blue, alpha]); projection() {} projection(cut) {} minkowski() {} hull() {}

Trigonometric
Functions

cos(degrees); sin(degrees); tan(degrees); acos(radians); asin(radians); atan(radians); atan2(radians);

Arithmetical
Operators

+ Add - Subtract * Multiply / Divide % Modulo

Other
Operators

= Assignment ; End of Statement

Relational
Operators

Less than <= Less equal == Equal != Not equal >= Greater equal Greater than

Logical
Operators

&& Logical AND || Logical OR Logical NOT

Code Readability
and Re-Use

module name() {} function name() =;

Other
Functions

echo("value"); version(); version_num(); children(); children(value); children([v1, v2, v3]); children([start : end]); children([start : increment : end]); concat();
OpenSCAD CheatSheet by Kay Anar. Copyright © 2014 Anar Software LLC - All Rights Reserved.