From 64d37014ecdee65f1b0e404951fecd478bd85205 Mon Sep 17 00:00:00 2001 From: "Pavel V. Shatov (Meister)" Date: Mon, 7 Jun 2021 13:42:23 +0300 Subject: Added assembly drawings support to the production package generator script. --- prepare_production_files.py | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/prepare_production_files.py b/prepare_production_files.py index 757164c..df5abb8 100644 --- a/prepare_production_files.py +++ b/prepare_production_files.py @@ -22,6 +22,7 @@ from openpyxl import Workbook # Stackup | 'Stackup.xls' # Pick & Place Data | pcbnew: File -> Fabrication Outputs -> Footprint Position File... # Notes | 'PCB_Notes.txt' +# Assembly Drawing | pcbnew: File -> Print... -> F.Fab, B.Fab (tick "Print mirrored" for the bottom layer!) # # @@ -66,6 +67,10 @@ _DRILL_RENAME_DICT = {'PTH' : 'Plated', _POS_RENAME_DICT = {'top' : 'TopPickPlace', 'bottom' : 'BottomPickPlace'} +_PDF_RENAME_DICT = {'F_Fab' : 'AssemblyTop', + 'B_Fab' : 'AssemblyBottom'} + + _STACKUP = 'Stackup' _NOTES = 'PCB_Notes' _BOM = 'BOM' @@ -77,6 +82,7 @@ _XLS = '.xls' _XLSX = _XLS + "x" _TXT = '.txt' _CSV = '.csv' +_PDF = '.pdf' _SKIP_REFDES = ['LOGO1'] @@ -295,6 +301,10 @@ def main(): prepare_notes() print(" Done") + print("Step 7. Preparing assembly drawings...") + prepare_assembly_drawings() + print(" Done") + # -------------------------------- def create_dirs(): @@ -528,9 +538,35 @@ def prepare_pickplace(): # check, that everything has been renamed if any(_POS_RENAME_DICT): - raise RuntimeError - + raise RuntimeE + rror +# -------------------------------- +def prepare_assembly_drawings(): +# -------------------------------- + + # get all the pdfs + pdfs = [] + for f in os.listdir("%s/%s" % (PROJECT_DIR, _KICAD_GERBER_SUBDIR)): + if f.startswith(PROJECT_NAME) and f.endswith(_PDF): + pdfs.append(f) + + # rename files + for p in pdfs: + d_old_part = p[len(PROJECT_NAME)+1:-len(_PDF)] + d_new_part = _PDF_RENAME_DICT[d_old_part] + del _PDF_RENAME_DICT[d_old_part] + d_from = "%s/%s/%s" % (PROJECT_DIR, _KICAD_GERBER_SUBDIR, p) + d_to = "%s/%s_%s%s" % (_OUT_GERBER_DIR, TARGET_PREFIX, d_new_part, _PDF) + print(" %s..." % d_from) + print(" -> %s" % d_to) + shutil.copyfile(d_from, d_to) + + # check, that everything has been renamed + if any(_PDF_RENAME_DICT): + raise RuntimeError + + # -------------------------------- def prepare_notes(): # -------------------------------- -- cgit v1.2.3