fix(footprint): emit (layer B.Cu) for bottom-layer components#293
Open
gsdali wants to merge 1 commit intotscircuit:mainfrom
Open
fix(footprint): emit (layer B.Cu) for bottom-layer components#293gsdali wants to merge 1 commit intotscircuit:mainfrom
gsdali wants to merge 1 commit intotscircuit:mainfrom
Conversation
When a circuit-json pcb_component has layer "bottom", KiCad needs the footprint-block header to read (layer B.Cu) so the component shows "Board Side: Back" in pcbnew. Without this, KiCad falls through to "Front" — even though the pad-level layers inside the footprint are correctly emitted as B.Cu / B.Paste / B.Mask by CreateSmdPadFromCircuitJson. The header layer was hardcoded to F.Cu in AddFootprintsStage._step (line 127). Two-line fix: read component.layer and map "bottom" -> "B.Cu", anything else -> "F.Cu". "top", undefined, and inner layers all keep the old behaviour. Tests: - New regression test tests/pcb/basics/basics17-bottom-layer-footprint.test.tsx — builds a board with one top-layer and one bottom-layer resistor, classifies the two footprint blocks by their pad-level layer, and asserts each block's header layer is F.Cu / B.Cu respectively. - All previously-passing tests still pass; the suite goes from 8 pass / 10 fail on main to 9 pass / 10 fail on this branch (one more pass from the new test). The 10 unrelated failures are pre-existing PNG-snapshot diffs from KiCad CLI environment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
When a circuit-json
pcb_componenthaslayer: "bottom", the KiCadexporter currently emits
(layer F.Cu)at the top of the resulting(footprint ...)block. KiCad's pcbnew reads that header line topopulate the footprint's "Board Side" property, so every back-side
component shows up as "Board Side: Front" even though its pads,
silkscreen and paste are correctly placed on B.Cu / B.Paste / B.Mask
inside the same block.
Reproducible on a board with any
layer="bottom"component:Output before this PR —
R_BOTTOMopens "Front" in pcbnew:Fix
AddFootprintsStage._stepbuilds the footprint with a hardcodedlayer: "F.Cu". Readcomponent.layerfrom the circuit-jsonpcb_componentand map"bottom"→"B.Cu", everything else(
"top", undefined, inner layers) keeps"F.Cu".Total diff: +9 / −1 lines in
AddFootprintsStage.ts(most of whichis an explanatory comment), plus a new regression test.
Tests
tests/pcb/basics/basics17-bottom-layer-footprint.test.tsxbuildsa board with one
layer="top"and onelayer="bottom"resistor,extracts both
(footprint ...)blocks from the rendered s-expression,classifies each by whether any pad inside is on B.Cu, and asserts
the footprint header layer is
F.Cu/B.Curespectively.The suite goes from 8 pass / 10 fail on main to 9 pass / 10 fail
on this branch — one more pass (the new test). The 10 pre-existing
failures are PNG-snapshot environmental diffs (KiCad CLI version)
unrelated to this fix; the basics01–basics05 / 06 / 09 / 10 / 14 / 15
PNGs differ on main as well.
Test plan
upstream/main: samefailcount, +1passthe back-side resistor's "Properties → Board Side" reads "Back"
🤖 Generated with Claude Code