Skip to main content
tscircuit Essentials

Mounting 3D models to a board

Name a PCB mounting hole, then point an assembly.bolt at it with fastenedTo. Core positions and orients the bolt from the hole's finalized PCB geometry, so it follows layout changes without manually copying the hole's coordinates or calculating the board's surface height.

import { assembly } from "tscircuit"

export default () => (
<assembly.device>
<board name="CONTROL" width={50} height={40} thickness={1.6}
pcbX={10} pcbY={5} pcbRotation={20} routingDisabled>
<hole name="H1" diameter={3.2} pcbX={-16} pcbY={-12} />
<platedhole name="H2" shape="circle"
holeDiameter={3.2} outerDiameter={6} pcbX={16} pcbY={12} />
<chip name="U_DRIVER" footprint="soic8" />
</board>
<assembly.bolt name="B1" model="hexsocketbolt_m3_l10mm"
fastenedTo=".CONTROL > .H1" />
<assembly.bolt name="B2" model="hexsocketbolt_m3_l10mm"
fastenedTo=".CONTROL > .H2 > .bottom" />
</assembly.device>
)

The example uses the canonical hexsocketbolt_m3_l10mm model: an M3 × 10 mm socket-head bolt. The plain and plated holes are both 3.2 mm in diameter. Each hole creates the physical PCB cutout; each bolt adds its own CAD model.

  • .CONTROL > .H1 selects H1's top surface. B1's head sits above the board and its shaft points down.
  • .CONTROL > .H2 > .bottom selects H2's bottom surface. B2's head sits underneath and its shaft points up.
  • .top explicitly selects a hole's top surface. A compact path such as CONTROL.H1 also works.

The 1.6 mm PCB remains centered at Z = 0. Bolt seating planes are at Z = 0.8 mm and Z = −0.8 mm, and their XY positions come from the rotated, translated holes. The same references continue to work if the board or a footprint containing the holes moves.

Adjust or import a fastener​

Add mountGap="2mm" for clearance along the selected surface normal. mountOffset={{ x: "1mm", y: "-2mm" }} moves along its local tangents; this is useful for adjustment within a slot. Choose dimensions and clearances for the actual hardware: mounting does not cut a countersink, determine engagement, or check interference.

For custom hardware, use modelUrl or cadModel. Author the asset's seating plane at its local origin, with its shaft pointing down (−Z), or provide a named mountFace on the bolt. See assembly.bolt for dimensional bolts and custom mating faces.

For bearings, brackets and other mechanical parts, define assembly.referencesurface datums and pair mountedTo with mountFace. A mounted assembly.subassembly carries a complete group through one relative constraint. cadModel offsets remain available to align an imported mesh within its part's local frame.