Fancy Bricks OpenSCAD Lego Brick Builder

by kresty, published

Fancy Bricks OpenSCAD Lego Brick Builder by kresty Dec 6, 2013


Liked By

View All

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag


Thing Statistics

10413Views 3906Downloads Found in Construction Toys


Updates, cylinders weren't connected and some of the fudge factors were off when I started "production" for L3-G0... Values now work well for ABS on my Flashforge version of Replicator.

Need a Lego compatible brick with studs on 6 sides?

FancyBricks is yet another OpenSCAD module to make Lego brick
compatible shapes. I needed to do some things that some of the other things don't do, like fractional bricks. Also some of the other modules weren't playing well with my actual Lego bricks after I printed them! I'm building special bricks for my Lego R2-D2 (L3-G0 has a Blog and Youtube channel.

I'm also building another couple modules off of this for angles and other cool shapes that'll be posted in a bit.

Tagged "work-in-progress" because you might need to tweak the fudge factors for your printer, however I'm not sure I'll expand it. Also the cylinders are work fine, but my printer doesn't print them in a very optimized fashion, not sure if it's the slicer or what.


Though I included a couple .stl files, FancyBricks is intended for you make your own "special" brick using OpenSCAD. It's fairly easy to do your own thing, and if you forget, there're comments in the fancybricks.scad file.

I've noticed that different materials (PLA/ABS) seem to have different tolerances, so you may need to play with the "fudge" factor to get a good fit. Bump up STUDDIAMETER if the studs are loose in a real Lego brick. Bump up WALLWIDTH if a real Lego brick is loose when plugged into the bottom of a FancyBrick.

My printers seem to have a little roughness. I print them with a raft if they have tubes on the bottom (my plate isn't apparently sticky enough otherwise). Then I press them onto a real Lego brick to get them to fit. Once that's done, I try fitting my bricks together.

Skip the first steps if you've played with OpenSCAD and know how libraries behave.

  1. Get OpenSCAD if you don't have it already, http://www.openscad.org/
  2. Copy fancybricks.scad to some folder on your machine.
  3. Either use a real library location, or to KISS, just make a new document and save it in the same folder as fancybricks.scad. (or just look at one of the other scad files).
  4. Enter something like this into your OpenSCAD script (on the left)
    use <fancybricks.scad>
  5. Press F5 (Design->Compile). You'll see your normal 3x5 brick 6 plates (2 bricks) tall!
  6. To make OpenSCAD create an STL file, you have to render it first, press F6 (Design->Compile and Render)
  7. Design->Export the STL.

Sometimes its easier to see your brick's shape if you turn on the edges, View->Show Edges.

brick() takes a ton of different parameters. The normal ones are length, width and height, in Lego studs for length/width and plates for height. 1,1,3 creates a "normal" 1x1x1 brick.

brick() is most useful for making more interesting shapes, such as when you need to plug things together in strange ways or parts are misaligned by a 1/2 brick and so on.

Lego blocks aren't exactly their specified size, they're a little smaller so that they can fit next to each other without too much pressure. Additionally different printers behave differently, so you may need to tweak the constants in the library for your needs.

ANTISNUG makes the brick a tiny bit narrower so that 2 bricks side-by-side might have a chance of fitting. If you're bricks are too "tight" sideways, try increasing that.

STUDSANTISNUG makes the studs a tiny bit skinnier for similar reasons. If your studs don't fit in other bricks, try bumping that up a tad (or dropping it if they're loose).
The other dimensions are also exposed, but hopefully you don't have to tweak them too much.

I try to make them "fit" in a normal Lego brick. If that works, they'll probably snap together. My printer is course enough that I need to work them a little to get them to behave, and, of course, they're not as precise as a real Lego brick, but they seem to get the job done.


In addition to making really strange sizes, you can put studs on any face (though I'm not gonna claim you can print them very well, my SquareStudBox almost works on my printer. You can also remove the studs from the top. (studs & studsFront/Back/Left/Right/Bottom booleans)

Particularly for odd sizes, you can chose where the studs are centered or shoved to one side. You can also pick if partial studs should be included. (Often partial studs are too skinny to be useful, but sometimes they might be interesting). (partialStuds and centerStuds parameters)

Your brick can also have a flat bottom if you want. Or maybe you just want to get rid of the tubes for some reason, you can do that too. (hollow and tubes).

From the library:

// length: "x" size in Lego studs (default 4)
// width: "y" size in Lego studs (think width of 1x1 brick) (default 2)
// height: "z" size in Lego plates (brick is 3, plate/tile are 1) (default 3)
// center: true if you want it centered (excluding studs)
// studs: false if you don't want studs on top (default true)
// tubes: false if you don't want tubes/pins on bottom (default true)
// studsFront: true if you want studs on the front (default false)
// studsBack: true if you want studs on the back (default false)
// studsLeft: true if you want studs on the left (default false)
// studsRight: true if you want studs on the right (default false)
// studsBottom: true if you want studs on then bottom (default false)
// partialStuds:true if you want studs overhanging non-even bricks. (default false)
// centerStuds: false if you don't want studs centered (default true)
// hollow: false if you don't want open bottom w/tubes (default true)

And don't forget to visit L3-G0 the Lego R2-D2's blog or Youtube channel. The gears I'm building are intended for his motorized feet....

More from Construction Toys

view more

All Apps

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Quickly Scale, Mirror or Cut your 3D Models

App Info Launch App

I've made an oops and the cylinders aren't completely connected to the brick it looks like, I'll fix that in a bit...

I expect to have some fancy bricks (like the one on the right) posted soon-ish, so check back. Just cleaning up the angles a bit.