How the enclosure generator works
23 August 2026
The enclosure generator is the one I rewrote most often. An enclosure is where every small mistake becomes a physical fact. A wall 0.2 mm too thin flexes when you push a USB cable in. A port opening 1 mm off and the plug does not go in at all. This post is about what the generator does with your numbers and where those numbers come from.
The board is the starting point
When you pick a board, the generator does not start from a box. It starts from the board itself, meaning its outline, its hole pattern and the connectors along its edges. Eleven boards are in the table right now. Pi 5, 4, 3, Zero and Zero 2 W, the Banana Pi M2 Zero, Pico, Arduino Uno and Mega, ESP32 DevKitC, Wemos D1 mini, and a "custom" entry where you type your own holes. The numbers come from the vendors' mechanical drawings rather than from a board on my desk, which is why the source says "nominal" next to them and why I still put calipers on a board before printing standoffs for it the first time.
Every connector is described by which edge it sits on, where its center is along that edge, and how high that center sits above the board. The Pi 5 has seven of them. The odd one is the microSD slot. It lives under the board, 2.8 mm below the top surface, so its opening must be cut lower than the standoffs suggest. I found that out by printing a case with no way to get the card out.
From the board to the cavity
The cavity around a Pi 5 is 92 by 64 by 30 mm, the board plus a little air on each side and room above the tallest connector. The board sits on standoffs over its four holes. The pilot hole in each standoff is 0.85 times the screw diameter, so an M2.5 self-tapper cuts its own thread and holds.
Walls are 2.4 mm by default. The generator refuses anything under 1.6 mm, because below that a wall prints as two 0.4 mm paths and it moves when a plug goes in. The lid can go down to 1.2 mm since nothing pushes on it sideways.
There are two lids. The snap lid has a skirt that drops into the cavity with a 0.35 mm bead around it. It pops on and off with a fingernail and needs no hardware. The screw lid has four corner bosses for M3 self-tappers, and on a Pi those bosses land exactly where the board's corner holes are. The generator checks for the collision and tells you the cavity that clears it (108 by 80 mm for a Pi 5 instead of 92 by 64), or suggests the snap lid instead. The library pages took the bigger cavity.
Cutting the openings
Each opening is a cutter, a small solid the shape of the connector pushed through the wall. About sixty connector shapes are in the library, from USB-A double stacks and micro-HDMI to RJ45, barrel jacks and toggle switches. Vents work the same way, as a field of small cutters kept away from the corners, the floor and the seam, and kept clear of the connectors so a slot never runs into a port.
Then all the cutters get subtracted from the shell. Here is the bug. For a week, the screw counterbores on the lid printed solid. Each screw position has two cutters, the through hole and the wider counterbore on top of it, and they overlap. I was merging every cutter into one mesh before the subtraction because it was faster. Where two cutters overlap, the merged mesh intersects itself, the boolean library flips parity inside the overlap, and that region stays uncut. A plugged hole every time, only on the lid, only under a screw head. The fix was to subtract each cutter as its own solid, with a one-at-a-time fallback if the combined pass chokes on a bad one. It costs about a second. It is correct every time.
The parts you do not see
A few things never show up in the preview. The bottom edge has a chamfer, and not for looks. The first layer of any print squashes out into an elephant foot, and a case without the chamfer rocks on it. The counterbore under a lid screw is a shallow cylinder rather than a cone, because a cone needs support when the lid prints upside down and a shallow counterbore takes a pan head as well as a countersunk one. At the end the two parts get laid out for the plate, base open side up and lid flipped, so neither needs supports.
What it still gets wrong
The port heights assume the connector is soldered straight. A crooked USB-C on a cheap clone board sits 1 mm off and the plug scrapes. Eleven boards is not many either. Next on the list are the Pi Compute Module carriers and a couple of ESP32-S3 dev boards with holes in the usual places. If your board is not in the table, the custom option takes the width, depth and hole positions, and the "Report an issue" button sends me your numbers. That is how most of the current eleven got in.