Ohmforge PCB Enclosure Generator (STL)
Board outline, holes, parts and connectors in – a verified, printable base and lid STL out.
Try an example: Sensor node with USB-C, barrel jack and header – snap-fit lid · Same board with lid screws and ventilation slots · Slim 65 × 30 mm board, M2.5 self-tapping screws, friction lip · Notched polygon board with a relay and a screw terminal
How it works
Describe a circuit board as JSON – outline, mounting holes, component boxes, edge connectors and keep-outs – and get a two-part 3D-printable enclosure: base with standoffs for heat-set inserts or self-tapping screws, connector cut-outs, and a lid with a snap-fit or friction lip or corner screws, optional vents and windows. Both STL files are checked to be watertight and manifold, cut-outs and standoffs are probed on the final mesh, and every part is tested for collisions. Includes a dimensioned drawing and an OBJ assembly.
- The cavity is the board's bounding box plus the gap on every side; the outer shell adds the wall. With lid screws the cavity grows until the corner posts (overlapping the walls) clear the board. Heights: floor, standoff, board, the tallest part or connector plus the space above it (at least the lip height plus 0.5 mm above the board), then the lid.
- Base and lid are each built as one layered solid: ordered add and subtract polygons over height ranges (shell, cavity, standoffs with blind holes, posts, connector cut-outs = connector box + clearance extended through the wall, snap grooves; lid plate, lip, snap bumps, vents, windows, notches where parts reach the lip). All polygon edges form one planar arrangement split at every crossing; a trapezoidal decomposition gives convex cells that share whole edges, and the surface consists of the cell faces between filled and empty prisms. This yields closed, consistently oriented meshes without mesh booleans.
- Verification on the final meshes: watertight, manifold, positive volume and a single shell (shared Renderloom mesh engine), again after a binary-STL round trip through the mesh analyzer; surface volume (divergence theorem) equal to the volume of the filled prisms; generalised winding numbers 0.005 mm inside and outside every opening edge and around every standoff hole and ring; every part, connector and the board tested as boxes against every material prism of base and lid.
- Typical sizes: clearance holes per ISO 273 (medium: M2 2.4, M2.5 2.9, M3 3.4 mm); pilot holes for self-tapping screws in printed plastic about 0.8 × d (1.6, 2.0, 2.5 mm); common short brass heat-set inserts need 3.2, 3.6 and 4.0 mm holes and are 3–4 mm long. Holes are polygons whose flats lie on the nominal diameter; bosses are inscribed polygons.
- Snap fit: bumps on the outside of the lip reach the snap depth past the lip, so they catch (snap depth − lip gap) in grooves cut 0.1 mm deeper into the wall, in the middle of each straight wall that has room and no opening. The lid STL is turned over for printing (plate on the bed); the base prints as it stands.
Screw, insert and boss sizes are typical values, and connector dimensions in the catalogue are generic. Check them against your parts' datasheets. Printability and fit are not guaranteed: tolerances depend on your printer, material and slicer, so print a test piece first.
Sources
- ISO 273: Fasteners — Clearance holes for bolts and screws (ISO)
- STL format (StereoLithography Interface Specification) (Marshall Burns, Fabbers.com)
- Computational Geometry: Algorithms and Applications, ch. 6 (trapezoidal maps) (de Berg, Cheong, van Kreveld, Overmars (Springer))
- Robust inside-outside segmentation using generalized winding numbers (Jacobson, Kavan, Sorkine-Hornung, SIGGRAPH 2013) (ACM Transactions on Graphics)
- The solid angle of a plane triangle (Van Oosterom and Strackee, IEEE Trans. Biomed. Eng. 1983) (IEEE)
Part of Ohmforge
-
Ohmforge Virtual electronics workbench
Draw a circuit, switch it on, and measure it with real-feeling bench instruments.
Generate a 3D-printable enclosure for a circuit board
Turn a board outline, mounting holes, parts and edge connectors into a verified base and lid STL with standoffs, connector cut-outs and a snap-fit, lip or screwed lid.
What it is for
You have a finished circuit board and need a case with openings for USB and power, standoffs under the mounting holes and a lid that stays on. This tool builds it from a short JSON board description: outline (rectangle, rounded rectangle or polygon), mounting holes, parts as boxes, edge connectors and keep-out zones.
You get the base and the lid (turned over for printing) as STL, an OBJ assembly, a dimensioned drawing and a verification report. It does not emboss text or cut round wall holes: a barrel jack gets a rectangular opening. Screw, insert and connector sizes are typical values, so check your datasheets.
Worked example
The first example is a 70 × 50 mm sensor board with four 3.2 mm holes, a USB-C socket on the left edge, a barrel jack on top, a right-angle header on the right and a 12 mm capacitor. With the defaults (2 mm walls, 1 mm gap, 5 mm standoffs for M3 heat-set inserts, snap-fit lid) the result is a 76 × 56 × 24.6 mm box and 18 of 18 checks passed.
The base has 7400 triangles and 19.065 cm³ of material, the lid 9.217 cm³. The board sits at 7 mm, the walls end at 22.6 mm, and the USB-C opening on the left wall starts 23.03 mm from the left edge of that side view, is 9.94 mm wide and runs from 8.1 to 12.36 mm. That is the 8.94 × 3.26 mm socket plus 0.5 mm all round. Three snap bumps catch 0.2 mm deep; the left wall gets none because of the USB-C opening.
Now add an 8 mm capacitor on the underside of the board. The status changes to 17 of 18 checks passed and the report says C9 collides with the base at x 31…39, y 21…29, z 0…2 mm: it would go through the floor. Set the standoff height to 10 mm and every check passes again, with a 29.6 mm tall box.
How to read the result
The Verification table matters most. Mesh rows confirm both files are watertight, manifold, one solid and still print-ready after an STL round trip. Volume compares the surface volume with the volume of the solid's building blocks. Cutout and boss rows come from probes 0.005 mm inside and outside every opening edge and around every standoff hole. Clearance lists any part, connector or the board itself that touches base or lid, with the overlap box in millimetres.
The drawing measures from the outer lower-left corner of the base. The side views list each opening as from left + width × z bottom…top.
Tips and common mistakes
- Parts are boxes: give tall or overhanging parts (bent LEDs, potentiometer shafts) some extra size.
- The lid gap of 0.2 mm suits a well-tuned FDM printer. If the lid is too tight, raise Gap between lip and wall rather than scaling the STL.
- With Corner screw posts the cavity grows so the posts clear the board, which can add several millimetres.
- Set a keep-out with lidOpening for displays and buttons; a keep-out without it reports any lid material above it.
- Print a small test piece of a corner and one opening before printing the whole case.
FAQ
Is the STL ready for my slicer?
Both files are closed, consistently oriented single solids. Whether they print well still depends on your printer, material and slicer.
Where do the screw and insert sizes come from?
Clearance holes follow ISO 273 medium (3.4 mm for M3). Pilot holes are about 0.8 times the screw diameter, and insert holes match common short brass inserts. Check your insert's own table.
How does the snap-fit work?
Small bumps on the outside of the lid's lip click into grooves in the middle of each straight wall that has no opening. The catch is the snap depth minus the lip gap.
Can I edit the board visually?
Yes. In Ohmforge, open Instruments → Board & enclosure… to edit the board in forms with previews, generate the same files and open the model in Renderloom.
Guide last updated:
For scripts and AI agents
- JSON API:
POST https://ohmforgeenclosuregenerator.usefulweb.app/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://ohmforgeenclosuregenerator.usefulweb.app/mcp· tool nameohmforge_enclosure_generator
Example request
curl -s -X POST https://ohmforgeenclosuregenerator.usefulweb.app/api/v1/calculate \
-H 'content-type: application/json' \
-d '{…see OpenAPI examples…}'