techmannih/nema34-mounted-stepper-controller
A 48 V USB‑C PD 3.1 EPR NEMA‑34 stepper controller PCB combining STM32/TMC5160 control, external MOSFET motor bridges, protected power and regenerative braking, USB data, telemetry, diagnostics, status LEDs, and buzzer alarms.
- Version
- 0.3.92
- License
- unset
- Stars
- 1
scripts/remove-isolated-zones.py
#!/usr/bin/env python3
"""Remove generated corridor zones identified as isolated by KiCad DRC."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
import pcbnew
import wx
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("board", type=Path)
parser.add_argument("drc_json", type=Path)
args = parser.parse_args()
report = json.loads(args.drc_json.read_text())
isolated = {
item["uuid"]
for violation in report.get("violations", [])
if violation.get("type") == "isolated_copper"
for item in violation.get("items", [])
if item.get("uuid")
}
app = wx.App(False)
board = pcbnew.LoadBoard(str(args.board))
removed = []
zones = list(board.Zones())
for zone in zones:
uuid = zone.m_Uuid.AsString()
if uuid in isolated:
removed.append((zone.GetNetname(), pcbnew.LayerName(zone.GetLayer()), uuid))
board.Remove(zone)
pcbnew.ZONE_FILLER(board).Fill(board.Zones())
pcbnew.SaveBoard(str(args.board), board)
print({"removed": len(removed), "zones": removed})
if __name__ == "__main__":
main()