00e203fc8dda3aca1dc8668c357faddb819edcb4
Stefan Schuermans begin of PCB footprint parser

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/pcbfp2dxf.py  1) #! /usr/bin/env python3
pcb_footpr_conv/pcbfp2dxf.py  2) 
Stefan Schuermans DXF export of pins + holes

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py     3) import dxf_export
Stefan Schuermans PCB element Python types

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py     4) import pcb_parser
pcb_footpr_conv/fp2dxf.py     5) import pcb_types
pcb_footpr_conv/fp2dxf.py     6) 
Stefan Schuermans DXF export of pins + holes

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py     7) import argparse
Stefan Schuermans begin of PCB footprint pars...

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py     8) import sys
pcb_footpr_conv/fp2dxf.py     9) 
pcb_footpr_conv/fp2dxf.py    10) 
Stefan Schuermans DXF export of pins + holes

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py    11) def parse_args():
pcb_footpr_conv/fp2dxf.py    12)     parser = argparse.ArgumentParser('Convert GNU PCB footrpint to DXF.')
pcb_footpr_conv/fp2dxf.py    13)     parser.add_argument('-ifp',
pcb_footpr_conv/fp2dxf.py    14)                         '--in-footprint',
pcb_footpr_conv/fp2dxf.py    15)                         required=True,
pcb_footpr_conv/fp2dxf.py    16)                         help='GNU PCB footprint file (input, required)')
pcb_footpr_conv/fp2dxf.py    17)     parser.add_argument('-odxf',
pcb_footpr_conv/fp2dxf.py    18)                         '--out-dxf',
pcb_footpr_conv/fp2dxf.py    19)                         required=True,
pcb_footpr_conv/fp2dxf.py    20)                         help='DXF file (output, required)')
pcb_footpr_conv/fp2dxf.py    21)     args = parser.parse_args()
pcb_footpr_conv/fp2dxf.py    22)     return args
pcb_footpr_conv/fp2dxf.py    23) 
pcb_footpr_conv/fp2dxf.py    24) 
Stefan Schuermans PCB element Python types

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py    25) def read_footprint(file_name: str) -> pcb_types.Element:
pcb_footpr_conv/fp2dxf.py    26)     with open(file_name, 'r') as f:
pcb_footpr_conv/fp2dxf.py    27)         s = f.read()
pcb_footpr_conv/fp2dxf.py    28)     parser = pcb_parser.PcbFootprintParser(s)
pcb_footpr_conv/fp2dxf.py    29)     element = parser.parseElementBlock()
pcb_footpr_conv/fp2dxf.py    30)     return element
Stefan Schuermans begin of PCB footprint parser

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/pcbfp2dxf.py 31) 
pcb_footpr_conv/pcbfp2dxf.py 32) 
Stefan Schuermans DXF export of pins + holes

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py    33) def write_dxf(fp: pcb_types.Element, file_name: str):
pcb_footpr_conv/fp2dxf.py    34)     dfw = dxf_export.DxfFootprintWriter()
pcb_footpr_conv/fp2dxf.py    35)     dfw.drawFootprint(fp)
pcb_footpr_conv/fp2dxf.py    36)     dfw.writeDxf(file_name)
Stefan Schuermans begin of PCB footprint parser

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/pcbfp2dxf.py 37) 
pcb_footpr_conv/pcbfp2dxf.py 38) 
pcb_footpr_conv/pcbfp2dxf.py 39) def main():
Stefan Schuermans DXF export of pins + holes

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py    40)     args = parse_args()
pcb_footpr_conv/fp2dxf.py    41)     fp = read_footprint(args.in_footprint)
pcb_footpr_conv/fp2dxf.py    42)     write_dxf(fp, args.out_dxf)