31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
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
|