fix: skip pcb pad overlap check for elements on different layers#121
Merged
rushabhcodes merged 4 commits intotscircuit:mainfrom Mar 12, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes false-positive PCB overlap errors by making overlap detection layer-aware, so copper features on different layers (e.g. top vs bottom) are not treated as physically colliding.
Changes:
- Add a layer-intersection early-return to
doPcbElementsOverlapbefore doing XY bounds overlap. - Add a regression test covering SMT pads on different layers and its SVG snapshot output.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
lib/check-pcb-components-overlap/doPcbElementsOverlap.ts |
Adds layer intersection logic to skip overlap checks for elements on disjoint layers. |
tests/lib/check-pcb-component-overlap/different-layer-pads-no-overlap.test.ts |
Adds regression test ensuring different-layer SMT pads aren’t flagged as overlapping. |
tests/lib/check-pcb-component-overlap/__snapshots__/different-layer-pads-no-overlap.snap.svg |
Adds snapshot for the new regression test’s rendered PCB SVG. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/lib/check-pcb-component-overlap/different-layer-pads-no-overlap.test.ts
Outdated
Show resolved
Hide resolved
tests/lib/check-pcb-component-overlap/different-layer-pads-no-overlap.test.ts
Outdated
Show resolved
Hide resolved
imrishabh18
requested changes
Mar 12, 2026
tests/lib/check-pcb-component-overlap/different-layer-pads-no-overlap.test.ts
Outdated
Show resolved
Hide resolved
tests/lib/check-pcb-component-overlap/different-layer-pads-no-overlap.test.ts
Outdated
Show resolved
Hide resolved
- Updated the test for SMT pads on different layers to utilize a circuit JSON file instead of hardcoded data. - Adjusted the error handling to incorporate errors from the overlap check into the circuit JSON for SVG conversion. - Enhanced SVG snapshot comparison to reflect the new structure of the test data.
Contributor
Author
|
@imrishabh18 fixed |
imrishabh18
approved these changes
Mar 12, 2026
Contributor
|
Thank you for your contribution! 🎉 PR Rating: ⭐⭐⭐ Track your contributions and see the leaderboard at: tscircuit Contribution Tracker |
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.
Problem
SMT pads positioned at the same XY coordinates but on different layers (e.g.
topvsbottom) were incorrectly reported as overlapping. Since these pads exist on physically separate copper planes, there is no actual conflict./fixes #120
Fix
Updated
doPcbElementsOverlapto check layer intersection before comparing XY bounds. If the two elements share no common layers, the function returnsfalseimmediately without performing a bounds check.pcb_smtpadelements carry a singlelayervaluepcb_plated_hole/pcb_hole/pcb_viaspan all layers and will still be checked against everything (correct behaviour preserved)Tests
Added
different-layer-pads-no-overlap.test.tswith snapshot tests:topvsbottomat the same position → 0 errors (reproduces the bug and confirms the fix)