Skip to content

fix(smtpad): emit per-side solder mask margins - #5929

Open
siribi007-del wants to merge 1 commit into
tscircuit:mainfrom
siribi007-del:fix/smtpad-soldermask-side-margins
Open

siribi007-del wants to merge 1 commit into
tscircuit:mainfrom
siribi007-del:fix/smtpad-soldermask-side-margins

Conversation

@siribi007-del

Copy link
Copy Markdown

Motivation

Fine-pitch pads often need a tight mask web between neighbours but a larger opening at the toe, which is what solderMaskMarginLeft/Right/Top/Bottom on <smtpad> are for. Core accepts those props but never writes them to pcb_smtpad, even though circuit-json has soldermask_margin_left/right/top/bottom on rect and rotated_rect pads and circuit-to-svg already reads them (circuit-to-svg#481).

Reproduction

<chip name="U1" footprint={<footprint>
  <smtpad shape="rect" width="1mm" height="0.6mm" portHints={["1"]}
    solderMaskMarginLeft="0.3mm" solderMaskMarginRight="0.1mm"
    solderMaskMarginTop="0.2mm" solderMaskMarginBottom="0.05mm" />
</footprint>} />

On main the pad comes out as { shape: "rect", ... } with no soldermask_margin_* fields.

Passing the values straight through is not enough: the margins are written in the pad's own frame, and the emitted pad is in the board frame. With pcbRotation={90} the pad's left edge faces -y, and on layer="bottom" the footprint is mirrored in x (a pad at pcbX={2} lands at x = -2), so left and right swap.

Change

mapSoldermaskSideMargins (new, lib/utils/pcb/) sends each side's outward direction through the pad's global transform (plus its own ccwRotation for rotated_rect) and into the frame of the emitted pad (its ccw_rotation), then assigns the margin to whichever side it lands on. SmtPad spreads the result into the three rect / rotated_rect inserts. Pads without per-side margins emit nothing new.

Validation

  • tests/components/primitive-components/smtpad-soldermask-side-margins.test.tsx (7 tests): pass-through, 90° rotation, bottom flip, flip + 90°, 45° (rotated_rect output), shape="rotated_rect" with ccwRotation on top and bottom, and no per-side fields when none are set. I checked the rotation and flip expectations against where an off-centre pad actually lands, not against the new function.
  • All tests that mention smtpad or solderMask (315 files) pass, except the two repro-a13-ddr-* tests, which fail the same way on main.
  • bunx tsc --noEmit and biome are clean. tscircuit-pullrequest-deterministic-checks reports 0 errors.

Before / after (5 pads at 0.5 mm pitch, L/R 0.03, top 0.15, bottom 0.05 mm). circuit-to-svg only draws the mask for covered pads, so this is drawn straight from the pcb_smtpad fields:

smtpad-soldermask-before-after

Not in this PR: circuit-json-to-gerber does not read the per-side fields yet (circuit-json-to-gerber#277 is open for that), so the mask layer in exported gerbers still uses soldermask_margin.

AI-assisted (Claude); I ran and checked the tests locally.

<smtpad solderMaskMarginLeft/Right/Top/Bottom> were accepted by the props
schema but never written to pcb_smtpad, so rect and rotated_rect pads
lost them even though circuit-json has soldermask_margin_left/right/
top/bottom.

The margins are given in the pad's own frame. Map each one through the
pad's global transform (component rotation and bottom-side flip) and
its own ccwRotation into the frame of the emitted pad, so a 90 degree
rotation or a bottom placement keeps each margin on the same physical
edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tscircuit-core-benchmarks Ready Ready Preview Nov 26, 2026 6:04pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — b274f216 Deployed Nov 26, 2026 by vercel[bot]
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.

1 participant