feat: flag SMT pads and plated holes too close to the board edge - #188
Open
zkasuran wants to merge 1 commit into
Open
feat: flag SMT pads and plated holes too close to the board edge#188zkasuran wants to merge 1 commit into
zkasuran wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #187.
What this fixes
min_board_edge_clearanceis 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.
checkPcbComponentsOutOfBoardonly 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):The change
lib/check-pcb-components-out-of-board/checkPadsOffBoard.ts. It mirrorscheckViasOffBoard: iterategetPads()(SMT pads plus plated holes), inset the board rectangle bymin_board_edge_clearance, flag any pad whose bounds cross the inset. It emits apcb_placement_errorwith idpad_off_board_<padId>.runAllPlacementChecksnext tocheckViasOffBoard.index.tsto match the other checks.The pad geometry uses the same
getPadBoundshelper the clearance checks already rely on, so no new geometry is introduced. For an axis-aligned rectangular board the bounds test is exact. FollowingcheckViasOffBoard, this handles boards defined bywidth/height; custom outlines can be a follow-up.Tests
tests/lib/check-pads-off-board.test.ts(8 cases):runAllChecksintegration: component bbox inside the board but a pad in the band => now flagged (the false negative above)shouldDrawErrorsVerification (local)
bun test: 149 pass, 0 failbunx tsc --noEmit: cleanbun run format:check: cleanbun run build: successbunx @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 buildandbunx @tscircuit/dependency-check.