8a9acb126fbc1913349895147ed1eed09bf9b6d8
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 PCB element Python types

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py     3) import pcb_parser
pcb_footpr_conv/fp2dxf.py     4) import pcb_types
pcb_footpr_conv/fp2dxf.py     5) 
Stefan Schuermans begin of PCB footprint parser

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/pcbfp2dxf.py  6) import ezdxf
Stefan Schuermans begin of PCB footprint pars...

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py     7) import sys
pcb_footpr_conv/fp2dxf.py     8) 
pcb_footpr_conv/fp2dxf.py     9) 
Stefan Schuermans PCB element Python types

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py    10) def read_footprint(file_name: str) -> pcb_types.Element:
pcb_footpr_conv/fp2dxf.py    11)     with open(file_name, 'r') as f:
pcb_footpr_conv/fp2dxf.py    12)         s = f.read()
pcb_footpr_conv/fp2dxf.py    13)     parser = pcb_parser.PcbFootprintParser(s)
pcb_footpr_conv/fp2dxf.py    14)     element = parser.parseElementBlock()
pcb_footpr_conv/fp2dxf.py    15)     return element
Stefan Schuermans begin of PCB footprint parser

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/pcbfp2dxf.py 16) 
pcb_footpr_conv/pcbfp2dxf.py 17) 
pcb_footpr_conv/pcbfp2dxf.py 18) def write_dxf(file_name: str):
pcb_footpr_conv/pcbfp2dxf.py 19)     doc = ezdxf.new('R12')
pcb_footpr_conv/pcbfp2dxf.py 20)     msp = doc.modelspace()
pcb_footpr_conv/pcbfp2dxf.py 21)     msp.add_circle((1, 2), radius=3)
pcb_footpr_conv/pcbfp2dxf.py 22)     doc.saveas(file_name)
pcb_footpr_conv/pcbfp2dxf.py 23) 
pcb_footpr_conv/pcbfp2dxf.py 24) 
pcb_footpr_conv/pcbfp2dxf.py 25) def main():
Stefan Schuermans PCB element Python types

Stefan Schuermans authored 3 years ago

pcb_footpr_conv/fp2dxf.py    26)     fp = read_footprint(sys.argv[1])
pcb_footpr_conv/fp2dxf.py    27)     print(fp)