Replies: 5 comments 11 replies
-
In this case, you have to use KiKit as a library and write a custom Python script for the panelization. Basically, you have operations like "Put board here", "add tabs in this way", "add frame" and save the panel. See [documentation] https://github.com/yaqwsx/KiKit/blob/master/doc/panelization.md. The UI is designed so it is easy to use and covers 99 % of the use cases. For anything more complicated, using KiKit as a library is the intended way. |
Beta Was this translation helpful? Give feedback.
-
I have derived the KiKit GUI panelization code to create a small script that creates a panel of two different designs with identical dimensions. |
Beta Was this translation helpful? Give feedback.
-
I'm putting together a CLI tool for doing multi-project panelization: https://github.com/snhobbs/kikit-multipanel. The input is a pandas DataFrame for the board placement which is read from an xls or xlsx spreadsheet. This could easily be json, csv, etc. if desired. Write a presets file and put your board arrangement into a spreadsheet the feed it into the CLI. I included an example, more to come. I'd like to add an second tool that uses Guillotine Cutting or a similar rectangle packing algorithm to optimize the panel arrangement. There's a rectpack library that works well if anyone is interested in helping! |
Beta Was this translation helpful? Give feedback.
-
For a simpler way to customize the layout process, you can use a layout plugin! It avoids having to rewrite a lot of the stuff that the CLI already does for you. I wrote this simple plugin that lets you make a grid of different types of boards. The boards are simply laid out left to right and wrapped when a certain number of columns is reached. If the board sizes are not similar the results can be a bit wonky (tabs ending in mid-air etc), but it can serve as a starting point for your own layout algorithm. To use it, save the code in a file in your working directory and then just use
multi_grid_layout.py from kikit.common import KiPoint
from kikit.panelize import Panel, expandRect, findBoardBoundingBox, pcbnew
from kikit.plugin import LayoutPlugin
from kikit.units import mm
class Plugin(LayoutPlugin):
def buildLayout(self, panel: Panel, mainInputFile: str, _sourceArea):
layout = self.preset["layout"]
cols = layout.get("cols", None)
if not cols:
raise RuntimeError("Specify the number of colums like this: --layout '...; cols: 3'")
cols = int(cols)
boards = layout.get("boards", None)
if not boards:
raise RuntimeError("Specify the boards and counts like this: --layout '...; boards: board_a.kicad_pcb, 3*board_b.kicad_pcb'")
panel.sourcePaths.add(mainInputFile)
netRenamer = lambda n, orig: self.netPattern.format(n=n, orig=orig)
refRenamer = lambda n, orig: self.refPattern.format(n=n, orig=orig)
col = x = y = next_y = 0
for filename in boards.split(","):
parts = filename.split("*", 1)
filename = parts[-1].strip()
count = 1 if len(parts) == 1 else int(parts[0])
for _ in range(count):
board = pcbnew.LoadBoard(filename)
size = panel.appendBoard(
filename=filename,
destination=KiPoint(x, y),
sourceArea=expandRect(findBoardBoundingBox(board), 1 * mm),
netRenamer=netRenamer,
refRenamer=refRenamer,
rotationAngle=self.rotation,
inheritDrc=False,
)
col += 1
if col == cols:
col = x = 0
y = next_y
else:
x += size.GetWidth() + self.vspace
next_y = max(next_y, y + size.GetHeight() + self.hspace)
return panel.substrates |
Beta Was this translation helpful? Give feedback.
-
Hi, I created a GUI tool based on KiKit Tested with KiCad 7.0.10 and KiKit 1.5.1 There is an alignment tool to fill the gap between automatic and manual grid panelization. Tab and tight frame functions are adapted from kikit code. Manual tab function may be added in the future. |
Beta Was this translation helpful? Give feedback.
-
Hi, I would like to know if we can use kikit to panelize two(or more) different boards with same shape in to one panel?
Beta Was this translation helpful? Give feedback.
All reactions