-
Notifications
You must be signed in to change notification settings - Fork 1
Generating The Models
A 3D print requires a STL file, which describes the surface geometry of a 3D object without its color, texture or other common CAD model attributes, and a G-code files, which tells the 3D printer how to make an object.
For generating the STL files, OpenSCAD was used, it is a 3D CAD Modeller catered towards programmers.
Here is an example of openSCAD code,
// Set the initial viewport parameters
$vpr = [90, 0, 0];
$vpt = [250, 0, 80];
$vpd = 500;
logosize = 120;
// Generated a text mode of param1 with arguments
// translate object by (8, 5, 2)
translate([8, 5, 2]) green() t(param1, 16, 1.3);
// Helper to create 3D text with correct font and orientation
module t(t, s = 18, sp=1) {
//rotate([90, 0, 0])
linear_extrude(height = 2)
text(t, size = s, font = str("Liberation Sans"), spacing = sp, $fn = 16);
}
// Color helpers
module green() color([81/255, 142/255, 4/255]) children();
module black() color([0, 0, 0]) children();
This code generates a 3D model of the text specified by param1. With this code, STL for text can be generated by inputting the value for param1. For openSCAD, there are command line commands that accepts arguments, https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment. In order to generate the 676 two-letter initials, a script was written to call the commands with param1 arguments. It takes in a name for the final file, a parameter, and a base SCAD file.
Here is the python script:
for char1 in ascii_uppercase:
for char2 in ascii_uppercase:
subprocess.call(["/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD", "-o", "{}.stl".format(char1+char2), "-D", "param1=\"{}\"".format(char1+char2), "name_initials.scad"])
In order to print the STL file, each STL requires a corresponding G-code file. To generate the G-code file, slic3r is used. Slic3r like openSCAD can be used through command line, http://manual.slic3r.org/advanced/command-line. It takes in a STL file and a config file. Follow is the script to generate all the G-code for the STL files,
import subprocess
from string import ascii_uppercase
for char1 in ascii_uppercase:
for char2 in ascii_uppercase:
subprocess.call(["Slic3r.app/Contents/MacOS/slic3r", "{}.stl".format(char1), "-load", "config.ini"])