| name | openscad-language |
| description | Write and edit OpenSCAD code for parametric 3D modeling. OpenSCAD language reference including primitives, transforms, boolean operations, modules, functions, and best practices. Use when creating .scad files, editing OpenSCAD code, or doing parametric/programmatic CAD. |
OpenSCAD Language Reference
OpenSCAD is a script-based 3D CAD modeler. Models are defined programmatically — there is no interactive GUI modeling. Files use the .scad extension.
Core Concepts
- OpenSCAD is declarative — you describe geometry, not steps
- Everything is either a 2D shape, a 3D solid, a transformation, or a boolean operation
- The final geometry is whatever is in the top-level scope (not inside a module)
- Use
$fn to control facet count (smoothness) for curved surfaces
3D Primitives
cube([x, y, z], center = true);
sphere(r = 5); // or sphere(d = 10);
cylinder(h = 10, r = 5); // or r1, r2 for cone
cylinder(h = 10, r1 = 5, r2 = 0); // cone
2D Primitives (for extrusion)
circle(r = 5);
square([10, 20], center = true);
polygon(points = [[0,0], [10,0], [5,10]]);
text("Hello", size = 10);
Extrusions (2D to 3D)
linear_extrude(height = 10) circle(r = 5); // cylinder
linear_extrude(height = 10, twist = 90) square([10, 2], center = true);
rotate_extrude() translate([10, 0]) circle(r = 3); // torus
Transformations
translate([x, y, z]) child();
rotate([rx, ry, rz]) child(); // degrees around each axis
scale([sx, sy, sz]) child();
mirror([1, 0, 0]) child(); // mirror across YZ plane
color("red") child();
color([0.5, 0.5, 0.5, 0.8]) child(); // RGBA