pcb-rnd knowledge pool


Exporting the board in STL

export_stl by Tibor 'Igor2' Palinkas on 2020-08-10

Tags: howto, stl, export, export_stl, 3d, model, mechanical, mech, dimension

node source



Abstract: The main purpose of export_stl is to provide 3d output to mechanical CAD programs. The 3d model includes at least the board outline but can also include holes, cutouts and component models.


Exporting the board outline and holes/cutouts

The board outline should be drawn on the outline layer, which should be in a boundary layer group (with purpose set to uroute normally). The drawing of the outline shall contain a closed loop of lines and arcs with perfectly matching endpoints (no gaps). The thickness of such lines and arcs are ignored (taken to be zero).

The export plugin will consider only one board outline. If the board has multiple outlines, the one closest to the the top-left corner (when looking from the top) will be used.

Internal cutouts within the outline can be drawn using the same layer, or any "slot" layer (in a layer group type mech , with purpose set to uroute or proute).

It is possible to disable rendering such cutouts, using the --no-cutouts command line argument (or checking out the cutouts checkbox in the GUI)

Holes and slots from padstacks are controlled by the following arguments:

Exporting component models

Unless the --no-models is specified, subcircuits with an STL model available are included in the output. To include a model, the subcircuit must have an attribute with key stl and value being the file name of the stl model for the part (without a path). For example:


The plugin will do a normal footprint library search for the file, so the easiest method is to place the stl file next to the footprint file.

WARNING: unlike the subcircuit itself, the stl model is not stored in the board file, it is only a reference; the reference may break if the board is exported on a different system where the stl file is not available in the library.

A tricky corner case is multiple stl files with the same name in the library. The code will always pick the first, in order of library search paths, in case the redundancy is between two libs. If the redundancy is within a single lib, the choice is unspecified. It is best practice to use long, unique model names.

Matching the model orientation with the subcircuit is achieved through the optional stl::translate and stl::rotate attributes of the subcircuit. When present, the value shall be three numbers separated by spaces or comma. The stl model is first rotated (around its own origin) by stl::rotate then moved by stl::translate.