Repository navigation
Fix KiCad via rendering and per-side tenting - #572
Conversation
qu1ck
left a comment
There was a problem hiding this comment.
Looks good, just get rid of via property
| if track.IsOnLayer(layer): | ||
| result[layer].append(track_dict) | ||
| via_dict = track_dict.copy() | ||
| via_dict["via"] = True |
There was a problem hiding this comment.
This extra property does not really carry any useful information and just bloats the output size.
Tented via is really not any different than a track segment for rendering purposes so the only thing we need to pass is drill hole size for untented vias.
There was a problem hiding this comment.
Removed the via field in commit 85ae313.
| track.start[1] == track.end[1]); | ||
|
|
||
| // First draw tracks and tented vias | ||
| var isVia = (track) => track.via || hasHole(track); |
There was a problem hiding this comment.
Keep old logic here. Only reason there is a separate second pass is to draw holes after everything else to have them always visible.
Tracks and tented vias can go in the first pass.
There was a problem hiding this comment.
I've removed the via field and kept the original hasHole logic and pass order: tracks and tented vias first, then untented vias and their holes.
I've kept explicit circle drawing because zero-length strokes paint nothing in the browser tests, even with round line caps. This reproduced in headless Edge 154 and Chrome 153. The circles use the existing coordinates and width, so no extra data field is needed.
Here's a standalone example of the stroke behavior:
const canvas = document.createElement("canvas");
canvas.width = canvas.height = 96;
const ctx = canvas.getContext("2d");
ctx.strokeStyle = "#00ff00";
ctx.lineCap = "round";
ctx.lineWidth = 24;
ctx.beginPath();
ctx.moveTo(48, 48);
ctx.lineTo(48, 48);
ctx.stroke();
console.log(ctx.getImageData(48, 48, 1, 1).data[3]);
// 0 in the tested browsers: the center pixel is transparent.The Canvas standard removes zero-length segments when tracing a path for stroking, so a round-capped zero-length stroke is not a dependable way to draw a dot.
Earlier working results could reflect a different browser implementation or version, but I haven't compared older browsers or known-good older HTML exports. The circle change fixes the behavior reproduced here; I can't yet say when or why earlier results differed.
The revised export and pixel checks pass, including all four front/back tenting combinations on a KiCad 10.0.6 via, net highlighting, and holes remaining visible above overlapping tracks. Older KiCad API fallbacks were checked with mocks rather than installed older releases.
|
Yeah the change to drop 0 length segments in paths is recent. Chrome definitely used to draw it few versions back. Thanks for your contribution. |
Fix KiCad 10 via tenting export and render tented vias
Problem
With Include tracks/zones enabled, iBOM 2.12.0 exports KiCad 10 vias as zero-length tracks without drill information. On the reported KiCad 10.0.6 board, changing individual or global tenting did not make the expected via holes appear. Tented vias were also difficult to see in the generated view.

parse_tracks()defaults to a board-wideGetTentVias()value that is unavailable in KiCad 10, then reuses one dictionary for both faces. The renderer relies on a zero-length stroke for tented vias. Together these prevent accurate per-side tenting and reliable via visibility.Change
IsTented(layer); support older KiCad's no-argumentIsTented()and the existing board-wide fallback.GetWidth(layer), falling back toGetWidth()on older KiCad.drillsize. The renderer still recognizes legacy drilled-via data without the new marker.Expected view
Only an outer copper layer occupied by the via receives an entry.
Compatibility with older KiCad versions
The parser tries the layer-aware
IsTented(layer)andGetWidth(layer)calls first, then falls back to the no-argumentIsTented()andGetWidth()signatures used by older bindings. WhenIsTentedis unavailable, it uses the existing board-wide tenting fallback.These compatibility paths were checked with API mocks, including KiCad 8-style signatures. They have not been tested in an installed older KiCad release.
Testing
git diff --check, and the module-import smoke check passed. The import check was run directly under KiCad Python rather than through pytest.The sample board contains through vias on a two-layer PCB; a real blind or buried via was not part of the test project.
