Added file selection by command line argument

This commit is contained in:
2021-07-20 14:40:37 +02:00
parent 0740cf5dc0
commit d0375d8908
2 changed files with 14 additions and 3 deletions

View File

@@ -12,6 +12,8 @@
import gerber import gerber
import re import re
import numpy as np import numpy as np
import sys
import os
############################################################################## ##############################################################################
# Define Classes # # Define Classes #
############################################################################## ##############################################################################
@@ -237,14 +239,19 @@ def create_kicad_mod(name,polygons,libary="Default",tedit="5EF5C08B"):
############################################################################## ##############################################################################
if len(sys.argv) != 2:
print("Wrong number of arguments")
exit()
filename = os.path.splitext(sys.argv[1])[0]
poly=readGerber('BP.ger') poly=readGerber(filename+'.gbr')
x_c,y_c = find_center(poly) x_c,y_c = find_center(poly)
kicad_poly = create_kicad_poly(poly,x_c,y_c,layer="F.Cu") kicad_poly = create_kicad_poly(poly,x_c,y_c,layer="F.Cu")
output=create_kicad_mod("BP",kicad_poly) output=create_kicad_mod(filename,kicad_poly)
f= open("BP.kicad_mod","w+") f= open(filename+".kicad_mod","w+")
f.write(output) f.write(output)
f.close() f.close()

View File

@@ -4,4 +4,8 @@ A simple python script to convert Gerber files (RS274X) to .kicad_mod files that
This script was mainly designed to import RF structures in KiCad, but should handle all polygon based designs (Uses G36/G37 codes of the RS274X standard). This script was mainly designed to import RF structures in KiCad, but should handle all polygon based designs (Uses G36/G37 codes of the RS274X standard).
Example:
python Ger2KiCad.py BP.ger
This script uses the [pcb-tools](https://github.com/curtacircuitos/pcb-tools) package. This script uses the [pcb-tools](https://github.com/curtacircuitos/pcb-tools) package.