A small rewrite of Andrew Sweet's excellent Lego bricks, into a callable module for easier integration with other objects. It also adds support for "flat" bricks (no pegs on top). Some parameter names have been changed, see scad file for details and usage examples.
Just put lego.scad in your OpenSCAD libraries folder (location varies with OS, but on my Mac it's ~/Documents/OpenSCAD/libraries/), or just in the same folder as your project.
Include it with
and then make a brick with something like
See the scad file for details on parameters and more usage examples.