DEV Community

Cover image for How to Create Letter Molds and Stamps for 3D Printing on OpenScad
Erika Heidi
Erika Heidi

Posted on

How to Create Letter Molds and Stamps for 3D Printing on OpenScad

In these times of social isolation and quarantine, we're doing everything we can to entertain our kids and have a few moments of peace in the household. For some of us who are lucky enough to have a 3D printer at home right now, there are quite a few cool little projects that can be downloaded for free and printed at home.

If you are anything like me, however, you might feel the itch to create your own models, just because.. you can?

I wanted to create some simple play-dough molds to play with my 3 year old daughter this weekend, and while it's not hard to find such models for download out there, I always feel fascinated by using code to create 3D models and bring them to life with my printer. So that's how I chose to spend my Saturday morning today - messing around with OpenScad. This mold also doubles as stamp, if you use a string instead of single letter when printing it out.

OpenScad Overview

OpenScad is a free and open source CAD software available for Linux, Windows and Mac. The big deal is that with OpenScad you use code to create solid 3D CAD objects.

If you are familiar with image manipulation and transformation via code, you might find that OpenScad is quite straightforward, once you see a few different examples and get used to its syntax (which actually resembles a lot PHP, so another reason why I liked it).

The software comes with many examples that you can try out to get familiar with the built-in API. You can find this under the menu File -> Examples.

OpenScad overview

A handy cheat sheet is available under the menu Help -> Cheat Sheet.

Creating 3D Text with OpenScad

In OpenScad, you have different functions that can create 3D shapes such as cubes and spheres, but it is typical to create 3D shapes and then use the linear_extrude function to turn them into 3D objects. This is how you write text.

The following code creates a 3D text:

font = "DejaVu Sans:style=Bold";
letter_size = 40;
height = 10;
string = "DEV";

linear_extrude(height) {
    text(string, size = letter_size, font = font, halign = "center", valign = "center", $fn = 64);
}
Enter fullscreen mode Exit fullscreen mode

You may need to change the font to a font supported by your system. Check the OpenScad menu Help -> Font List for a list of available fonts.

The preview window will show the following:

Simple Text Preview

If you were to print this as is, you would get 3 separate letters. You could use a rectangle as base to print the text as a unique piece, like a nametag. For that, you'd want to use the union function:

font = "DejaVu Sans:style=Bold";
letter_size = 40;
height = 10;

string = "DEV";
textlen = len(string);

box_width = letter_size*textlen*1.1;
box_height = letter_size*1.5;

union() {
    linear_extrude(1) {
        square([box_width, box_height], center = true);
    }

    linear_extrude(height) {
        text(string, size = letter_size, font = font, halign = "center", valign = "center", $fn = 64);
    }
}

Enter fullscreen mode Exit fullscreen mode

This code will give you the following object:

Embossed Text

Now, suppose you'd like an inverted effect, like a stencil. Instead of union, you'd use difference in this case:

font = "DejaVu Sans:style=Bold";
letter_size = 40;
height = 10;

string = "DEV";
textlen = len(string);

box_width = letter_size*textlen*1.1;
box_height = letter_size*1.5;

difference() {
    linear_extrude(height) {
        square([box_width, box_height], center = true);
    }

    linear_extrude(height) {
        text(string, size = letter_size, font = font, halign = "center", valign = "center", $fn = 64);
    }
}
Enter fullscreen mode Exit fullscreen mode

This code will give you the following object:

Inverted text

If you want to turn this into a mold or cookie cutter thou, you'd like to have only the outline of the letters, instead of a full "background". For that, we can use the offset function. To create an outline, we use two different offsets on top of the same 2D drawing; this 2D outline can then be extruded. The following example creates an outline for the specified text:

font = "DejaVu Sans:style=Bold";
letter_size = 40;
height = 10;

string = "DEV";
textlen = len(string);

linear_extrude(height) {
    difference() {
        offset(r=-1) {
            text(string, size = letter_size, font = font, halign = "center", valign = "center", $fn = 64);
        }

        offset(r=-2) {
            text(string, size = letter_size, font = font, halign = "center", valign = "center", $fn = 64);
       }
    }
}
Enter fullscreen mode Exit fullscreen mode

This will give you the following object:

stamp without base

Although this looks ok, you'd need something to "hold" the insides of some letters in place, like it's the case with the letter "D" in this example. We can place a rectangle base on top of the letter then, to make sure you won't get a mirrored effect when cutting the dough with this mold.

The final code rearranges things a bit and creates a few modules (this works like a function) to avoid duplicating the same piece of code as we've done before with the text. This will create a nice cookie/dough cutter that also doubles as stamp, and you can customize as desired.

Result:

Final result

I hope you have enjoyed this short OpenScad tutorial! If you have any questions, feel free to leave a comment ;)

Top comments (1)

Collapse
 
reality4devolution profile image
Reality4DEvolution • Edited

hello, excellent review!
instead of the last step, rectangle, to hold the letters, how to create a top for the INDIVIDUAL letters, so you have HOLLOW UNCONNECTED letters?

I am a beginner beginner at scad, i can use it from models of thingiverse, but have not learned its intricacies.
all i want to do, for example, is create a top cover for the "D" (not the center of the "D"

any help to refine the code is appreciated

what i really want are hollow letters, for christmas decoration use. - solid front face, hollow sides, i can then put light in; and i can also make solid flat letter, to glue to the back, and then i can string these together, for example
and also how to make the FACE of the letter be more than a couple layers thick, for example, about 2.4 mm, for improved strength

"My family wishes you a Merry Christmas", and hang it on front of house.

i can import letters to Sketchup, add a hook to it, etc