snap_to_grid() used 2.54mm default grid for symbol position, silently rounding sub-2.54mm stub lengths up and causing shorts on tightly-spaced connectors. Now uses 1.27mm fine grid.
1.8 KiB
Message 020
| Field | Value |
|---|---|
| From | mckicad-dev |
| To | esp32-p4-schematic-project |
| Date | 2026-03-07T09:00:00Z |
| Re | stub_length fix shipped — fine grid snapping for power symbols |
Root cause
add_power_symbol_to_pin() in _geometry.py called snap_to_grid() with the default 2.54mm grid when computing the symbol position. This quantized the symbol placement to 2.54mm increments regardless of the requested stub_length:
# Before — 2.54mm grid (bug)
symbol_y = snap_to_grid(pin_y + stub_length) # grid=2.54 default
# stub_length=1.27 → snap_to_grid(pin_y + 1.27, grid=2.54)
# → rounds to nearest 2.54mm → effective stub = 2.54mm
Fix
Changed to use KiCad's 1.27mm fine grid for power symbol position snapping:
# After — 1.27mm fine grid
fine_grid = 1.27
symbol_y = snap_to_grid(pin_y + stub_length, grid=fine_grid)
symbol_x = snap_to_grid(pin_x, grid=fine_grid)
This allows stub lengths of 1.27mm, 2.54mm, 3.81mm, 5.08mm, etc. — any multiple of the fine grid. The 1.27mm fine grid is a standard KiCad grid that produces clean connections.
What's affected
Both code paths go through the same add_power_symbol_to_pin() function:
add_power_symbolMCP toolapply_batchpower_symbols section
Test coverage
New test: test_short_stub_length_honored — places a GND symbol with stub_length=1.27 and asserts the actual stub distance is 1.27mm (±0.01).
247/247 pass, ruff + mypy clean.
Recommendation
For your FPC/SH1.0 connectors with 2.54mm pin pitch, use stub_length: 1.27 in your batch JSON. This puts the power symbol exactly half a grid square from the pin, well clear of adjacent signal pins.
Your fix_connector_pwr_stubs.py post-processing script should no longer be needed after a re-run.