From 4e70342eae7900065c4ffdcf56cf299607f962a1 Mon Sep 17 00:00:00 2001 From: Roman PASSLER Date: Sun, 1 Mar 2026 18:40:45 +0100 Subject: [PATCH] fix(drc): extract violation coordinates from kicad-cli JSON items kicad-cli DRC JSON output stores coordinates in items[].pos.x/y, not at the violation top level. The code was reading violation.x/y which don't exist, falling back to (0, 0) for every violation. Now correctly reads the position from the first item in each violation entry. --- python/commands/design_rules.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python/commands/design_rules.py b/python/commands/design_rules.py index 04984c8..71eb7aa 100644 --- a/python/commands/design_rules.py +++ b/python/commands/design_rules.py @@ -267,14 +267,21 @@ class DesignRuleCommands: vtype = violation.get("type", "unknown") vseverity = violation.get("severity", "error") + # Extract location from first item's pos (kicad-cli JSON format) + items = violation.get("items", []) + loc_x, loc_y = 0, 0 + if items and "pos" in items[0]: + loc_x = items[0]["pos"].get("x", 0) + loc_y = items[0]["pos"].get("y", 0) + violations.append( { "type": vtype, "severity": vseverity, "message": violation.get("description", ""), "location": { - "x": violation.get("x", 0), - "y": violation.get("y", 0), + "x": loc_x, + "y": loc_y, "unit": "mm", }, }