Skip to content

feat: flag SMT pads and plated holes too close to the board edge - #188

Open
zkasuran wants to merge 1 commit into
tscircuit:mainfrom
zkasuran:feat/check-pads-off-board
Open

feat: flag SMT pads and plated holes too close to the board edge#188
zkasuran wants to merge 1 commit into
tscircuit:mainfrom
zkasuran:feat/check-pads-off-board

Conversation

@zkasuran

@zkasuran zkasuran commented Aug 8, 2026

Copy link
Copy Markdown

Closes #187.

What this fixes

min_board_edge_clearance is enforced for traces (checkPcbTracesOutOfBoard) and vias (checkViasOffBoard), but SMT pad and plated-hole copper was never checked against the board edge. A pad whose copper sits inside the clearance band passed clean.

It slips through because the owning component can be fully inside the board. checkPcbComponentsOutOfBoard only tests component-bounding-box containment with no clearance margin, so nothing flags a pad whose copper is still too close to the routed or V-scored edge.

Repro that returned [] before this change (10x10 board, 0.2mm clearance, right pad copper 0.15mm from the edge, component bbox still inside):

const soup = [
  { type: "pcb_board", pcb_board_id: "board1", center: { x: 0, y: 0 }, width: 10, height: 10, num_layers: 2, thickness: 1.2, material: "fr4", min_board_edge_clearance: 0.2 },
  { type: "pcb_component", pcb_component_id: "R1", center: { x: 4.0, y: 0 }, width: 1.7, height: 1.2, layer: "top", rotation: 0 },
  { type: "pcb_smtpad", pcb_smtpad_id: "pad1", pcb_component_id: "R1", shape: "rect", x: 3.4, y: 0, width: 0.5, height: 1.2, layer: "top" },
  { type: "pcb_smtpad", pcb_smtpad_id: "pad2", pcb_component_id: "R1", shape: "rect", x: 4.6, y: 0, width: 0.5, height: 1.2, layer: "top" },
]

The change

  • New lib/check-pcb-components-out-of-board/checkPadsOffBoard.ts. It mirrors checkViasOffBoard: iterate getPads() (SMT pads plus plated holes), inset the board rectangle by min_board_edge_clearance, flag any pad whose bounds cross the inset. It emits a pcb_placement_error with id pad_off_board_<padId>.
  • Wired into runAllPlacementChecks next to checkViasOffBoard.
  • Re-exported from index.ts to match the other checks.

The pad geometry uses the same getPadBounds helper the clearance checks already rely on, so no new geometry is introduced. For an axis-aligned rectangular board the bounds test is exact. Following checkViasOffBoard, this handles boards defined by width/height; custom outlines can be a follow-up.

Tests

tests/lib/check-pads-off-board.test.ts (8 cases):

  • no board, no pads, pad well inside the board => no errors
  • SMT pad copper in the clearance band => error
  • SMT pad crossing the edge => error
  • plated hole in the clearance band => error
  • runAllChecks integration: component bbox inside the board but a pad in the band => now flagged (the false negative above)
  • SVG snapshot rendered with shouldDrawErrors

Verification (local)

  • bun test: 149 pass, 0 fail
  • bunx tsc --noEmit: clean
  • bun run format:check: clean
  • bun run build: success
  • bunx @tscircuit/dependency-check: passed (no new dependencies)

AI assistance

AI assistance (Claude, Anthropic) was used in developing this change. The design, review and verification were done by the author. Verified locally before submitting: bun test (149 pass), bunx tsc --noEmit, bun run format:check, bun run build and bunx @tscircuit/dependency-check.

Board-edge clearance (min_board_edge_clearance) was enforced for traces
(checkPcbTracesOutOfBoard) and vias (checkViasOffBoard) but never for SMT pad
or plated-hole copper. A pad sitting inside the clearance band passed clean:
the owning component can be fully inside the board, so checkPcbComponentsOutOfBoard
stays silent while the copper is still too close to the routed or scored edge.

Add checkPadsOffBoard, mirroring checkViasOffBoard over getPads(), and wire it
into runAllPlacementChecks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SMT pads and plated holes are not checked against min_board_edge_clearance

1 participant