Back when I was editing Make: Lego and Arduino Projects by John Baichtal, Matthew Beckler, and Adam Wolf, I wanted to build as many of the projects from the book as I could. But I grew impatient waiting for parts to arrive, and I realized there were two parts I was ordering the most of: Technic beams and gears.
I knew about Jason Huggins‘ Bitbeam, an open source Technic-compatible beam designed for laser cutting. Like me, Jason is a fan of OpenSCAD, “The Programmers Solid 3D CAD Modeller.” So I made some changes to Bitbeam, released the modified version on Thingiverse as MyBeam, and got to printing some beams.
But I still wanted gears, so I looked up all the ways you could generate gears and finally came up with something that was pretty close, and added it to the MyBeam thing files. But it wasn’t perfect. And in fact, I really had no idea what I was doing; I had copied and pasted random bits of open-source code, glued them together, and tweaked them until I could plug in the number of teeth I wanted — and got something that was “close enough” to stand in for a gear while I waited for parts I ordered to arrive.
Both the beams and gears are parametric, so you only need to open the files and specify what you want. For example, if you open gear-v3.scad in OpenSCAD, scroll down to this line:
// As an example, make one gear. myGear(11);
and then change the 11 to the number of teeth you want in your gear. Next, choose Design→Compile and Render, and inspect your gear in the preview window. When you’re ready to print it, choose File→Export→Export as STL (older versions of OpenSCAD: Design→Export as STL), and you’ve got a gear you can print!