From 56362ae8afbab82f84b638410a540ad70a816504 Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Thu, 26 Apr 2018 12:23:08 +0200 Subject: fix the rest of the footprints that were exported from Altium --- set-footprints-from-pcb.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'set-footprints-from-pcb.py') diff --git a/set-footprints-from-pcb.py b/set-footprints-from-pcb.py index ad0683b..578b9ce 100755 --- a/set-footprints-from-pcb.py +++ b/set-footprints-from-pcb.py @@ -21,6 +21,7 @@ def add_footprints(fn_in, fn_out, comp): out = open(fn_out, 'w') curr = None c = 0 + f0 = '' print('Adding footprints to {}'.format(fn_in)) for line in in_.readlines(): c += 1 @@ -28,6 +29,11 @@ def add_footprints(fn_in, fn_out, comp): curr = line.split(' ')[-1] while curr[-1] == '\n': curr = curr[:-1] + # Special case handling of chips divided into parts + if '_' in curr and curr not in comp: + curr = curr.split('_')[0] + if line.startswith('F 0 '): + f0 = line if line.startswith('F 2 ""'): if curr in comp: fp = comp[curr] @@ -38,7 +44,20 @@ def add_footprints(fn_in, fn_out, comp): #print('{}: line {} {} fp {}'.format(fn_in, c, curr, fp)) else: if not curr.startswith('#PWR'): - sys.stderr.write('Footprint for {} not known\n'.format(curr)) + sys.stderr.write('{}: line {} footprint for {} not known\n'.format(fn_in, c, curr)) + curr = None + f0 = '' + if line.startswith('$EndComp') and curr is not None: + #sys.stderr.write('{}: line {} footprint for {} not written\n'.format(fn_in, c, curr)) + if curr in comp: + # Component without F 2 line. Construct one roughly from F 0. + f = f0.split(' ') + coord = f[4] + ' ' + f[5] + f2 = 'F 2 "Cryptech_Alpha_Footprints:{}" H {} 60 0001 C CNN\n'.format(comp[curr], coord) + out.write(f2) + else: + if not curr.startswith('#PWR'): + sys.stderr.write('{}: line {} footprint for {} not known\n'.format(fn_in, c, curr)) out.write(line) return True @@ -53,6 +72,7 @@ def main(pcb, schemas): sys.stderr.write('{} already in comp ({} -> {})!\n'.format(ref, comp[ref], fp)) comp[ref] = str(fp) + #print(sorted(comp.keys())) #print(pprint.pformat(comp)) for this in schemas: -- cgit v1.2.3