OpenSCAD Cheat Sheet: Essential Commands for 3D Modeling

Published: February 21, 2026

Quick Reference Overview

This cheat sheet covers all the essential OpenSCAD commands you need for 3D modeling. Bookmark this page for quick reference while you work. New to OpenSCAD? Start with our OpenSCAD Tutorial or generate OpenSCAD code from a photo to learn from real examples.

🔲 3D Primitives

Basic 3D shapes you can create directly:

Command Description Example
cube(size) Creates a cube or box cube(10); or cube([10, 20, 5]);
sphere(r) Creates a sphere sphere(r=15); or sphere(d=30);
cylinder(h, r) Creates a cylinder or cone cylinder(h=20, r=10);
cylinder(h, r1, r2) Creates a cone/tapered cylinder cylinder(h=20, r1=15, r2=5);
polyhedron(points, faces) Creates custom 3D shape from vertices polyhedron(points=[[...]], faces=[[...]]);
// Cube with size [width, depth, height]
cube([30, 20, 10]);

// Centered cube
cube([30, 20, 10], center=true);

// Smooth sphere ($fn controls resolution)
sphere(r=10, $fn=64);

◻️ 2D Primitives

2D shapes that can be extruded into 3D:

Command Description Example
square(size) Creates a rectangle square([20, 10]);
circle(r) Creates a circle circle(r=10, $fn=64);
polygon(points) Creates custom 2D shape polygon([[0,0], [10,0], [5,10]]);
text(str) Creates 2D text text("Hello", size=10);

↕️ Extrusion (2D → 3D)

Convert 2D shapes into 3D objects:

Command Description Example
linear_extrude(height) Extrude 2D shape straight up linear_extrude(10) circle(r=5);
linear_extrude(height, twist) Extrude with rotation linear_extrude(20, twist=90) square(10);
linear_extrude(height, scale) Extrude with taper linear_extrude(20, scale=0.5) circle(10);
rotate_extrude() Spin 2D shape around Z axis rotate_extrude() translate([10,0]) circle(3);
// 3D text
linear_extrude(5)
    text("OpenSCAD", size=12, font="Arial:style=Bold");

// Twisted column
linear_extrude(50, twist=180, $fn=64)
    square([10, 10], center=true);

🔄 Transformations

Move, rotate, and scale objects:

Command Description Example
translate([x, y, z]) Move object translate([10, 0, 5]) cube(5);
rotate([x, y, z]) Rotate around axes (degrees) rotate([0, 0, 45]) cube(10);
scale([x, y, z]) Resize object scale([2, 1, 0.5]) cube(10);
mirror([x, y, z]) Mirror across plane mirror([1, 0, 0]) cube(10);
resize([x, y, z]) Resize to exact dimensions resize([20, 20, 0], auto=true) sphere(10);
color("name") Set preview color color("red") cube(10);

🔗 Boolean Operations (CSG)

Combine shapes using Constructive Solid Geometry:

Command Description Use Case
union() Combine shapes together Join multiple parts into one
difference() Subtract subsequent shapes from first Create holes, cutouts
intersection() Keep only overlapping regions Create complex shapes from overlaps
// Cube with a cylindrical hole
difference() {
    cube([20, 20, 10], center=true);
    cylinder(h=12, r=5, center=true, $fn=32);
}

// Two overlapping spheres combined
union() {
    sphere(r=10);
    translate([8, 0, 0]) sphere(r=10);
}

📦 Modules (Reusable Components)

Create reusable shapes like functions:

// Define a module
module rounded_box(size, radius) {
    minkowski() {
        cube([size[0]-radius*2, size[1]-radius*2, size[2]/2]);
        cylinder(r=radius, h=size[2]/2, $fn=32);
    }
}

// Use the module
rounded_box([30, 20, 10], 3);

🔁 Loops and Conditionals

Create patterns and conditional geometry:

// Create a row of cylinders
for (i = [0 : 5]) {
    translate([i * 15, 0, 0])
        cylinder(h=10, r=5);
}

// Circular array
for (i = [0 : 360/6 : 360]) {
    rotate([0, 0, i])
        translate([20, 0, 0])
            cylinder(h=5, r=3);
}

// Conditional geometry
if (add_hole) {
    difference() {
        cube(20);
        cylinder(h=22, r=5);
    }
} else {
    cube(20);
}

⚙️ Special Variables

Variable Description Typical Value
$fn Number of fragments (resolution) $fn=64 for smooth curves
$fa Minimum angle for fragment $fa=1 (degrees)
$fs Minimum size of fragment $fs=0.5 (mm)

Tip: Use $fn=32 for previews (fast) and $fn=128 for final renders (smooth).

⌨️ Keyboard Shortcuts

Shortcut Action
F5 Preview (fast, approximate)
F6 Render (slow, accurate)
F7 Export STL
Ctrl + D Comment/uncomment line
Ctrl + Shift + V View all (reset camera)

💡 Pro Tips

  • Debugging: Use % prefix to make a shape transparent, # to highlight it
  • Performance: Keep $fn low during development, increase for final render
  • Reusability: Use modules for repeated elements, variables for dimensions
  • Organization: Comment your code, group related operations
  • Starting point: Generate OpenSCAD from photos to get working code fast

Skip the Blank Page

Instead of starting from scratch, generate OpenSCAD code from a photo. Get a working starting point you can modify using the commands from this cheat sheet.

Generate OpenSCAD from Photo

📚 Related Articles

Connection Lost

Please reload the page to continue.