A Python utility to merge Bill of Materials (BOM) and Pick & Place (CPL/Position) files (as exported by Fabrication Toolkit from KiCAD) for PCB panels created with ThisIsNotRocketScience/GerberTools.
While the Gerber Panelizer tool is excellent for merging Gerber files, it does not natively support merging assembly data. This script reads the .gerberset file to calculate the precise rotation and offsets of every board in the panel, automatically generating a unified BOM and Pick & Place file ready for assembly (e.g., JLCPCB).
- Geometry Calculation: Parses the XML
.gerbersetfile to apply accurate X/Y offsets and rotations to component coordinates. - Designator Management: Renames components to avoid duplicates (e.g.,
C1on Board 1 becomesB1_C1,C1on Board 2 becomesB2_C1). - BOM Aggregation: Merges identical parts across the entire panel into single line items, summing quantities and concatenating designators.
- Unique File Handling: Intelligently asks for source files only once per unique design, even if the design is repeated multiple times on the panel.
- Standard Library Only: Written using only Python standard libraries (no
pip installrequired).
- Python 3.x installed on your system.
- Source Files:
- The
.gerbersetfile saved from Gerber Panelizer. - The BOM
.csvfile for each distinct board design. - The Pick & Place
.csvfile for each distinct board design.
- The
The script expects CSV files formatted similarly to KiCad/JLCPCB exports:
Must contain headers:
DesignatorQuantityFootprintValueLCSC Part #(Optional, used for grouping if present)
Must contain headers:
DesignatorMid XMid YRotationLayer
- Download
merge_panel_data.pyto your computer. - Open a terminal or command prompt.
- Run the script:
python merge_panel_data.py
- Select the Layout: A file dialog will appear. Select your
.gerbersetfile. - Select Source Data: The script will detect the unique boards in your panel. For each board, it will ask you to select:
- The BOM CSV file.
- The Pick & Place CSV file.
- Done: The script will generate two files in the script's directory:
merged_bom.csvmerged_positions.csv
- Parsing: The script reads the XML structure of the
.gerbersetfile to find the center coordinates(X, Y)andAnglefor every instance of a board. - Transformation:
- It rotates the original component coordinates around the board's (0,0) origin based on the panel rotation.
- It translates (shifts) the coordinates based on the instance's location in the panel.
- It adds the panel rotation to the component's individual rotation.
- Merging: It combines the data into a single list, generating unique designators (Prefix
B[InstanceNumber]_) and aggregating BOM quantities.