Compare commits
3 Commits
9699d47021
...
8a0033239f
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a0033239f | |||
| d0375d8908 | |||
| 0740cf5dc0 |
21
Ger2KiCad.py
21
Ger2KiCad.py
@@ -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 #
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@@ -40,8 +42,8 @@ class Polygon:
|
|||||||
|
|
||||||
MODE = r"(Mode):\s([a-z]{1,})"
|
MODE = r"(Mode):\s([a-z]{1,})"
|
||||||
SCALE = r"(Scale) Factor:\sX:\s(\d+\.\d+|\d+)\sY:\s(\d+\.\d+|\d+)"
|
SCALE = r"(Scale) Factor:\sX:\s(\d+\.\d+|\d+)\sY:\s(\d+\.\d+|\d+)"
|
||||||
COOR = r"(Coordinate Statement):\s([X,Y]):\s(-?\d+\.\d+|\d+)\s(?:(Y):\s"+\
|
COOR = r"(Coordinate Statement):\s([X,Y]):\s(-?\d+\.\d+|-?\d+)\s(?:(Y):\s"+\
|
||||||
"(-?\d+\.\d+|\d+))?.{1,}Lights\s(On|Off)"
|
"(-?\d+\.\d+|-?\d+))?.{1,}Lights\s(On|Off)"
|
||||||
RMStmtStart = r"(RegionModeStmt) type=RegionMode units=(metric|inch) mode=(on)"
|
RMStmtStart = r"(RegionModeStmt) type=RegionMode units=(metric|inch) mode=(on)"
|
||||||
RMStmtStop = r"(RegionModeStmt) type=RegionMode units=(metric|inch) mode=(off)"
|
RMStmtStop = r"(RegionModeStmt) type=RegionMode units=(metric|inch) mode=(off)"
|
||||||
EOF = r"EOF Statement"
|
EOF = r"EOF Statement"
|
||||||
@@ -237,14 +239,21 @@ def create_kicad_mod(name,polygons,libary="Default",tedit="5EF5C08B"):
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Wrong number of arguments")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
filename = sys.argv[1]
|
||||||
|
|
||||||
|
|
||||||
poly=readGerber('BP.ger')
|
poly=readGerber(filename)
|
||||||
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")
|
|
||||||
output=create_kicad_mod("BP",kicad_poly)
|
|
||||||
|
|
||||||
f= open("BP.kicad_mod","w+")
|
|
||||||
|
kicad_poly = create_kicad_poly(poly,x_c,y_c,layer="F.Cu")
|
||||||
|
output=create_kicad_mod(filename,kicad_poly)
|
||||||
|
|
||||||
|
f= open(filename+".kicad_mod","w+")
|
||||||
f.write(output)
|
f.write(output)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user