# Designing enclosures for electronics: fitting a board on the first print

A maker's guide to measuring a board, sizing walls and standoffs, adding vent slots, choosing a lid fit, and clearing connectors before you ever hit print.

---

An electronics enclosure fails in a specific, predictable way: a mounting hole doesn't
line up, the USB port sits 2 mm behind the cutout, or the lid won't close because a
capacitor is taller than the standoffs. None of that is bad luck. It's a measurement
that got skipped or a clearance that got guessed instead of calculated.

This guide covers the six decisions that determine whether a board fits an enclosure the
first time: measuring the board, picking a wall thickness that survives FDM printing,
sizing standoffs to lift the board off the floor, adding vents without weakening the
shell, choosing how the lid closes, and clearing the connectors you'll plug into. Then
it covers turning that spec into one prompt and tuning it with sliders instead of
reprinting from scratch.

## Measure the board, not the datasheet thumbnail

Every enclosure starts from the board's outline and hole pattern. Get both from the
real board with calipers, not from a product photo.

**Length and width.** Measure the board's overall footprint corner to corner, then add
your intended side clearance (2 to 3 mm per side is a reasonable default; more if you
want room for wiring or a battery alongside the board). That total is your interior
cavity dimension, not the outer dimension of the box.

**Mounting-hole spacing.** Measure hole center to hole center, not edge to edge. This is
the number that actually determines whether your standoffs line up, and it's the one
people guess most often because it looks like it should just be "near the corners."

Two common hobbyist boards make good worked examples because they behave differently:

- **Raspberry Pi (Model B+ through 4B) mounting holes sit on a clean 58 mm x 49 mm
  rectangle**, four holes sized for M2.5 screws. Because it's a true rectangle, you can
  place four standoffs symmetrically and trust the math.
- **Arduino Uno's four mounting holes are not on a clean rectangle.** The board is
  roughly 68.6 mm x 53.4 mm, but the hole positions are staggered by design history, not
  a tidy grid. Model an Uno mount by eyeballing "four corners" and at least one hole
  will miss. Measure all four hole centers individually and use those coordinates.

The lesson generalizes: never assume a hole pattern is symmetric just because the board
looks symmetric. Measure every hole you plan to use.

## Wall thickness for FDM

An enclosure wall does two jobs: it holds its shape under the light stress of handling,
and it gives screw bosses and standoffs something solid to root into.

**2 to 3 mm is a solid default wall thickness for a small electronics enclosure printed
in PLA or PETG.** That's usually 4 to 6 perimeters at a typical 0.4 mm nozzle, enough to
resist flexing when you pick the box up or a cable tugs on a port. Thinner than 2 mm and
large flat panels can bow enough to pop a press-fit lid loose over time.

**Go thicker, 3 to 4 mm, on any wall that carries a screw boss or a standoff base.**
Those features need surrounding material to avoid cracking when a screw is driven in; a
boss built into a 2 mm wall has almost no margin before the screw tip breaks through.

**Keep wall thickness consistent where you can.** Sudden thickness changes are where FDM
prints warp and stress concentrates, which matters more on an enclosure than a bracket
because enclosures have long, flat, unsupported panels.

## Standoff and boss height: lifting the board off the floor

The board needs to sit above the enclosure floor for two reasons: solder joints and
through-hole leads stick out the bottom, and many boards have components (a micro-USB
jack, an SD card slot) that need room underneath.

**A standoff height of 3 to 5 mm is enough for most hobbyist boards with modest
underside components.** That clears typical solder joints and header pins with margin.
If a connector or component protrudes noticeably from the bottom (a shield, an add-on
board, a battery holder soldered underneath), measure that protrusion and size the
standoff to clear it plus 1 mm.

**Boss diameter should give the screw at least 1.5 to 2 mm of surrounding plastic.** For
an M2.5 self-tapping screw, a 5 to 6 mm outer boss diameter with a pilot hole around
2.0 to 2.1 mm (a hair under the screw's minor diameter, so the plastic threads form as
the screw bites) is a workable starting point. Going too thin here is the most common
way a boss splits the first time someone drives the screw home.

## Vent slots for airflow

Any board that runs warm (a Pi under sustained load, a stepper driver, a power supply)
benefits from airflow instead of a fully sealed box.

**Slots beat round holes for both airflow and printability.** A row of rectangular
slots, roughly 2 to 3 mm wide with 2 to 3 mm gaps between them, moves more air per unit
of wall than the same area in small round holes, and slots print cleanly without
supports when oriented vertically on the wall.

**Put vents where the heat actually is, not symmetrically for looks.** A vent pattern
above a voltage regulator does more good than the same pattern spread evenly around the
box. If you don't know where heat concentrates, venting the top and one long side gives
a natural chimney effect (cool air in low, warm air out high) without guessing hotspots.

**Keep vent slots away from screw bosses and corners.** A slot that intersects a boss or
a corner removes material from the exact spots that need it most for strength.

## Lid fit: press-fit lip vs. screw bosses

**A press-fit lip (a small step or ridge the lid snaps or slides onto) is fastest to
use and good for enclosures you'll open occasionally**, prototyping boxes, anything
you'll reprint often while iterating. It needs a bit of interference, generally 0.1 to
0.2 mm on the fitting surfaces for FDM, so the lid holds without a fastener but still
comes off by hand. Too little interference and the lid rattles; too much and it won't
seat, or cracks the lip going in.

**Screw bosses in the corners of both halves are the better choice for anything that
gets handled, shipped, or opened repeatedly.** They add assembly time (four
self-tapping screws, four bosses per half) but the lid stays closed reliably and you
can remove it as many times as you want without wearing out a friction fit.

A reasonable default: prototype with a press-fit lip while dialing in board fit, then
switch to screw bosses once the design is stable and the box needs to survive real use.

<TryMeshra />

## Clearance around connectors

Connector cutouts are where "it fits on the bench" and "it fits in the box" diverge:
the cutout has to line up with a port mounted on the board, not floating in space.

**Measure from a fixed board reference (an edge or a mounting hole) to the center of
the port**, not from the connector itself. Locate the cutout in the enclosure wall
using that same reference so the two stay aligned even if you nudge the board later.

**Oversize the cutout, don't cut it exact.** A USB-A or USB-C cutout sized 1 to 1.5 mm
larger than the connector body on each side accounts for print tolerance and lets a
cable plug in at a slight angle without binding against the wall. An exact-sized cutout
looks tidy in a render and is a constant annoyance in practice, since the cable
connector is almost always a little larger than the board-mounted socket it plugs into.

**Leave room to grip the cable, not just clear the connector.** A barrel power jack or
USB cable needs a few extra millimeters of open space around the cutout so your fingers
aren't fighting the enclosure wall every time you plug in.

## Describing the enclosure to Meshra in one sentence

Once you have your spec, hand it to Meshra as one sentence and let the numbers do the
work:

- Vague: "a case for a Raspberry Pi"
- Specific: "an enclosure for a Raspberry Pi 4 with a 58 by 49 mm mounting hole
  rectangle, 3 mm walls, 4 mm standoffs, a vented top panel, a press-fit lid, and a
  USB-C cutout on one short side"

The second version carries your measured spec straight into the prompt: hole pattern,
wall thickness, standoff height, vent location, lid style, connector placement. Each
becomes a named, adjustable value in the parameter manifest Meshra generates alongside
the CadQuery code, which is what makes the next step possible.

## Tuning wall thickness and standoff height with sliders

This is where a parametric enclosure earns its keep over a static file you found
online. Say the first print seats the board fine but the lid rubs against a tall
capacitor, or the walls feel thinner than you'd like once you have it in hand. You don't
redesign the box: you open the parameter drawer and change the one number that's wrong.

Raise the standoff height from 4 mm to 6 mm to clear that capacitor, and the same
CadQuery program re-executes with the new value: the standoffs get taller, the mounting
holes stay exactly where they were, and the surrounding wall thickness is untouched.
That re-execution is deterministic and free, the same program running again with one
number changed, not a new AI generation. Our post on
[how Meshra turns a sentence into a printable part](/blog/from-a-sentence-to-a-printable-part)
covers how that parameter manifest and slider-driven re-run work.

The same applies to wall thickness: bump the wall thickness slider from 2 mm to 3 mm
and every wall, boss, and vent slot in the model regenerates around the new thickness,
because they're all defined relative to it in the code, not hand-placed. That's the
difference between adjusting a parametric enclosure and redrawing a mesh from scratch
every time a dimension is off.

## Where to start

If you already have your board's hole pattern measured, browse the
[maker starters in the template gallery](/templates) for an enclosure base close to
your board, or open the builder and describe your enclosure in one sentence. Either
path gives you a parametric box with a slider for wall thickness, standoff height, and
every dimension you're likely to correct after the first test fit. Free and Maker plans
include AI generations for exactly this kind of iteration; see [pricing](/pricing) for
current allowances, or [create an account](/sign-up) to save your enclosure.

A box you can measure once and adjust in minutes is a fundamentally different tool than
a box you have to redraw every time a standoff is a millimeter too short. Measure the
board, describe it in one sentence, and let the sliders handle the rest.
