Last active
April 15, 2021 22:35
-
-
Save dronir/705d125545019d4052945f9f8d0ccbeb to your computer and use it in GitHub Desktop.
Scripts to convert KiCad files for JLCPCB assembly service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This converts a BOM file in CSV format, produced by KiCad Pcbnew, | |
# by selecting File / Fabrication Outputs / BOM File | |
# into the format expected by the JLCPCB manufacture service. | |
# At least in KiCad 5.1.4 the CSV output seems a bit broken in terms of column names, | |
# which is reflected in this code. If it changes in later KiCad versions, this script | |
# needs to change, too. | |
# Use this by running the command line: python convert_bom.py inputfile.csv outputfile.csv | |
# It will overwrite your output file without asking so be careful. | |
import pandas as pd | |
from sys import argv, exit | |
# Select these columns from the input file | |
FILTER = ["Id", "Quantity", "Designator"] | |
# Rename the columns based on these rules | |
JLCPCB_NAMES = { | |
"Designator" : "Footprint", | |
"Quantity" : "Comment", | |
"Id" : "Designator" | |
} | |
# Read data, filter, rename and write output | |
data = pd.read_csv(argv[1], delimiter=";") | |
filtered = data[FILTER] | |
result = filtered.rename(JLCPCB_NAMES, axis="columns", errors="raise") | |
result.to_csv(argv[2], index=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This converts a component placement file in CSV format, produced by KiCad Pcbnew, | |
# by selecting File / Fabrication Outputs / Footprint position (.pos) file | |
# into the format expected by the JLCPCB manufacture service. | |
# In KiCad, use the following options: | |
# Format = CSV | |
# Units = Millimeters | |
# Files = Single file for board | |
# Include footprints with SMD pads even if ... = unchecked | |
# Use this by running the command line: python convert_pos.py inputfile.csv outputfile.csv | |
# It will overwrite your output file without asking so be careful. | |
import pandas as pd | |
from sys import argv, exit | |
# Select these columns from the input file | |
FILTER = ["Ref", "PosX", "PosY", "Side", "Rot"] | |
# Rename the columns based on these rules | |
JLCPCB_NAMES = { | |
"Ref" : "Designator", | |
"PosX" : "Mid X", | |
"PosY" : "Mid Y", | |
"Side" : "Layer", | |
"Rot" : "Rotation" | |
} | |
# Read data, filter, rename and write output | |
data = pd.read_csv(argv[1]) | |
filtered = data[FILTER] | |
result = filtered.rename(JLCPCB_NAMES, axis="columns", errors="raise") | |
result.to_csv(argv[2], index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment