Update based off work done in diceshaker.

This commit is contained in:
ac
2023-05-11 11:38:56 +10:00
parent 95d9e1ef85
commit d1307c4e3d
6 changed files with 142 additions and 159 deletions

30
.scripts/ki_plugin.py Normal file
View File

@@ -0,0 +1,30 @@
from kikit import panelize_ui_impl as ki
from kikit.panelize import Panel
from kikit.panelize_ui_impl import Substrate, readLength
from pcbnewTransition import pcbnew
from pcbnewTransition.pcbnew import LoadBoard, VECTOR2I
from kikit.plugin import LayoutPlugin
import json
from typing import Iterable
from kikit.common import fromDegrees
class ManualLayout(LayoutPlugin):
def buildLayout(self, panel: Panel, inputFile: str,
sourceArea: pcbnew.BOX2I) -> Iterable[Substrate]:
netRenamer = lambda x, y: self.netPattern.format(n=x, orig=y)
refRenamer = lambda x, y: self.refPattern.format(n=x, orig=y)
with open("boards.json") as json_file:
json_str = json_file.read()
boards = []
for d in json.loads(json_str):
source = {"type": "auto", "tolerance": readLength("5mm")}
board = LoadBoard(d["board"])
sourceArea = ki.readSourceArea(source, board)
drc_flag = False
if d["board"] == inputFile and not len(panel.sourcePaths):
drc_flag = True
panel.appendBoard(d["board"], VECTOR2I(*[readLength(p) for p in d["pos"]]),\
sourceArea, inheritDrc=drc_flag, rotationAngle=fromDegrees(d.get("rot", 0.0)),\
netRenamer=netRenamer, refRenamer=refRenamer)
return panel.substrates