3D Printing the Alphabet

Mathias Hansen
4 min readFeb 11, 2016

I got an interesting question from a Montessori school recently. They had this material that consisted of a big box with a slot for each letter in the alphabet.

Unfortunately many of the letters had gone missing over time, and they now no longer had the complete alphabet.

I figured that it would be a relatively simple job for the 3D printer. It turned out to be so, albeit very time consuming yet rewarding.

From photo to sprites

I started out by taking a picture of the wooden box (just using a regular phone camera).

As you can see, the shape of each letter was already painted on the box, so I wanted to use those as the base for my 3D models — I actually ended up taking a second picture for just the vowels, since they got cut off a little bit in this photo, due to the angle.

Next step was to slice out each letter. I happened to have Photoshop at hand, but Gimp or other image editing software should work just as well. I used a combination of the “magic wand” tool, pared with adjust the contrast and reducing the number of colors in the photo to make editing easier.

After fiddling around for a little bit, I now had an individual file for each letter. I removed the background completely and made the foreground black, just to simplify things.

Vectorizing the sprites

This was the part of the project that I was mostly worried about. The letters I had at this point were completely rasterized (i.e. pixels on a grid). I had to vectorize the letters in order to turn them into 3D objects.

I really wanted to automate the whole process from here, so I didn’t have to draw the vector shapes for each letter by hand. Both in the interest of time but also because I don’t know anything about drawing vector shapes.

I knew that it was possible to convert raster to vector for simple shapes like these, and in the past I’ve used various online conversion tools for one-off things. This wouldn’t really cut it for this project though, as it would prevent me from automating it completely.

Luckily, I found an amazing open source project called potrace that did just that. A quick “brew install potrace” later, I was able to move on.

Generating the 3D models and putting it all together

I’m already a big OpenSCAD user and fan, so my plan was just to import the vectorized image to OpenSCAD and then extrude it to a nice thickness of 2mm.

Turns out that you can invoke OpenSCAD from the command line and have it render to .stl without opening the GUI.

I ended up having to convert the files a few times back and forth as some of the tools were very specific as to what formats they like. potrace needs a bitmap as input and outputs .eps and in the other end OpenSCAD only takes a specific type of .dxf file as input.

This is the final bash script that I whipped together. It simply converts every single .png file in the current directory to an .stl file, ready for 3D printing.

I’m sure that there might be a way to make this process cleaner and more efficient, but hey — it worked wonders for my use case.

Printing

All the letters were printed on a Lulzbot Mini. This was the most time consuming process, as the build area is pretty small. I needed 5 copies of each letter, and I was able to fit 2–5 letters per print job. I used Cura to lay out the models manually, trying to fit as many as possible.

I kind of lost track at this point, but I think that I ended up with around 35 print jobs, each taking between 20–60 minutes. OctoPrint made it pretty efficient, with the ability to queue up jobs. So all I had to do was remove the printed parts from the build plate and then kick off the next one, but obviously 3D printing is not ideal for “mass manufacturing”.

And here’s the final result!

It sure wasn’t the fastest or most practical way to solve the problem, but it was super fun working on automating the process and seeing the final product. The school was certainly also excited about getting their letters back.

--

--

Mathias Hansen

Father & married to the lovely @mjwhansen. Lead Software Engineer at Storyblocks. Co-founded Geocodio, Pixelbug, and Capital Laravel Group