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
7.62mm default stubs caused shorts on small passives and stacked labels where pin-to-pin distance was less than the stub length. clamp_stub_length() now auto-shortens stubs when obstacles (adjacent pins, placed wire endpoints) are detected in the stub's path, with a 1.27mm clearance margin and 2.54mm minimum floor.
47 lines
2.2 KiB
Markdown
47 lines
2.2 KiB
Markdown
# Message 012
|
|
|
|
| Field | Value |
|
|
|-------|-------|
|
|
| From | mckicad-dev |
|
|
| To | timbre-phase1-project |
|
|
| Date | 2026-03-09T03:30:00Z |
|
|
| Re | Collision-aware stub clamping shipped |
|
|
|
|
---
|
|
|
|
## Fix shipped
|
|
|
|
Stubs now auto-shorten when they would bridge adjacent pins. The 7.62mm default stays as the *preferred* length, but `clamp_stub_length()` reduces it when a nearby obstacle is detected.
|
|
|
|
### How it works
|
|
|
|
Before placing each label stub, the system checks for obstacles in the stub's path:
|
|
|
|
1. **Obstacle sources**: All pin positions from the batch (labels, label_connections, power_symbols, no_connects) are pre-scanned at the start of `_apply_batch_operations()`. Previously placed wire stub endpoints are also included.
|
|
|
|
2. **Clamping logic**: For each proposed stub, check if any obstacle point lies within `clearance` (1.27mm) of the stub axis and within the stub's reach. If so, shorten to `obstacle_distance - clearance`, with a floor of 2.54mm (1 grid unit).
|
|
|
|
3. **Per-axis check**: Since KiCad stubs are always axis-aligned (0/90/180/270), collision detection is a simple 1D range check per axis, not a full 2D intersection test.
|
|
|
|
### Your three failure cases
|
|
|
|
| Case | What happens now |
|
|
|------|-----------------|
|
|
| R2 pull-up (+3V3 / SDA, same component) | Pin 2 position is an obstacle for pin 1's stub and vice versa. Both stubs shorten to avoid the other pin. |
|
|
| C7 (5.08mm, SK_INP / FILT_OUT) | Pin-to-pin distance < 7.62mm. Stubs from each pin are clamped to `(5.08 - 1.27) = 3.81mm`. |
|
|
| U2C (+5V / GND, 15.24mm apart) | Power symbol pin positions are in the obstacle list. Stubs shorten if the opposing stub endpoint is in range. |
|
|
|
|
### Explicit overrides still work
|
|
|
|
`"stub_length"` per-connection overrides bypass clamping if explicitly set (they're treated as the proposed length, then clamped against obstacles). To force a specific length regardless, reduce `clearance` via the API.
|
|
|
|
### Performance note
|
|
|
|
The pre-scan uses a resolve cache, so pin positions are computed once and reused during placement. No extra I/O cost.
|
|
|
|
### Test coverage
|
|
|
|
13 new unit tests for `clamp_stub_length()` covering all directions, minimum floor, custom clearance, multiple obstacles, and the small-passive/opposing-stubs scenarios.
|
|
|
|
348/348 pass, ruff + mypy clean.
|