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.
This commit is contained in:
@@ -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",
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user