Fixed gerber parse error related to extra trace.

This commit is contained in:
jpcaram 2015-02-17 17:54:51 -05:00
parent 9b9258a831
commit 873db32aad
2 changed files with 34 additions and 2 deletions

View File

@ -43,8 +43,8 @@ import simplejson as json
import logging
log = logging.getLogger('base2')
#log.setLevel(logging.DEBUG)
log.setLevel(logging.WARNING)
log.setLevel(logging.DEBUG)
#log.setLevel(logging.WARNING)
#log.setLevel(logging.INFO)
formatter = logging.Formatter('[%(levelname)s] %(message)s')
handler = logging.StreamHandler()
@ -1598,6 +1598,8 @@ class Gerber (Geometry):
self.apertures[current_aperture])
poly_buffer.append(flash)
path = [[current_x, current_y]] # Reset path starting point
continue
### G02/3 - Circular interpolation

30
sandbox/gerber_find.py Normal file
View File

@ -0,0 +1,30 @@
from camlib import *
def gerber_find(filename, coords, frac_digits=5, tol=0.1):
g = Gerber()
f = open(filename)
current_x = None
current_y = None
line_num = 0
for line in f:
line_num += 1
try:
match = g.lin_re.search(line)
if match:
# Parse coordinates
if match.group(2) is not None:
current_x = parse_gerber_number(match.group(2), frac_digits)
if match.group(3) is not None:
current_y = parse_gerber_number(match.group(3), frac_digits)
if distance(coords, (current_x, current_y)) <= tol:
print line_num, ":", line.strip('\n\r')
except Exception as e:
print str(e)
print line_num, ":", line.strip('\n\r')
if __name__ == "__main__":
filename = "/home/jpcaram/flatcam_test_files/ExtraTrace_cleanup.gbr"
gerber_find(filename, (1.2, 1.1))