Some checks are pending
CI / Lint and Format (push) Waiting to run
CI / Test Python 3.11 on macos-latest (push) Waiting to run
CI / Test Python 3.12 on macos-latest (push) Waiting to run
CI / Test Python 3.13 on macos-latest (push) Waiting to run
CI / Test Python 3.10 on ubuntu-latest (push) Waiting to run
CI / Test Python 3.11 on ubuntu-latest (push) Waiting to run
CI / Test Python 3.12 on ubuntu-latest (push) Waiting to run
CI / Test Python 3.13 on ubuntu-latest (push) Waiting to run
CI / Security Scan (push) Waiting to run
CI / Build Package (push) Blocked by required conditions
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.
54 lines
1.8 KiB
Markdown
54 lines
1.8 KiB
Markdown
# 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`:
|
|
|
|
```python
|
|
# 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:
|
|
|
|
```python
|
|
# 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_symbol` MCP tool
|
|
- `apply_batch` power_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.
|