Doblo factory

From EduTech Wiki
Jump to: navigation, search

1 Introduction

Doblo Factory is the name of a set of OpenScad modules to generate Lego and Duplo-compatible structures and bricks. An inititial version was written by Daniel K. Schneider in 2010. Daniel Taub created a nicely refactored version in 2012. This new version documented here also included several interesting additions made by D. Taub, such as various connectors.

Important update: As of september 2015, the V2.x version of this library is functional and compatible with current OpenSCAD implementations. Height parameters are different because it turned out that we needed to divide a full block by 6 (as opposed to 4). Also, there are additional parameters, in particular the scale parameter that allows having both Lego and Duplo sizes in one model.

1.1 Purpose

Doblo factory includes both modules for generating "standard" bricks and modules for creating larger structures. Since OpenScad allows to "union" bricks, it is fairly easy to stack up bricks made from parametric OpenScad modules in order to create larger "playmobile-like" structures.

Doblo factory modules use a grid-based positioning system. The library can be used by non-programmers to create complex Lego-like structures just by making function calls with the right position and size parameters. However, users are expected to be familiar with using a formal language (e.g. HTML or SPSS or a simple scripting language). See the example section for some module usage code.

See also: Lego Dacta, i.e. an article describing a Lego product line for education.

1.2 Download

2 Concepts

This section introduces some basic terminology and conventions. Here is the executive summary.

  • Lugo referes do Lego-compatibles, Doblo refers to Duplo-compatibles
  • There is a positioning grid and it uses the smallest part width as unit, i.e. the size of a 1x1 Lego or Duplo unit.
  • Height of a typical brick was divided in 6 units. FULL=6, HALF=3 and THIRD=2.

2.1 Basic Units

Doblo factory uses a simple unit and position system that allows thinking in high-level units, as opposed to fractions of millimeters. Lego measures are quite complex and sometimes controversial as you could see from reading information on various fan sites.

Doblo factory has been tested quite extensively with Duplo and Lego sizes. You even can combine the two systems to create a single brick. Mini (nano size) and Quadro size has not been really tested. While the outside sizes of various systems are always 2 times smaller or bigger, this is not the case for walls, nibbles, cylinders, etc.

2.1.1 Lugos, Doblos, etc.

  • Doblo bricks are compatible with Duplos
  • Lugo bricks are compatible with Legos. Legos are half as wide, long and high as Duplos, i.e. en 8th of the volume
  • Minis are an 8th of Legos, i.e. the same size as Nanoblocks but Lego compatible
  • Cadros are the biggest units and compatible with Quadros, but have not been tested very much. Also, they need support for printing.

2.1.2 Height units

Height of a standard brick is defined as 6 units. E.g. a height of 5 for a Lego brick would mean 5/6th of a standard brick. Common heights are also defined by the parameters FULL, HALF and THIRD.

  • FULL = 6 units
  • HALF = 3 units
  • THIRD = 2 units

The unit size in mm depends on the brick system

  • Cadro (Quatro compatible) = 6.4mm
  • Doblo (Duplo compatible) = 3.2mm
  • Lugo (Lego compatible) = 1.6mm
  • Mini (Nanoblock size, but not compatible) = 0.8mm

For example, a standard Lego brick has a height of 6 units * 1.6mm = 9.6mm

The following picture shows left to right (x axis) the FULL, HALF and THIRD height of the various brick types. Back to front (y axis) shows the brick types: Doblo, Lego, Mini. These are compatible with DUPLO, LEGO, and can be stacked on top of Nano blocks (but not underneath).

Doblo factory height conventions. Back to front: Doblo, Lego, Mini. Left to right: FULL, HALF, THIRD

2.1.3 Width and length units

Units for columns, rows, with and length are standardized with respect to the smallest Lego/Duplo size

  • DUPLO = 16mm
  • LEGO = 8mm

The following picture shows in the back row a 2x2 Duplo (red), a 1x1 Duplo (green), and in the front row a 2x2 Lego (orange) and an olive 1x1 Lego. The 1x1 bricks represent a unit. Positioning uses the same units (see below)

Unit sizes in mm for width, length, row (y) and col (x) are the same, e.g. 8mm for Lego and 16mm for Duplo

For example, as we shall explain again in more detail, a standard small squared Lego brick is defined as "2x2xFULL" = 2x2x6 = 16mm x 16mm x 9.6mm

2.1.4 Rotation

Some bricks can be rotated through rotation parameters. You only should try 0, 90, 180, 270, else the result is unpredictable

File:2x2xFULL duplo lego.stl

2.2 The positioning framework

Doblo uses a grid like a chessboard. Origin is in the middle like in most 3D representation languages.

  • Column = left to right (x axis)
  • Row = forward to backward (y axis). This can be considered a good decision if you look at your model from top. Else it isn't. I wasn't sure about this, but now it's done. So remember: y is reversed with respect to OpenScad.
  • up = upwards (z axis)

Blocks have the x/y origin in the origin in the upper left.

Coordinate system

Let us illustrate this with an example picture:

Coordinate system and brick x/y size units

You are free to use rational numbers for "in-between positioning", e.g. when assembling more complex structures.

Parameter names used in the source code

  • col: the x axis (left-to-right)
  • row: the y axis (forward to backward)
  • up: the z axis (down to up), Z origin is the bottom of a block. I.e. a block of up=1 would sit on a block of height=1.
  • width: length on the x-axis. Except for the doblo block whose origin is in the middle, origin is upper left
  • length: length on the y-axis, Except for the doblo block whose origin is in the middle, origin is upper left
  • nibbles_on_off: true = nibbles on top, false = no nibbles

Parameters to identify the Duplo/Lego scale

Each function that defines a brick has a scale parameter that you can use to render it in either Doblo, Lugo or mini size.

  • DOBLO == 1; // Duplo size
  • LUGO == 0.5; // Lego size
  • MINI == 0.25; // Nano size

Alternatively, you could set the SCALE parameter in the beginning of your file, e.g. scale = 0.5;

3 Calibration of parameters

3.1 About Lego and Duplo dimensions

According to the german-speaking 1000steine.de forum , retrieved 13:12, 15 April 2010 (UTC), the approximate dimensions of a Lego brick are the following. Duplo bricks are double in each dimension (i.e. 8 times the volume). However, there are important differences between Duplo and Lego bricks. In the code, we deal with this by using conditionals when defining parameters.

Approximate Lego dimensions according to Paddie

Another theory from the same forum thread claims that Legos have been designed in terms of special Lego units, i.e 1/64 inches.

Approximate Lego dimensions according to Chris

Wikipedia also includes a diagram with dimensions

"Lego dimensions" by Cmglee - Own work. Licensed under CC BY-SA 3.0 via Commons
Digital Calliper

Finally, I suggest to buy a digital calliper (about 17 Euros) and measure both original bricks and your own bricks.

Typical Duplo vs. Lego heights

(1) Most Duplo pieces are either "normal" (19.2mm) or half height (9.6mm)

  • In our unit system: FULL or HALF, that is 6 or 3 units. In terms of mm's this translates to 6*3.2mm and 3*3.2mm

(2) Most Lego pieces are either "normal" (9.6mm) or third height (3.2mm).

  • In our unit system: FULL or THIRD, that is 6 or 2 units. In terms of physical size, this would translate to 6*1.6mm = 9.6mm and 2*1.6mm = 3.2mm

Any 3D printer should be able to print DUPLOs. For good Lego rendering, you need to be able to print with 0.25mm layers (or better).

3.2 Doblo factory parameters

To create somewhat DUPLO and Lego-compatible bricks, one does not necessarily use real dimensions. For example, filament-based 3D printers will not produce accurate nibbles. Therefore, if you provide correct data, your blocks won't be compatible. You will have to adjust for your printer and your print settings by editing the parameters in the *.scad file.

Doblo factory is fully parametrized and you certainly will have to adjust the nibble-related parameters with respect to your type of 3D printer, polymers used, and your print setting like print speed, extrusion speed, layer width, and Perimeter Width over Thickness ratio. See for example the Skeinforge for RapMan article for an explanation of these concepts.

Depending on your printer and your layer/thickness printing parameters you may need to change parameters for nibbles and walls.

Parameters were by default set for a Felix V2 printer, i.e. typical mid-range PLA printer. Printing with "normal" slicers profiles should work fairly well, although you may add an extra shell to the first layer and and extra full layer for the bridges (roofs).

  • Layer thickness (mm): Between 0.2 and 0.25 for DUPLOS and Legos. But you can go lower for Legos (0.1 to 02mm).
  • Fit with real Legos and Duplos is rather tight (as least with our printer/slicer combination). After printing - while still warm - you can press the brick onto a real brick to make some adjustement. You also could heat a brick with heat gun, e.g. to 60 - 90 degrees before doing so.
  • Adjust wall with, insets and nibble outer radius, if needed.

Parameters are wrong in order to compensate for the characteristics of the printer and the print parameters. If you do precision printing, e.g. with a 0.1 mm layer you may go closer to the real DUPLO/Lego values.

All units are mm.

Dimensions:

  • A typical small 2x2 nibbles on top DUPLO compatible brick with one nibble underneath is approximately 32mm x 32mm x 19.2mm (plus a nibble height of 4.5mm)
  • LEGO-compatible bricks are half that size in all three dimensions. However walls and nibbles are not proportionally smaller !. This is why we use conditionals in the parameter section. we assume that any size smaller than 0.6 should adopt the Lego proportions.
DUPLO compatible bricks: use SCALE = 1
Lego compatible bricks: Use SCALE = 0.5

Below we show the settings part of the doblo-params.scad file in Doblo Factory, version 2.1

// Normal size (DUPLO)
// SCALE = 1;
// Lego size - see also the hacks in the code for fixing wall and nibble dimensions
// SCALE = 0.5 ;
// Mini Lego size 
// SCALE = 0.25

CADRO = 2; // not yet tested
DOBLO = 1;
LUGO = 0.5;
MINI = 0.25;

HALF=3;
THIRD=2;
FULL=6;

// LEGO SCALE - don't change, allows to create nano legos, should be 1 if real Legos
function LEGO_SCALE(SCALE) = 2 * SCALE;

// Doblo block size
// Real DUPLO Block = 31.7 / 2 = 15.85 (with some variations)
function PART_WIDTH(SCALE)  = 16.0  * SCALE;

// Block height (a typical block is 4 * PART_HEIGHT)
// Real Duplo Block = 19.17 / 4 = 4.8, we also measured 19.09, 19.16
function PART_HEIGHT(SCALE)  = (SCALE < 0.6) ? ( 1.6 * LEGO_SCALE(SCALE) ) : ( 3.2 * SCALE );
// Diamonds - size of anti-warping holes - used optionally
DIAMOND = 4;

// Top nibble size definitions
// Must be adjusted with respect to layer resolution and other slicing considerations
function NO(SCALE)         = PART_WIDTH(SCALE) / 2.0;              //nibble offset
function NBO(SCALE)        = PART_WIDTH(SCALE);                   // nibble bottom offset
function NH(SCALE)         = (SCALE < 0.6) ? 1.75 * LEGO_SCALE(SCALE) : 4.55 * SCALE;  // LEGO vs. DUPLO 
function NB_RADIUS(SCALE)  = (SCALE < 0.6) ? (4.9 / 2 * LEGO_SCALE(SCALE)) : (9.2 / 2.0 * SCALE);  // Lego vs. DUPLO

// Real DUPLO Block = 9.38 
function NB_RADIUS_INSIDE(SCALE) = 6.8/2  * SCALE;  
// 6.44 = Real DUPLO block

function NB_THICKNESS(SCALE)=NB_RADIUS(SCALE)-NB_RADIUS_INSIDE(SCALE);

// For square nibble supports in 1xM or Nx1 blocks
function ALONG_LEN(SCALE)  = (PART_WIDTH(SCALE)-NB_RADIUS(SCALE))/1.7; //tighter fit than 1.8
function CROSS_LEN(SCALE)  = (PART_WIDTH(SCALE)-NB_RADIUS(SCALE)/2);

// Bottom nibbles size definitions
// Must be adjusted with respect to layer resolution and other slicing considerations
function NB_BOTTOM_RADIUS(SCALE)        = (SCALE < 0.6) ? 6.5/2*LEGO_SCALE(SCALE) : 13.4/2*SCALE;
function NB_BOTTOM_RADIUS_THIN(SCALE)   = (SCALE < 0.6) ? 3.5/2*LEGO_SCALE(SCALE) : 7.2/2*SCALE;
// Real DUPLO = 13.48
function NB_BOTTOM_RADIUS_INSIDE(SCALE) = (SCALE < 0.6) ? 4.8/2*LEGO_SCALE(SCALE) : 10.8/2*SCALE;
// Real DUPLO = 10.73
// rapman 10.6
// Real Lego = 4.9

// walls - IMPORTANT: must be adjusted with respect to layer resolution and other slicing considerations
function DOBLOWALL(SCALE) = (SCALE < 0.6) ? 1.2 * LEGO_SCALE(SCALE): 1.55 *SCALE; // Lego vs. Duplo, Lego is not 2x smaller

function USE_INSET(SCALE) = (SCALE < 0.6) ? true : true;
function INSET_WIDTH(SCALE)    = (SCALE < 0.6) ? 0.4 *LEGO_SCALE(SCALE) : 1.50 * SCALE; //little inset walls to make it stick
function INSET_LENGTH(SCALE)  = (SCALE < 0.6) ? 3*DOBLOWALL(SCALE) : 4*DOBLOWALL(SCALE); // Legos have proportionally smaller insets

//lattice width and height (optional, see LATTICE_TYPE)
// A grid underneath the flat bridge, crossing through the nibbles underneath
function LATTICE_WIDTH(SCALE)   = 1.50 * SCALE;

// 0 means none, 1 means more spacing (same as nibbles underneath),
// 2 means denser
LATTICE_TYPE    = 1; 

// Sizes of a standard 2x2 square brick, normal height
// Not used, but are practical in your custom modules
function DOBLOWIDTH(SCALE)  = PART_WIDTH(SCALE)  * 2.0  * SCALE;
function DOBLOHEIGHT(SCALE) = PART_HEIGHT(SCALE) * 6.0  * SCALE;
function LEGOHEIGHT(SCALE)  = PART_HEIGHT(SCALE) * 6.0  * SCALE;

4 Using openscad doblo modules

From a user point of view, Doble factory, is a set of functions (called modules in OpenSCAD) that will produce various Lego geometries.

You could use Doblo factory to generate various types of isolated bricks, but its main purpose is to assemble various smaller pieces into a bigger whole that then can printed.

Most doblo modules work in the same way, the use the same parameters in the same order if appropriate.

4.1 Getting started

Getting started - e.g. producing a canonical 4x2 Lego brick - is simple

  • Create a Scad file that includes the doblo-factory library and a parameter file
  • Call the doblo module with some parameters.

Creation of simple Lego brick using a list of parameters

include <doblo-factory.scad>;
include <lib/doblo-params.scad>;
//       column line z-pos   width length   height nibbles diamonds, size
doblo   (0,     0,   0,      4,    2,       FULL,  true,   false,    LUGO);

This will create a brick that looks like this and that is positioned at x,y,z origin. As you can see in the code, we added a line with comments so that we could remember what each parameter represents.

Alternatively - and we recomment this - you can use a more verbose syntax that uses parameter names in the module call. Warning: you cannot use both positions and verbose syntax in one module call (except for the last element).

The following code will produce two identical Lego compatible bricks. We use both short and long notation (named parameters).

include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

//doblo   (0,   0,   0,   2,   2,    FULL,  true, false, DOBLO);
//doblo   (0,   0,   0,   2,   2,    FULL,  true, false, LUGO);

//      col row   up  width length height
doblo   (0,   0,   0,   4,   2,    FULL,  true, false, LUGO);

doblo   (col=0,  row=4, up=0,  
	 width=4,  length=2, height=FULL, 
	 nibbles_on_off=true, diamonds_on_off=false,
	 scale=LUGO);
Creating simple Lego bricks with the doblo module. Two ways to call a module

Using the library and the parameter file, file locations

Most example code should work (copy/paste the code). However, you have to make sure that the file paths are right.

E.g. if your scad file sits in the top-level directory, use

include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

If it stits in a subdirectory, use

include <../doblo-factory.scad>;
include <../lib/doblo-params.scad>;

etc.

4.2 Overview of doblo modules

The following picture of Doblo Factory V2 shows most types of bricks that you could generate (and combine).

Doblo factory V2 OpenScad lego-compatible module bricks - top
Doblo factory V2 OpenScad lego-compatible module bricks - bottom
Doblo factory V2 OpenScad Duplo-compatible module bricks - top
  1. Doblo brick: An x/y/z size of Lego/Duplo compatible brick. With or without nibbles on top
  2. Base plate: Like block, but a different bottom for easier printing
  3. Merge STL files
  4. Block: Like duplos, but a flat bottom. Allows to assemble playmobile-like structures
  5. Nibbles: To stick on top of plates, blocks, animals
  6. Support triangles. To build housing and other structures
  7. Ramp: to build housing and other structures
  8. Cylinder. An alternative to block when building structures
  9. [ New elements !! ]

5 List of doblo modules

Below, we shall attempt to document each type of brick. The documentation is not complete yet, look at the source code please - Daniel K. Schneider (talk) 17:25, 28 September 2015 (CEST)

5.1 doblo brick

Creates a typical duplo-compatible brick. Typical use is to create a Doblo base on which you then can add other structures. You also can pile up (union) these bricks, but that may lead to a waste of processing time and plastic. Doblo bricks are just like Duplo bricks, however you can make the nibbles on top optional.

Short Syntax
doblo   (col, row,  up,  width, length, height, nibbles_on_off, holes_on_off, system)

col     = number, the x position of the brick
row     = number, the y position of the brick
width   = number, the size in x axis. 2 refers to brick size of 2
length  = number (y axis). 4 referes to brick size of 4
height  = either a number for the sixth of a standard brick height or THIRD, HALF, FULL
nibbles_on_off = wether you want nibbles or not, i.e. true or false
system  = either LUGO or DOBLO
Named parameters syntax with default parameter values
doblo   (col=0,  
         row=4, 
         up=0,  
	 width=4, 
         length=2, 
         height=FULL, 
	 nibbles_on_off=true, 
         diamonds_on_off=false,
	 scale=LUGO);

Example

The following picture shows four bricks:

  • Yellow: A larger yellow Lego-compatible brick (4x6x6 or 4x6xFULL size) without nibbles
  • Red: A standard 2x2xFULL sized Lego-compatible brick
  • Blue: A 1x1x18 = 1x1x 3*FULL Lego-compatible brick
  • Green: A 2x3xFULL Duplo-compatible block
A set of doblo bricks (top front view)

The code (including an extra "color("....") statements goes like this:

include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

color ("yellow") doblo (col=0,  row=0, up=0,  
		       width=4,  length=6, height=FULL, 
		       nibbles_on_off=false,
		       diamonds_on_off=false,
		       scale=LUGO);

color ("red") doblo   (col=0,  row=0, up=FULL,  
		       width=4,  length=2, height=FULL, 
		       nibbles_on_off=true,
		       diamonds_on_off=false,
		       scale=LUGO);

color ("blue") doblo   (col=0,  row=5, up=FULL,  
		       width=1,  length=1, height=3*FULL, 
		       nibbles_on_off=true,
		       diamonds_on_off=false,
		       scale=LUGO);

color ("green") doblo  (col=-3,  row=0, up=0,  
		       width=2,  length=3, height=FULL, 
		       nibbles_on_off=true,
		       diamonds_on_off=false,
		       scale=DOBLO);
A set of doblo bricks (bottom front view)

5.2 Base plate

This is an easy to print non-stackable base plate. In order to prevent warping on the print bed, it has smaller squares underneath if you print them in exactly the same heights as below (there is a bug as of sept. 2015). Up should be always 0. You also can "glue" other elements on top in order to create play-mobile like structures. In that case you also should nibbles in certain areas as shown in the following example:

Short Syntax
base_plate (col, row, up, width, length, height, nibbles_on_off, scale)
Long Syntax
module base_plate (col=0, row=0, up=0, width=8,length=8,height=THIRD,nibbles_on_off, scale=LUGO)

Example that shows how to add a few nibbles on top:

include <doblo-factory.scad>;

base_plate (4, -14, 0, 12,12,2,true, LUGO);
base_plate (2, 0, 0, 6, 6, 2,true, DOBLO);
base_plate(col=-8);

// A stack of doblos/lugos just for the fun of it.
// Note how DOBLOs and LUGOs have a different coordinate system
color ("red")    base_plate  (-4, -6,  0,   4,   4,  2,  false, DOBLO);
color ("orange") nibbles     (col=-4, row=-6,  up=2,  width=2, length=4, scale=DOBLO);    

color ("green")  doblo       (-2, -12,  4,   2,   2,    6,  true, false, LUGO);
color ("olive")  nibbles     (col=-2, row=-10,  up=4,  width=2, length=6, scale=LUGO);  

  As this example shows, it could be useful to add a bit of color in front of some bricks. This way you can identify them. Below is the picture:

4 differenty base plates

5.3 Merge STL files

Positions an stl file, you may have to find out by trial and error what z offset to use. Tip: embed the STL into a doblo or a block.

Syntax
merge_stl (file, col, row, up, stl_z_offset_mm, shrink, scale)

Notice: For height, you only need the up parameter, e.g. up=3.2, but if you prefer to think in mm's use stl_z_offset_mm

Code available at thingiverse

Example:

 merge_stl ("../stls/duckator-reduced.stl", col=-3.4, row=-9, up=FULL);

If you plan to create blocks with some animal on top, also consider using the little stl-merge-display extension like this:

include <doblo-factory.scad>;
include <lib/doblo-params.scad>;
include <ext/stl-merge-display.scad>;

// One in front
merge_brick(stl_file="stls/duck.stl");

// A second one in the back
translate([0,40,0])
 merge_brick (doblo_width=3, doblo_length=2, doblo_height=2, doblo_nibbles=false,
	      stl_file="stls/duck.stl", stl_lift=-1, stl_shrink=1.66,
	      STL_col=1, STL_row=0,
	      block_height=2, block_width=3, block_length=2);

// A simple merge without brick and block using the doblo-factory module
translate([0,80,0]) scale (0.5) merge_stl ("stls/duck.stl", shrink=0.8);
A duck merged on a Lugo brick

5.4 Block

Creates a building block for larger structures with x,y,z positioning. A block does not have nibbles underneath and may or may not have nibbles on top. Also could be used to print a base plate.

Syntax
block (col, row, up, width,length,height,nibbles_on_off, scale)
block (col=0, row=0, up=0, width=2,length=4,height=FULL,nibbles_on_off=false, scale=LUGO)

Example: Simple stairway

Blocks are essential for building larger structures. The following examples shows how we could create a simple stairway by stacking a series of blocks next to each other.

include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

module stairs_world_light ()
{
     //    (col, row, up, width,length,height,nibbles_on_off) 
     color ("green") doblo (-5,  -5,   0,  10,   10,    1,     false, scale=DOBLO);
     
     //    staircase
     //                   (col, row, up, width,length,height,nibbles_on_off, SCALE) 
     color ("red")  block (1,   3,   1,  2,    2,     2,     false, DOBLO);
     color ("pink") block (-1,  3,   1,  2,    2,     4,     false, DOBLO);
     color ("red")  block (-3,  3,   1,  2,    2,     6,     false, DOBLO);
     color ("pink") block (-5,  3,   1,  2,    2,     8,     false, DOBLO);
     color ("red")  block (-5,  1,   1,  2,    2,    10,     false, DOBLO);
     color ("pink") block (-5, -1,   1,  2,    2,    12,     false, DOBLO);
     color ("red")  block (-5, -3,   1,  2,    2,    14,     false, DOBLO);
     color ("pink") block (-5, -5,   1,  2,    2,    16,     true, DOBLO);
     
     color ("blue") block (3, -5, 1, 2, 6, 1, true, scale=DOBLO);
}
// call the module, else it won't draw
stairs_world_light();
Simple stairway made with blocks

Example: Stairway

The following example shows inclusion of some other brick types that we shall explain below, e.g. nibbles. Also admire the duck embedded as a monument to all this...

This example also demonstrates how to use standard openscad functionality to "dig" a tunnel, seen to the left. In the source code below the # sign will allow to visualize the object (in pink) that was subtracted and that won't be seen in the computed scene.

The passageway to the right has been built with some support brick (see below) that should be replaced some day with something that is more graceful but still printable.

include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

stairs_world ();

module stairs_world ()
{
     //      (col, row, up, width, length)
     nibbles (-1,   -1,   1,   6,     4      , scale=DOBLO);
     nibbles (-1,   -5,   1,   4,     3      , scale=DOBLO);
     
     difference () {
	  union () {
	       //    Base plate, for faster printing replace by block
	       //    (col, row, up, width,length,height,nibbles_on_off, diamonds) 
	       color ("green") base_plate (-5,  -5,   0,  10,   10,    1,     false, false, scale=DOBLO);
     	       //    staircase
	       //    (col, row, up, width,length,height,nibbles_on_off) 
	       color("red") block (1,   3,   1,  2,    2,     2,     false, scale=DOBLO);
	       block (-1,  3,   1,  2,    2,     4,     false, scale=DOBLO);
	       color("red") block (-3,  3,   1,  2,    2,     6,     false, scale=DOBLO);
	       block (-5,  3,   1,  2,    2,     8,     false, scale=DOBLO);
	       color("red") block (-5,  1,   1,  2,    2,    10,     false, scale=DOBLO);
	       block (-5, -1,   1,  2,    2,    12,     false, scale=DOBLO);
	       }
	  # house_lr (-6.01, 0.01, 1.01, 4.01, 2.01, 3.01, DOBLO);
	  }
     //   platform and support
     //          (col,row,up,height,angle, width)
     color ("blue") support (-5, -5,  6,  7,   270, 1, scale=DOBLO) ;
     block   (-5, -5,  1,  1,    1,     8,   false, scale=DOBLO);
     
     color ("blue") support (-3, -5,  6,  7,   270, 1, scale=DOBLO) ;
     block   (-3, -5,  1,  1,    1,     8,   false, scale=DOBLO);
     
     color ("blue") support (-5, -2,  6,  7,   90, 1, scale=DOBLO) ;
     block   (-5, -2,  1,  1,    1,     8,   false, scale=DOBLO);
     
     color ("blue") support (-3, -2,  6,  7,   90, 1, scale=DOBLO) ;
     block   (-3, -2,  1,  1,    1,     8,   false, scale=DOBLO);
     
     block   (-5, -5,  13,  3,    4,     2,   true, scale=DOBLO);
     
     // support block + duck
     block   (-4, -5,  15,  2,    2,     2,     false, scale=DOBLO);
     merge_stl ("stls/duck.stl", -4, -5, 15, 3, scale=DOBLO);
     nibbles (-3.9, -4.5, 19.7, 1, 1, scale=DOBLO);
     nibbles (-3.9, -4.5, 19, 1, 1, scale=DOBLO);
}
Simple stairway made with blocks

5.5 Nibbles

To insert nibbles on some spots of a nibble-less block or an imported STL. For use in larger structures or to create custom bricks. Nibbles also can be stuck on top of imported STL files (use rational numbers for the x,z,z aks col,row,up positions to do so, as seen for the duck in the example below.

Syntax
nibbles (col, row, up, width, length, scale, extra, filled, hscale)
nibbles (col=0, row=0, up=FULL, width=1, length=1, scale=LUGO, extra =false, filled=false, hscale=1)

Example

Various doblo nibbles
include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

doblo (col=-4, row=-2, up=0,  
	width=4,  length=4, height=HALF, 
	nibbles_on_off=false,
	diamonds_on_off=false,
	scale=DOBLO);

color ("red") nibbles (col=-4, row=0, up=HALF, width=1, length=2,
		       scale=DOBLO, extra =false, filled=false, hscale=1);
color ("pink") nibbles (col=-4, row=-2, up=HALF, width=1, length=2,
			scale=DOBLO, extra =false, filled=true, hscale=1);
color ("orange") nibbles (col=-3, row=-2, up=HALF, width=1, length=2,
			  scale=DOBLO, extra =false, filled=true, hscale=3);

doblo (col=2, row=0, up=0,  
	width=4,  length=4, height=HALF, 
	nibbles_on_off=false,
	diamonds_on_off=false,
	scale=LUGO);

color ("green") nibbles (col=2, row=0, up=HALF, width=1, length=2,
			 scale=LUGO, extra =false, filled=false, hscale=1);
color ("lightgreen") nibbles (col=2, row=2, up=HALF, width=1, length=2,
			      scale=LUGO, extra =false, filled=true, hscale=1);
color ("lime") nibbles (col=3, row=0, up=HALF, width=3, length=2,
			scale=LUGO, extra =false, filled=true, hscale=1);
 
merge_stl (file="stls/duck.stl", col=-15, row=-4, up=0, stl_z_offset_mm=0, shrink=0.5, scale=LUGO);

color ("blue") nibbles (col=-15.5, row=-4, up=17, width=2, length=2,
			scale=LUGO, extra =false, filled=true, hscale=3);

color ("cyan") nibbles (col=-12.5, row=-3.5, up=31, width=1, length=1,
			scale=LUGO, extra =false, filled=true, hscale=3);
  • See also the example above for the block element

5.6 Bottom nibbles

To insert underneath an imported STL. Not very usefull, unless you can print with an easily removable support material or if you can turn the object upside down (put these nibbles on top) or if you turn it upside down and then use a support structure generated from your slicer. I'd rather stick a doblo block to the feet of an imported object.

Syntax
nibbles_bottom (col, row, up, width, length, height, scale)

Important: For positioning think of a bottom nibble as the center of a "virtual Lego brick". E.g. in the example below, both the lime and the olive nibble sit on the same "row" as the pink Lugo brick.

Example

Bottom nibbles
include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

merge_stl (file="stls/duck.stl", col=0, row=0, up=HALF, stl_z_offset_mm=0, shrink=0.5, scale=LUGO);

// calibration brick
color ("pink") doblo (col=-6, row=0, up=0, width=2, length=2, height=HALF, scale=LUGO);

color ("green") nibbles_bottom (col=-2, row=-1, up=0, width=5, length=4, height=FULL, scale=LUGO);
color ("lime") nibbles_bottom (col=-3, row=0, up=0, width=1, length=1, height=FULL, scale=LUGO);
color ("olive") nibbles_bottom (col=-4, row=0, up=0, width=2, length=2, h

5.7 Alternative to bottom nibbles

As we mentioned above, you could just "sit" and STL object on top of a doblo brick. However, if you want the nibbles underneath to be less appareant, you can play with the following kind of alternative.

The following alternative requires a tiny bit of OpenSCAD programming and does create printable objects.

  1. Use a block to dig a rectangular hole into the imported STL object
  2. Stick a doblo block without nibbles into this hole.

Example

Imported STL with an embedded doblo brick (requires a difference operation with a block of the same size).
include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

difference () {
     merge_stl (file="stls/duck.stl", col=0, row=0, up=0, stl_z_offset_mm=0.5, shrink=0.7, scale=LUGO);
     block (col=-1.3, row=0, up=-1, width=3, length=2, height=HALF, nibbles_on_off=false, scale=LUGO);
}

doblo (col=-1.3, row=0, up=0, width=3, length=2, height=HALF, nibbles_on_off=false, scale=LUGO);

5.8 Doblo angle and block angle

Doblo angle's allow creating blocks with an angle with or without nibbles. Block angle's are made for stacking. Btw. the doblo angle is just the union of a doblo block with a block angle.

These are bit experimental and measures may not exactly be right. In particular, angle blocks z-position can be below 0. Therefore on position these on top of something else. Doblo angle blocks, on the other hand should work OK. There is no rotation feature. Finally, you will have to use OpenSCAD rotation, e.g. translate([2*PART_WIDTH(LUGO),0,0]) rotate(90)doblo_angle();, plus a translation to put it back in the right position.

Short Syntax for doblo_angle

module doblo_angle_block (col,row,up,width,length,height,a_height,nibbles_on_off,scale)

Long Syntax with default values shown:

 doblo_angle (col=0,row=0,
	      up=0,
	      width=2,length=4,
	      height=FULL,
              a_height=FULL,
	      nibbles_on_off=true,
	      scale=LUGO)

With respect to doblo's there is an additional parameter: a_height. I.e. doblo angle have a base height plus the height of the angle block that will sit on top.

Short Syntax for block_angle

module block_angle (col, row, up, width,length,height,nibbles_on_off, scale)

Warning: z positioning is slightly wrong, i.e. a bit below z=0. Use these only for single printing or as building blocks for larger structures.

Example

The following picture shows for doblo angle blocks (the green ones) and three block angle pieces (the blue ones). The wall in the background is for calibration.

Various doblo and block angle pieces
include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

// calibration block

color ("pink")  block  (-5,-3, 0,      20,2,HALF,false,LUGO);
color ("red") block  (-5,-3, HALF,   20,2,HALF,false,LUGO);
color ("pink")  block  (-5,-3, FULL,   20,2,HALF,false,LUGO);
color ("red") block  (-5,-3, 3*HALF, 20,2,HALF,false,LUGO);
color ("pink")  block  (-5,-3, 2*FULL,   20,2,HALF,false,LUGO);
color ("red")  doblo  (-5,-3, 2*FULL+HALF,   20,2,HALF,true,false,LUGO);

// from left to right

color ("lime") doblo_angle (col=-5, row=0, up=0, 
	     width=1, length=4, 
	     height=THIRD, a_height=FULL,
	     nibbles_on_off=false,
	     scale=LUGO);

color ("green") doblo_angle (col=-3);

color ("olive") doblo_angle (col=-1, row=0, up=0, 
	     width=1, length=4,
	     height=THIRD, a_height=HALF,
	     nibbles_on_off=true,
	     scale=LUGO);

color ("darkgreen") doblo_angle (col=1, row=0, up=0, 
	     width=4, length=2,
	     height=HALF, a_height=FULL,
	     nibbles_on_off=true,
	     scale=LUGO);

color ("blue") block_angle (col=6, row=0, up=0,
			    width=2,length=4,height=HALF, a_height=FULL,
			    nibbles_on_off=true, scale=LUGO);  

color ("darkblue") block_angle (col=9, row=0, up=0,
			    width=2,length=4,height=FULL,
			    nibbles_on_off=false, scale=LUGO);  

color ("skyblue") block_angle (col=12, row=0, up=0,
			       width=2,length=4,height=3*FULL,
			       nibbles_on_off=true, scale=LUGO);

5.9 Support triangles

Support triangles are used in larger structures to support a roof. These bricks are really ugly and some day should be replaced by some more graceful arcs ...

  • Thickness = 1 doblo width, e.g. = PART_WIDTH.
  • Sometimes you may want rational numbers. E.g. 1.5
  • Height/length proportion is 4.8/4 (i.e. typical Duplo proportions).
  • Only use angle arg of 0,90,180,270 !!

WARNING: You may want to have these bricks overlap a bit, e.g. if 2 corners are just touching, the model will be not be "simple" and can't be exported as STL. In other words, make them a bit higher and position a bit off (embed into the block that you will put on the back and embed the back in a side block). See the stronghold example included.

Syntax
support (col,row,up,height,rotation_angle,thickness,scale)

Example

Support structure block
include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

// (col=0,row=0,up=0,height=FULL,angle=0,thickness=1, scale)

color ("pink") support    (col=0, row=-6, up=0, height=2*FULL, angle=270, thickness=1, scale=LUGO) ;
color ("pink") support    (col=0, row=-6, up=0, height=2*FULL, angle=90, thickness=1, scale=LUGO) ;

color ("red") support     (0,     0,     0,    2*FULL,        0,       1,           LUGO) ;
color ("yellow") support   (5,  0,   0,   2*FULL,   180, 1, LUGO) ;
color ("lime") block      (0,  0,   2*FULL,  6,    1,   1, true, LUGO);

5.10 ramp

ramp is the opposite of the support triangle, but with a flatter angle. Can be used to anchor a high and slim block or also to build a real ramp.

  • Height/length proportion is 4.8/16 (i.e. typical Lego proportions)

If you wish to use a more flexible solution, you could start from block_angles, but you'd have to rotate these manually. The ramp doesn't have nibbles, the angle blocks do ...

Syntax:

ramp (col,row,up,height,rotation_angle, width,scale)
Rotation must be one of 0, 90 180 or 270.

Example

Various doblo ramps.
include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

color ("lavender") doblo (col=-0, row=0, height=FULL, width=2, nibbles_on_off=false);
// ramp                (col, row, up, height, angle,width,scale)
color ("fuchsia") ramp  (2,  0,   0,  FULL,   0,    2, LUGO);
color ("plum")    ramp  (0,  0,   0,  FULL,   180,  2, LUGO);
color ("purple")  ramp  (-0.5,  0,   0,  8,      90,   3, LUGO);
color ("indigo")  ramp  (0,  2,   0,  FULL,   270,  2, LUGO);

doblo (col=-4, row=4,height=THIRD);
color ("blue")  ramp  (col=-1, row=6, up=0, height=THIRD, angle=270, width=0.5, scale=LUGO);

5.11 Cylinder

cylinder is like a block, but round.

  • Can have nibbles on top.

Syntax:

cyl_block (col, row, up, bottom_r, top_r, height, nibbles_on_off,scale)

Example

A collection of funky doblo cylinders
include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

color ("purple") cyl_block ();
color ("purple") cyl_block (col=2);
color ("purple") cyl_block (col=4, nibbles_on_off=false);

color ("fuchsia") cyl_block (col=-6, bottom_r=4, top_r=3, height=2*FULL);

// An ugly antique pilar
color ("gold")    cyl_block (row=-6, col=0, up=0,      
			     bottom_r=4, top_r=2, height=FULL, nibbles_on_off=false);
color ("cornsilk") cyl_block (row=-5, col=1, up=FULL,   
			      bottom_r=2, top_r=2, height=2*FULL, nibbles_on_off=false);
color ("khaki")    cyl_block (row=-5, col=1, up=3*FULL,
			      bottom_r=2, top_r=4, height=FULL, nibb

Bug: Generates 4 nibbles for a r=0.5 cylinder. Workaround: Add a single one manually using the nibbles module.

5.12 Writing text

For writing text on top of blocks, we can use the OpenSCAD text function.

include <../doblo-factory.scad>;
include <../lib/doblo-params.scad>;

// text on a 6x2 doblo

doblo (col=2,row=1,up=0,length=2,width=6,height=THIRD,nibbles_on_off=false); 
color ("purple") write (text="DOBLO", col=2, row=1.5, up=THIRD,
			size=10, height=1.5);

doblo (col=8,row=-5,up=0,length=6,width=2,height=THIRD,nibbles_on_off=false); 
color ("purple") write (text="ROCKS !", col=8.5, row=-4.9, up=THIRD, rot=270,
			size=8, height=1.5,valign="baseline");
Writing on two doblo bricks using a little write module (see below)

Since this module might be missing from doblo-factory.scad, here is the definition of the module (just copy/paste it in your file, e.g. next to the example above).

// Text module

module write (text="hello", col=0, row=0, up=0, rot=0, height=1, size=8, valign="top", halign="left", font="Liberation Sans,style=bold", scale=LUGO) {
     x_0 = col    * PART_WIDTH(scale);
     y_0 = - (row * PART_WIDTH(scale));
     z_0 = up     * PART_HEIGHT(scale);

     translate ([x_0, y_0, z_0]) {
	  rotate (rot) {
	       linear_extrude (height=height) {
		    text (text, font = font, size=size, valign=valign, halign=halign);
	       }
	  }
     }
}

6 Extensions

Some bricks are available through the extension library. Some modules are not fully tested or not fully implemented...

6.1 Ball and socket doblos

Ball and socket doblos are defined in the connectors extension library. They allow creating objects that can hook together. These joints are based on ball joint in SCAD by Erik de Bruijn, modified by juniortan http://www.thingiverse.com/thing:2631, derived originally from Erik's parametric ball joint: http://www.thingiverse.com/thing:1968.

Syntax

ball_doblo (row, col, up, width, height, nibbles_on_off, diamonds_on_off, size)

Arguments are the same as for doblo, except that parameter names are different.

ball_doblo(xoff, yoff, zoff,width,length,height=3,nibbles=true,diamonds=false,size=DOBLO)
module socket_doblo(xoff, yoff, zoff,width,length,height=3,nibbles=true,diamonds=false,size=DOBLO){

Example:

include <doblo-factory.scad>;
include <lib/doblo-params.scad>;
include <ext/connectors.scad>;

//ball_doblo   (0,   1,   0,   2,   2,size=LUGO);
//socket_doblo   (4,   1,   0,   2,   2,size=LUGO);

color ("red") socket_doblo (xoff=5, yoff=4, zoff=0, width=3, length=2, height=HALF, nibbles=true, diamonds=false, size=DOBLO);

color ("darkred") ball_doblo   (0,   4,   0,   3,   2,size=DOBLO);

color ("tomato") ball_doblo   (1,   7,   0,   8,   2,diamonds=true,size=DOBLO);
color ("orange") socket_doblo   (1,   7,   0,   8,   2,diamonds=true,size=DOBLO);

color ("green") ball_doblo   (1,   1,   0,   2,   2,size=DOBLO);
color ("darkgreen") socket_doblo   (1,   1,   0,   2,   2,size=DOBLO);

ball_doblo   (5,   1,   0,   2,   2,size=DOBLO);
socket_doblo   (5,   1,   0,   2,   2,size=DOBLO);

ball_doblo   (9,   1,   0,   2,   2,size=DOBLO);
socket_doblo   (9,   1,   0,   2,   2,size=DOBLO);

color ("blue") socket_doblo   (9,   4,   0,   2,   2,6,size=DOBLO);

color ("fuchsia") top_ball_doblo   (10,   7,   0,   2,   2,diamonds=false,size=DOBLO);
Sockets and ball joints

6.2 Hinges

Hinges allor to create covers, doors etc. You either can print these as is or assemble within other objects. You may have to use OpenScad transformations of positioning. Note that these require a good high resolution printer for Lego-compatible blocks (Lugos). Doblos should be easier to print ...

horizontal hinges

Thes rotate up/down along the y-axis

Syntax:

hinge_y(xoff, yoff, zoff,length,width,height=3,nibbles=true,size=DOBLO, $fs=0.01,type=0)
module hinge_z_hole(offx=0,offy=0,offz=0,width=1,length=2,height=6,nibbles=true,size=DOBLO,tolerance = 1){

Hinge_y example

Four doblo hinges. Rotations (i.e. the green one) must be done with OpenSCAD transforms
include <doblo-factory.scad>;
include <lib/doblo-params.scad>;
include <ext/connectors.scad>;

// minimum dimension for hinge side is 2

color ("brown")     hinge_y   (0,  0,  0,   1,  4, 3, true, LUGO);
color ("chocolate") hinge_y   (3,  0,  0,   2,  4, 3, true, LUGO);

// create a hinge on top of a stackable block
color ("cyan")       doblo     (-3,  0,  0,      2,  4, HALF, false, false, LUGO);
color ("lightcyan")  block     (-3,  0,  HALF,   2,  4, HALF+FULL, false, LUGO);
color ("grey")       support   (col=-1, row=0, up=FULL+HALF, height=HALF, angle=0, thickness=4, scale=LUGO);
color ("blue")       hinge_y   (-3,  0,  2*FULL,   2,  4, HALF, true, LUGO);

// rotate, then translate a hinge with OpenSCAD functions
unit = PART_WIDTH(LUGO);
translate ([8*unit, -4*unit, 0]) {
     rotate (180) {
	  color ("green") hinge_y (xoff=0, yoff= 0, zoff= 0, length=2, width=4, height=3, nibbles=true, size=LUGO);
     }
     }

6.3 Text

The text module is deprecated, since OpenSCAD now does have a text module.

Glyph

Is a letter, a number or a special character. This module is based on OpenSCAD Bitmap Fonts Module

Syntax:

glyph (col, row, up, height_mm, char)

Text

Is a text with glyph characters (see above).

Syntax:

text (col, row, up, height_mm, chars, count)

count is the number of letters chars is an array.

Example

text (1, 6, 2, 4, ["T","H","i","N","G","Y"], 6);

7 Examples

7.1 Simple bricks with x/y positions and color parameters

The following example demonstrates (again) how to create simple Lego and Duplo compatible bricks

It also shows how to create custom modules that would simplify creation of frequently bricks. Each module takes position, and a color and then produces a standard Lego-compatible bricks, a flat half-height lego-compatible bricks for mashups, and a standard 2x2 Duplo-compatible brick.

Three bricks created with custom modules
include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

// Each brick is defined in a module that takes x/y position and color as parameter

module lego_brick_for_mashups (x,y,fill) {
     color (fill)
     doblo   (col=x,  row=y, up=0,  
	      width=4,  length=4, height=HALF, 
	      nibbles_on_off=false, diamonds_on_off=false,
	      scale=LUGO);
}

module lego_compat_standard_brick  (x,y,fill) {
     color (fill)
     doblo (x,y, 0, 4, 2, FULL, true, false, LUGO);
}

module duplo_compat_2x2xHALF_brick  (x,y,fill) {
     color (fill) {
	  doblo (x,y, 0, 2, 2, FULL, true, false, DOBLO);
	  }
}

// display each module, position and color each
// makes it easier to use (less typing if you just want flat standard bricks)

lego_brick_for_mashups (x=0, y=0, fill="red");
lego_compat_standard_brick (-4,-3,"blue");
duplo_compat_2x2xHALF_brick (-3,1, "green");

Exercise:

  • Revert the y position
  • Add width and length parameters

7.2 Doblo structure - A stronghold

The following structure was my first creation and it did have some design flaws. But it did print back in 2010 on a RapMan printer. It took about 3 days....

Strong-hold in progress

But it did print:

Stronghold printed

See the happy Duplo persons !

Happy duplo persona enjoying their new home
Module name
stronghold ()

Below is a revised design which I didn't print yet. It's included in the doblo-factory-1.scad file.

Stronghold - version 2 as seen in Netfab

The code is fairly complex, because we needed some support triangles. These should be replaced by pillars some day ...

// ------------------- A stronghold

include <doblo-factory.scad>;
include <lib/doblo-params.scad>;

// SCALE=LUGO;
SCALE=DOBLO;

stronghold();

module stronghold ()
{
     union()
     {
	  doblo (col=-6, row=-6, up=0, width=12, length=12, height=THIRD, nibbles_on_off=false, diamonds=false, scale=SCALE);
	  nibbles (col=3, row=-6, up=THIRD, width=3, length=3, scale=SCALE, extra=false, filled=false, hscale=1);
	  nibbles (col=1, row=3, up=THIRD, width=5, length=3, scale=SCALE, extra=false, filled=false, hscale=1);
	  nibbles (col=-6, row=3, up=THIRD, width=3, length=3, scale=SCALE, extra=false, filled=false, hscale=1);

	  //back
	  ramp  (0, -5, 1, 2, 0, scale=SCALE);
	  block (col=-5, row=-5, up=THIRD, width=1, length=1, height=6*FULL, nibbles_on_off=false, scale=SCALE);	    
	  color ("grey")  ramp  (-4, -5, 1, 2, 0, scale=SCALE);
	  color ("black") ramp  (-2.5, -5, 1, 2, 180, scale=SCALE);
	  block (col=-3, row=-5, up=THIRD, width=1, length=1, height=6*FULL, nibbles_on_off=false, scale=SCALE);	    
	  ramp  (-2, -5, 1, 2, 0, scale=SCALE);
	  ramp  (-0.5, -5, 1, 2, 180, scale=SCALE);
	  block (col=-1, row=-5, up=THIRD, width=1, length=1, height=6*FULL, nibbles_on_off=false, scale=SCALE);	    
	  ramp  (1.5, -5, 1, 2, 180, scale=SCALE);
	  block (col=1, row=-5, up=THIRD, width=1, length=1, height=6*FULL, nibbles_on_off=false, scale=SCALE);	    
	  // left
	  block (col=-5, row=-3, up=THIRD, width=1, length=1, height=6*FULL, nibbles_on_off=false, scale=SCALE);
	  block (col=-5, row=-1, up=THIRD, width=1, length=1, height=6*FULL, nibbles_on_off=false, scale=SCALE);
	  // front
	  ramp  (-4, 1, 1, 2, 0, scale=SCALE);
	  block (col=-5, row=1, up=THIRD, width=1, length=1, height=6*FULL, nibbles_on_off=false, scale=SCALE);	    

	  ramp  (-2, 1, 1, 2, 0, scale=SCALE);
	  ramp  (-2.5, 1, 1, 2, 180, scale=SCALE);
	  block (col=-3, row=1, up=THIRD, width=1, length=1, height=6*FULL, nibbles_on_off=false, scale=SCALE);	    

	  ramp  (-0, 1, 1, 2, 0, scale=SCALE);
	  ramp  (-0.5, 1, 1, 2, 180, scale=SCALE);
	  block (col=-1, row=1, up=THIRD, width=1, length=1, height=6*FULL, nibbles_on_off=false, scale=SCALE);	    

	  ramp  (1.5, 1, 1, 2, 180, scale=SCALE);
	  block (col=1, row=1, up=THIRD, width=1, length=1, height=6*FULL, nibbles_on_off=false, scale=SCALE);	    
	  // right
	  // big arc
	  color("blue") support (col=-5, row=-5, up=3*FULL, height=3*FULL, angle=270, thickness=1, scale=SCALE) ;
	  color ("red") support (col=-4.1, row=-5, up=6*FULL-THIRD, height=2.2, angle=0, thickness=7, scale=SCALE);
	  support (col=-3.9, row=-5, up=6*FULL-THIRD, height=2.2, angle=180, thickness=7, scale=SCALE);

	  support (col=-3, row=-5, up=3*FULL, height=3*FULL, angle=270, thickness=1, scale=SCALE) ;
	  color ("red")  support (col=-2.1, row=-5, up=6*FULL-THIRD, height=2.2, angle=0, thickness=7, scale=SCALE);
	  support (col=-1.9, row=-5, up=6*FULL-THIRD, height=2.2, angle=180, thickness=7, scale=SCALE);

	  support (col=-1, row=-5, up=3*FULL, height=3*FULL, angle=270, thickness=1, scale=SCALE) ;
	  support (col=-0.1, row=-5, up=6*FULL-THIRD, height=2.2, angle=0, thickness=7, scale=SCALE);
	  support (col=0.1, row=-5, up=6*FULL-THIRD, height=2.2, angle=180, thickness=7, scale=SCALE);

	  support (col=1, row=-5, up=3*FULL, height=3*FULL, angle=270, thickness=1, scale=SCALE) ;
	  support (col=-5, row=1, up=3*FULL, height=3*FULL, angle=90, thickness=1, scale=SCALE) ;

	  support (col=-3, row=1, up=3*FULL, height=3*FULL, angle=90, thickness=1, scale=SCALE) ;

	  support (col=-1, row=1, up=3*FULL, height=3*FULL, angle=90, thickness=1, scale=SCALE) ;

	  support (col=1, row=1, up=3*FULL, height=3*FULL, angle=90, thickness=1, scale=SCALE) ;
	    
	  // Roof
	  block   (col=-5, row=-5, up=6*FULL, width=7, length=7, height=1, nibbles_on_off=false, scale=SCALE);
	  nibbles (col=-3, row=-3, up=6*FULL+1, width=3, length=3, scale=SCALE, extra=false, filled=false, hscale=1);

	  color ("green") block   (col=-5, row=-5, up=6*FULL, width=7, length=1, height=FULL, nibbles_on_off=false, scale=SCALE);
	  nibbles (col=-4, row=-5, up=7*FULL, width=5, length=1, scale=SCALE, extra=false, filled=false, hscale=1);

	  color ("green") 	  block   (col=-5, row=1, up=6*FULL, width=7, length=1, height=FULL, nibbles_on_off=false, scale=SCALE);
	  nibbles (col=-5, row=-4, up=7*FULL, width=1, length=5, scale=SCALE, extra=false, filled=false, hscale=1);

	  color ("green") 	  block   (col=-5, row=-4, up=6*FULL, width=1, length=5, height=FULL, nibbles_on_off=false, scale=SCALE);
	  nibbles (col=-4, row=1, up=7*FULL, width=5, length=1, scale=SCALE, extra=false, filled=false, hscale=1);

	  color ("green") 	  block   (col=1, row=-4, up=6*FULL, width=1, length=5, height=FULL, nibbles_on_off=false, scale=SCALE);
	  nibbles (col=1, row=-4, up=7*FULL, width=1, length=5, scale=SCALE, extra=false, filled=false, hscale=1);

	  cyl_block   (col=-6,row= -6,up=THIRD,bottom_r= 2,top_r= 2,height= 8*FULL,nibbles_on_off= true, scale=SCALE) ;
	  cyl_block   (col=1,row= -6,up=THIRD,bottom_r= 2,top_r= 2,height= 8*FULL,nibbles_on_off= true, scale=SCALE) ;
	  cyl_block   (col=-6,row= 1,up=THIRD,bottom_r= 2,top_r= 2,height= 8*FULL,nibbles_on_off= true, scale=SCALE) ;
	  cyl_block   (col=1,row= 1,up=THIRD,bottom_r= 2,top_r= 2,height= 8*FULL,nibbles_on_off= true, scale=SCALE) ;
     }
}

To use this "as is", just set the scale in the beginning of the file.

7.3 Some mashups

Some history

In the following picture you can see two kinds of mashups made in 2010 with a Rapman printer and a rather coarse 0.4mm layer resolution.

  • Larger STL models put on top of bricks. I actually did these with Meshlab before I learnt how to use OpenScad.
  • Doblo bricks with webdings on top. Produced with either OpenScad alone or with Netfabb Studio. The basic version of Netfabb does have a 3D text. The pro version can directly export a mashup. Users of Netfabb Studio basic should also use either OpenScad or Meshlab for merging.
Some Doblo bricks (Duplo compatible). Various Skeinforge settings, some bad

Lego-compatibles icon blocks

Thanks to icon libraries like the noun project, there are thousands of interesting sets that allow creating lego-compatible blocks to used in games, simulations or just for decoration.

Women icon on compatible bricks (see our openscad tutorial that explains how to import SVG files)

A similar object, printed with t-glase (a bit too much extrusion) looks like this:

Women icon on compatible brick printer with t-glase on the Felix Pro 1 3D printer

T-glase is a plastic that is fairly easy to print, however it requires slow speed and certain amount of filament coming out.

The following wouldn't print well (some wall are too small) but it illustrates use of more complex SVG graphics.

include <../doblo-factory.scad>;
include <../lib/doblo-params.scad>;

cowgirl_lugos(); 
unit = NBO(LUGO);

module cowgirl_lugos () {
     difference () {
	  union () {
	       color ("lightgrey") doblo (col=0,  row=-4, up=0,  
					  width=4,  length=4, height=HALF, 
					  nibbles_on_off=false,
					  diamonds_on_off=false,
					  scale=LUGO);
	       color ("lightgrey") block (col=0,  row=-4, up=HALF,  
					  width=4,  length=4, height=HALF, 
					  nibbles_on_off=false,
					  diamonds_on_off=false,
					  scale=LUGO);
	       }

	  translate ([5,1,FULL+THIRD]) {
	       color ("pink") linear_extrude(height = 5, center = true, convexity = 10)
		    // cowgirl by Simon Child from the Noun Project
	       import (file = "noun_cowgirl_31624_cleaned.dxf");
	  }
}

     translate ([6*unit,0,0]) {
	  color ("lightgrey") doblo (col=0,  row=-4, up=0,  
				     width=4,  length=4, height=HALF, 
				     nibbles_on_off=false,
				     diamonds_on_off=false,
				     scale=LUGO);
	  color ("lightgrey") block (col=0,  row=-4, up=HALF,  
				     width=4,  length=4, height=HALF, 
				     nibbles_on_off=false,
				     diamonds_on_off=false,
				     scale=LUGO);
	  translate ([5,1,FULL+HALF]) {
	       color ("pink") linear_extrude(height = 5, center = true, convexity = 10)
		    // cowgirl by Simon Child from the Noun Project
		    import (file = "noun_cowgirl_31624_cleaned.dxf");
	  }
     }

     }
Cowgirl Lego-compatible bricks (see our openscad tutorial that explains how to import SVG files)

8 Printing

Printing Lego and Duplo blocks (and compatibles is never easy). There are several challenges:

Correct dimensions and wall thickness in particular

  • Real wall thinkness (and in particular of the crucial nibbles underneath) depend very much on your slicer settings. Several parameters could influence real wall thickness: layer height, layer width, wall re-inforcement, speed, temperature, the kind/brand of plastic, filling, etc. The only way to get this right is to print a few bricks and then play with both slicer and OpenScad settings. Create a new parameter file for each plastic/slicer setting. Make a copy of DobloFactory/lib/doblo-params.scad
  • Since PLA behaves a bit like wood, i.e. thin walls break easily, we suggest to print walls and nibbles underneath too fat. While the piece is still somewhat warm but not warm from the oven, press it gently on a real Lego plate. This way it will both fit and be a bit more solid than the thin "Lego"-like walls.
  • For ABS, tinker with OpenScad/slicer settings until you get it right.

First layer

As with any other difficult print, make sure to get the first layer right. I rather recommend calibrating the printer (nozzle is 1 sheet of paper away from the platform) then either printing extra base layers or at least 150% extra height. If the first layer is not precise, the nibbles will look all wrong. If you print too closely to the platform (PLA looks almost transparent and very wide) then you will have trouble pressing the brick down to make it fit. But too close is better than too far. If your print bed is too uneven and removable, then use glue and wash the piece off with hot water...

Roof

The roof will be ugly underneath and there is nothing you can do about it, except going back to a 3mm / 4mm layer height printer. You can make it less ugly, by slowing down and extruding a bit more. The top should be ok, but may need a bit more plastic flow than usual.

Resolution

Using 2.5mm layers layers and 3.5mm width (or similar) gives pretty good results, except if you plan to have small 2D1/2 extruded drawings on top. In the latter case make sure to have little or no retraction, plus high fill. Otherwise, the plastic may "dry up". Of course, you also can print with lower resolution (e.g. 0.1mm) but the resulting standard blocks do not necessarily look better

Retraction

I suggest using little retraction. It is better to have stringing than problems with plastic flow when printing the nibbles underneath the bricks ... Try and see.

Calibration

Try small objects first, e.g. a 3x3x3 doblo brick with PLA or a 2x2x3 block with ABS. ABS warps, therefore either use diamonds in the walls or strong glue !

Plastics

We printed most pieces with various sorts of PLA, ABS, T-glase, Laybrick, TPE also worked. In order to get the bottom right, you really have to slow down when printing with composites like laybrick, T-glase and various TPEs.

8.1 Post processing

If fit is too tight, heat the underneath with a heat gun (about 80 degs for PLA) then press the piece onto a real Lego or Duplo plate. You also can try an oven or a hair dryer. The latter only reaches about 55 to 60 degs, but this is better than pressing down cold plastic.

If fit is too loose, you cannot do anything about it. Change your slicer settings or re-generate the models with different settings.

8.2 Can your printer do it ?

We designed a simple suite of benchmarking pieces that you can use to test drive both DUPLO-compatible and LEGO-compatible sized blocks. Start with the DUPLOs pieces. Note however, that different kinds of structures may need different calibration. Print time is also a big factor.

Download: http://www.thingiverse.com/thing:2714

Print the four pieces and see if they fit like in the picture. The green blocks are Duplos/Legos. Pieces must fit in each possible combination.

If you know how to use OpenScad, it's better to generate the STLs again, since I had to cheat a bit with the width parameters in order to compensate the way the printer works. The ABS prints in the picture below did use the old version of doblo factory.

The *.zip file includes all files (except the picture)

Evaluation criteria:

  • 1a) Fit with real Duplos, i.e. respect dimensions of real Duplo and Lego bricks
  • 1b) First good good 5 layers of the brick. That's important for both esthetics and also vertical fit. That includes no warping !
  • 1c) Roof of the brick on top, must be flat and smooth
  • 1d) Roof of the brick underneath, no hanging filament
  • 2a) Overhang of the thumb
  • 2b) Smoothness of the palm and the back (difficult, of course faster prints will use bigger filament)
  • 2c) Smoothness of the fingers, nails (difficult)
  • 2d) Correct position of fingers
  • 3a) Amount of post-processing needed
  • 3b) Solidity (with respect to polymers used and size)
  • 4) I don't know exactly how - but all this should be put into relation with print time
Doblo-lugo benchmark V.1 - made in 2010 - Green pieces are DUPLOs/LEGOs(TM)

8.3 Printing pauses and recovery from print abortion

A larger structure like the stronghold takes over 24 hours to print. If you use PLA, it's ok to interrupt while you sleep or do other stuff. Unless you got some very special control software, your computer must stay on. With most software it is ok to move the printhead for extruding some plastic before continuing. It should move back to where it was.

However, if you encounter a card read error or a filament problem after 20 hours of printing, frustration can be high ! In the g-code article, we described how we managed to recover. It's not so easy, but certainly less painful than to restart.

8.4 Tips for RapMan / RepRap Mendel

The following skeinforge printing settings for the RapMan were made in 2010. You may consult the Skeinforge for RapMan to understand these.

  • Layer Thickness (mm) : 0.4
  • Perimeter Width over Thickness (ratio), i.e. how wide the filament should be compared to it´s height: 1.8
Fill
  • Fill of 0.1 should be ok (I tested with 0.05)
PLA
  • Use PLA on large objects to prevent warping (Notice: I should create a version of the bricks with big holes in the side walls for ABS printing)
  • Temperature: 210 (all) and Fan on
  • Raft: One interface layer
  • Flow rate: At least 380 for a layer thickness of 0.4 (for horizontal structures)
Other
  • Solid Surface Thickness for both ABS and PLA: 4
ABS

Since skeinforge does not really produce what I want, I'd suggest to produce sort of a normal "fat" raft code, then edit the g-code file and double up M108 and Fxxx values. Make it twice as fast, else it takes hours to get just the raft printed ....

Precision objects
  • See the Hand on duplo-compatible block example discussed on Thingyverse. E.g. a good quality/print time setting for Skeinforge is:
  • Layer Thickness = 0.35
  • Clip Over Perimeter Width = 0.15
  • Cool Type = Orbit
  • Min Layer time = 1
  • Extra shells on Base = 2
  • Infill perimeter Overlap
  • Infill solidity = 0.3
  • Solid surface layers = 4
  • Jitter = activated
  • Temperature = 210 for ALL
  • Flow Rate = 250
  • Feed Rate = 16

8.5 Tips for 2mm printers

Printers of the 2012 to 2014 generation can easily do Legos, but the floor underneath will probably be uglier than with older more coarse-grained printers. A 4x4 full height piece should take between 15 minutes and an hour depending on quality and resolution settings. For each different setting you may have to change OpenSCAD parameters (sorry). We suggest starting with "normal" settings that your slicer software provides for your printer. You then maybe should remove some retraction, slow down printing of the first layer, print 3-4 layers for floors and reinforce the walls a bit.

High quality prints are not necessarily better. As you can see in the pictures below, a fast "normal" 2.5mm/3.8mm print will just use straight lines for creating nibbles and other small stuff. A high resolution solution will create fills and these then bang into the walls and make them look less good ....

2.5mm layers and normal 3.8mm walls (Felixprinter 2.0, Repetierhost control software, Skeinforge slicer
2.0 mm layers and thin 0.25mm walls (Felixprinter 2.0, Repetierhost control software, Skeinforge slicer. Both nibbles and walls are "filled" with a zigzag pattern. Print time: more than an hour

Pick the right slicer

  • Some slicers have trouble printing LEGO since the attempt to strengthen thin walls. For example, it is fairly difficult to convince Slic3R to respect basic Lego wall and nibble definitions. Using Cura is much simpler, since one can define wall thickness.
  • Interaction between nozzle size and flow also seems to be different, but that could be explained by initial configuration settings that are not equivalent.

9 Educational use

(will be completed later, probably as a separate piece - 14:33, 13 April 2010 (UTC) ....)

9.1 Design of constructivist play kits

One of our goals is create a kit that allows the creation of 3D duplo-compatible "play" boards for various purposes from Kindergarten to Master level.

“In the LEGO System, complex cause-and-effect relationships can be built from the ground up by the relatively simple act of combining individual elements” (Ackerman et al. 2009: 76). While ready-made playmobil-like boards to not necessarily favor creativity, building such boards does. LEGO (ibid:77) argues that the benefits of playing with LEGO Systems are: Curiosity (bricks encourage exploration naturally), courage (one can take risks and make mistakes), exploration and investigation (Lego has an easy start, but can reach high levels), experimentation (change and fiddle), imagination (infinite combinations), reason and discipoline (uses a fixed logical structure), sociability (can be shared) and reflection (builders can step back and evaluate).

The same paper (p. 81)also argues that the system will support systematic creativity:

  • Preparation (problems that arrise curiosity)
  • Incubation (ideas being generated and unlocked)
  • Insight (thing falls in place and construction can begin)
  • Evaluation (decide if the insight is worth pursuing and may lead to "hard fun")
  • Elaboration (create the final form)

“The LEGO System is a system to think with. It encourages the process of making and reflecting, then making and reflecting again, in a thoughtful circuit of activity. In LEGO Serious Play participants are encouraged to build quickly and spontaneously, but then to take a step back and consider what they have made, and then review and change it as they see fit, with multiple iterations of individual and the collective activity. This build-then-reflect approach is really just one of the standard ways of using LEGO bricks which people naturally adopt.”

Teacher and educational technologists training

Since fall 2010, we used this library in classes in our master in educational technology

Example (in french) of a wakeup activity: Objets village de savants. Students had to create printable Lego mashups to populate a "village" of wise researchers...

A few notes on childhood learning

Ackerman, in an interview (retrieved 11:22, 13 April 2010 (UTC)) states that “LEGO provides a unique building system that encourages children to give form, or expression, to their wildest ideas in the most rigorous ways (hard fun)! Two things I enjoy most about LEGO: 1) the system offers endless possibilities. Yet, at the same time, not anything goes! The bricks have a mind [or logic] of their own, that the child learns to compose with to achieve their creations; 2) the system grows with the child, thus allowing the children to grow with it. As a constructivist at heart, I like play materials that let you in at different levels, and you can add complexity at will (low floor, high ceiling). Most children love to build things, and then bring them to life through play – or for real by adding special bricks, such as a motor, a light, or even a sensor.”

“Systems are crucial for creativity. Systems of science channel creativity towards asking specific questions, and solving or problems as in maths, chemistry and engineering. Systems of art channel creativity into many different and unique expressions, giving form to our imagination, feelings and identities, as in painting, music and sculpture. LEGO offers a unique—and widely recognized—system capable of channelling both, simultaneously. With LEGO you can bridge a stream, or transport an apple from A to B (scientific creativity) or build a fantasy creature, spaceship or landscape; or create metaphorical arrangements to evoke, project and represent feelings or identities (artistic creativity).” (Defining Systematic Creativity, retrieved 11:22, 13 April 2010 (UTC)).

Frans Orsted Andersen (2004) also argues that high PISA performances of the Danish Schools can be partly explained by the fact the learners more often encounter flow through "optimal learning environments". Scandinavian education is based on the three child i'es:

  • initiative
  • independence
  • intrinsic motivation (which in turn is part-of flow). “Being able to base the learning processes on high levels of pupil

intrinsic motivation through a special teaching model enhancing flow experiences - indeed seems to be the key to understanding the successful optimal learning environments of the sampled Danish schools in this study.” ([Anderson, 2004: 14).

In addition to using such bricks and systems in normal schools and at home, DUPLOs and other construction kits seem to popular in special education (refs. needed).

Adult learning

Another potential avenue for the doblo factory comes from so-called simulation and gaming. Some adult gaming environments only use physical support, others rely entirely on computer-support and, finally, others on mixed support.

Our aim is to procude visual, mostly 2D, iconic languages to support various kinds of project-oriented learning.

9.2 CAD/CAM, 3D and CS education

  • Introduction to 3D graphics and design (learn about positions) and simple use of OpenSCAD
  • "End-user 3D programming" environment (e.g. students could add other primitives)

10 Bugs, to do

Bugs
  • cyl_block nibbles can't handle top_r < 2 and rational numbers
Needed
  • a pillar with both supports for bottom and top (i.e. 2x4 directions)
Improvements
  • replace support modules by triangle_forward, triangle_right, etc.
  • Parametrize all numbers
  • Make it also Lego compatible
Adjustments
  • make the nibbles underneath a bit fatter maybe
  • Figure out the best skeinforge settings for ABS and PLA

11 Links and credits

Credits for the OpenScad code

STL files

OpenScad
End-user programming / microworlds
Lego
What's the relationship between playing with Lego and creation of Google ?

12 Bibliography

  • Ackermann Edith; David Gauntlett and Cecilia Weckstrom (2009). Defining Systematic Creativity, LEGO Learning Institute, Summary, PDF download
  • Andersen, Frans Ørsted (2004), Optimal Learning Environments at Danish Primary Schools, LEGO Learning Institute Abstract/PDF download
  • Claxton, Guy (1997). Hare Brain, Tortoise Mind, Fourth Estate, London.
  • Claxton, Guy, What’s the Point of School, One World Publications, Oxford, 2008.
  • Winnicott, D.W. (1989) Playing and Reality. London, New York: Routledge.