← Commit history

Delete design/gen/silk_fields_apply.py

John Lauer ·135b318cae ·7d ago ·parent 501c275
1 file changed −22
design/gen/silk_fields_apply.pydeleted−22
@@ -1,22 +0,0 @@-"""Apply the reference/value field placements of design/silk_plan.json to a SAVED board file in place (KiCad 10.0.5's-IPC server cannot update footprint fields, so this is a disclosed saved-file edit; the editor is closed while it runs-and reopened after). Run with KiCad's python.exe: silk_fields_apply.py <board.kicad_pcb>"""-import json, os, sys-import pcbnew-ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")-MM = pcbnew.FromMM-b = pcbnew.LoadBoard(sys.argv[1])-plan = json.load(open(os.path.join(ROOT, "design", "silk_plan.json")))-n = 0-for fl in plan["fields"]:-    fp = b.FindFootprintByReference(fl["ref"])-    f = fp.Reference() if fl["field"] == "Reference" else fp.Value()-    assert f.m_Uuid.AsString() == fl["id"], (fl["ref"], fl["field"], "field identity changed")-    f.SetVisible(True)-    f.SetLayer(pcbnew.F_SilkS if fl["layer"] == "F.SilkS" else pcbnew.B_SilkS)-    f.SetTextSize(pcbnew.VECTOR2I(MM(fl["height"]), MM(fl["height"]))); f.SetTextThickness(MM(fl["stroke"]))-    f.SetTextAngleDegrees(fl["rotation"]); f.SetHorizJustify(pcbnew.GR_TEXT_H_ALIGN_CENTER)-    f.SetPosition(pcbnew.VECTOR2I(MM(fl["x"]), MM(fl["y"])))-    n += 1-pcbnew.SaveBoard(sys.argv[1], b)-print("fields applied:", n)