diff --git a/bin/copy_from_Kicad.py b/bin/copy_from_Kicad.py index af2462b..cba46b7 100644 --- a/bin/copy_from_Kicad.py +++ b/bin/copy_from_Kicad.py @@ -30,6 +30,8 @@ else: # modules fixRotationsPath = "bin/jlc_kicad_tools/cpl_rotations_db.csv" +fixFootprintsPath = "kicad/footprints.csv" + pat_module = re.compile(r'^[Mm]odule-([\w]+)-([\w\.]+)') ################################################# @@ -77,6 +79,14 @@ shutil.copyfile(src_name + ".pdf", dst_name + "-schematic.pdf") # copy the VRML 3D components shutil.copyfile(src_name + ".wrl", dst_name + "-vrml.wrl") +footprint_LUT = dict() + +print ("Reading footprint replacement table...") +with open(fixFootprintsPath, 'rb') as f_f: + reader = csv.reader(f_f, delimiter=',') + for row in reader: + footprint_LUT[row[0]] = row[1] + bom = dict() print ("Copying BOM...") @@ -90,6 +100,8 @@ with open(src_name + ".csv", 'rb') as src_f, open(dst_name + "-BOM.csv", 'w') as des = row[1] footprint = row[2] lcsc = row[3] + if footprint in footprint_LUT: + footprint = footprint_LUT[footprint] bom[des] = footprint print ("* " + des) mod = pat_module.match(comment) diff --git a/kicad/footprints.csv b/kicad/footprints.csv new file mode 100644 index 0000000..f130493 --- /dev/null +++ b/kicad/footprints.csv @@ -0,0 +1,10 @@ +"Resistor_SMD:R_0402_1005Metric","R0402" +"Resistor_SMD:R_0603_1608Metric","R0603" +"Capacitor_SMD:C_0402_1005Metric","C0402" +"Capacitor_SMD:C_0603_1608Metric","C0603" +"LED_SMD:LED_0603_1608Metric","LED-0603" +"Package_TO_SOT_SMD:TO-252-2","DPAK" +"Package_SO:TSSOP-14_4.4x5mm_P0.65mm","TSSOP14" +"Package_TO_SOT_SMD:TSOT-23-5","TSOT23-5" +"Package_QFP:LQFP-32_7x7mm_P0.8mm","LQFP32" +"Package_TO_SOT_SMD:SOT-23","SOT-23"