aboutsummaryrefslogtreecommitdiff
path: root/set-footprints-from-pcb.py
diff options
context:
space:
mode:
Diffstat (limited to 'set-footprints-from-pcb.py')
-rwxr-xr-xset-footprints-from-pcb.py22
1 files changed, 21 insertions, 1 deletions
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: