# Creating Paper Templates and Stencils in OpenSCAD

Source: https://rickcarlino.com/2023/printing-openscad-designs.html
Published: 2023-02-24

![](/images/2023/stencil.jpg)

OpenSCAD is usually used for 3D modeling. But it also supports a "2D subsystem" for two dimensional drawings (stuff like `circle` and `square`). This article teaches you how to make stencils and templates that will match your target measurements exactly. For example, you could make a stencil for a painted sign or guideline for a wood project that uses a jigsaw.

What You Need:

* A ruler that uses the same unit of measure as your drawing. If your drawing is in millimeters, use a metric ruler.
* A desktop paper printer.
* An OpenSCAD drawing.

## How to Print in OpenSCAD

Printing a drawing in OpenSCAD is simple:

* Create an OpenSCAD project.
* Render it.
* Export as PDF (File -> Export -> Export as PDF).

This is where the problem starts: your drawing is not 100% proportional, and one millimeter in OpenSCAD will NOT equal one millimeter on the paper in most cases.

For example, my printer would shrink 90mm objects down to 80mm. What a rebel!

## Fixing Proportions With scale()

Luckily for us, OpenSCAD is aware of the problem with scaling and provides calibration guides. When you export the PDF, it will have a ruler alongside both edges of the paper.

Make a note of how big the guidelines are on the paper:

```
OPENSCAD_LENGTH = 90;
```

In my case, the guidelines went from 0 to 90 and -90 alongside the edge of the page. Don't worry if your guidelines look different.

After that, I took my ruler and measured how long the guidelines actually were in the real world.

```
PAPER_LENGTH    = 80;
```

As I mentioned, even though the guidelines were supposed to be 90mm, my printer printed them out as 80mm. My printer was a little too eager to be "helpful", it seems.

Now that I know my real-world size versus OpenSCAD size, I can use the OpenSCAD scale() operation:

```
scale(OPENSCAD_LENGTH / PAPER_LENGTH) {
    // PUT YOUR ORIGINAL OPENSCAD DESIGN HERE
}
```

At this point, you can export the project as a PDF and print it to paper. Congratulations! You now have a paper stencil/template that is exactly the correct size.

## Experiment: Printing Coin-Size Holes

If you want to be sure this process works on your machine, you can try printing US coins onto a paper and lay the coins over the final template to ensure calibration succeeded.

The list below contains the size of common coin sizes (in mm) for US-based readers:

* Dime - 17.91
* Penny - 19.05
* Nickel - 21.21
* Quarter - 24.26

## ...But I Just Want to Copy/Paste a Snippet

Ok, fine:

```c
OPENSCAD_LENGTH = 90; // FIND THIS ON YOUR PDF OUTPUT!!
PAPER_LENGTH    = 80; // DIFFERENT FOR EVERY PRINTER!!!

scale(OPENSCAD_LENGTH / PAPER_LENGTH) {
    // PLACE YOUR ORIGINAL DESIGN HERE
}
```
