Learn OPENSCAD-MACROS with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
1
Parametric Bolt Module
module bolt(length=20, radius=3) {
cylinder(h=length, r=radius);
sphere(r=radius*1.2);
}
// Example usage
bolt(30, 4);
translate([0,10,0]) bolt(15, 2.5);
An OpenSCAD macro (module) that generates a simple parametric bolt with customizable shaft length and radius.
2
Gear Generator Macro
module gear(teeth=12, radius=20, thickness=5) {
for (i = [0:teeth-1]) {
rotate(i*360/teeth)
square([2, radius], center=true);
}
extrude(height=thickness)
circle(r=radius);
}
// Example usage
gear(16, 25, 8);
A simplified gear macro to generate a 2D gear profile extruded into 3D.