Dynamic Duplicator Script for OpenSCAD

Printing many small objects on a 3D printer is a chore no more. Below is a dynamic script for OpenSCAD that will duplicate a model the requested number of times. The script performs some clever math to arrange the duplicates in columns and rows.  You can then export to an .stl and print several objects at once.

The example model pictured can be found here: http://www.thingiverse.com/thing:172553

Duplicator Script Example Multi Object Printing

 

/*******************************************
Dynamic Duplicator Script for OpenSCAD
Author: Dustin Westaby
Website: http://www.westaby.net
Last revised: 7/26/2015
********************************************/

// Model parameters
model_filename = “star_w_hole.STL”;
model_scale = 1;
model_spacing_y = 50;
model_spacing_x = 60;
z_position = 18.5;
model_rotate = [0,0,0];

//examples: 1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36
number_of_copies = 9;

/******************************************
DO NOT MODIFY BELOW THIS LINE
******************************************/

columns = ceil(sqrt(number_of_copies));
rows = ceil(number_of_copies/columns);

for(j=[1:columns])
{
    for(i=[1:rows])
    {
        scale(model_scale)
            translate( [-model_spacing_x*j, -model_spacing_y*i, z_position] )
                rotate(model_rotate)
                    import(model_filename);
    }
}