Flag keepout tracks in the courtyard and mark the plan map OK.

PS-PLC-004 is a foreign net endpoint inside the KiCad courtyard. The lista↔codice table and sprints 0–10+ get an OK column where the hole is closed without invented millimetres.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-11 00:11:02 +02:00
co-authored by Cursor
parent 412c32e9b2
commit 796cd9d8a2
4 changed files with 152 additions and 46 deletions
+38
View File
@@ -7,6 +7,7 @@ min_via_count — no invented pad radius. same_layer (`PS-PLC-003`) uses
the boolean parameter plus footprint layers from the PCB. Crystals use
the same decoupling_proximity rule. Track length is shortest path on
segments vs max_distance_mm — no invented “much larger than euclidean”.
Keepout (`PS-PLC-004`) is a foreign net endpoint inside the courtyard.
"""
from __future__ import annotations
@@ -124,6 +125,8 @@ def check_placement(
)
elif kind == "thermal_via":
findings.extend(_thermal_via_finding(ref, comp, cons, rule, layout))
elif kind == "keepout":
findings.extend(_keepout_finding(ref, comp, cons, rule, graph, layout))
return findings
@@ -275,3 +278,38 @@ def _thermal_via_finding(ref, comp, cons, rule, layout: LayoutGraph) -> list[Fin
pins=[pin] if pin else [],
source_page=rule.get("source_page"),
)]
def _keepout_finding(ref, comp, cons, rule, graph: DesignGraph, layout: LayoutGraph) -> list[Finding]:
fp = layout.footprints.get(ref)
if not fp or len(fp.courtyard) < 3:
return []
pin_no = _pin_number(cons, str(rule.get("pin") or ""))
own = _net_for_pin(graph, ref, pin_no) if pin_no else None
if not own:
return []
foreign: list[str] = []
for s in layout.segments:
if not s.net or s.net == own:
continue
if _in_poly(s.start[0], s.start[1], fp.courtyard) or _in_poly(
s.end[0], s.end[1], fp.courtyard
):
foreign.append(s.net)
if not foreign:
return []
net = sorted(set(foreign))[0]
return [Finding(
designator=ref,
mpn=comp.mpn or cons.mpn,
aspect="placement",
finding=f"Track on {net} enters courtyard of {ref} (keepout on {own}).",
why="layout_rules kind=keepout.",
status="WARNING",
recommendation="Keep other nets out of the courtyard.",
source="placement_check",
rule_id="PS-PLC-004",
net=net,
pins=[pin_no],
source_page=rule.get("source_page"),
)]