Add allegro gerber comment parser
This commit is contained in:
parent
002d1ed0cf
commit
fd8a259fb0
2 changed files with 32 additions and 1 deletions
|
|
@ -174,6 +174,7 @@ class LayerStack:
|
|||
filemap = autoguess([ f for files in filemap for f in files ])
|
||||
if len(filemap < 6):
|
||||
raise SystemError('Cannot figure out gerber file mapping')
|
||||
# FIXME use layer metadata from comments and ipc file if available
|
||||
|
||||
else:
|
||||
excellon_settings = None
|
||||
|
|
@ -236,6 +237,7 @@ class LayerStack:
|
|||
self.drill_layers = [target]
|
||||
|
||||
def normalize_drill_layers(self):
|
||||
# TODO: maybe also separate into drill and route?
|
||||
drill_pth, drill_npth, drill_aux = [], [], []
|
||||
|
||||
for layer in self.drill_layers:
|
||||
|
|
|
|||
|
|
@ -556,6 +556,8 @@ class GerberParser:
|
|||
self.multi_quadrant_mode = None # used only for syntax checking
|
||||
self.macros = {}
|
||||
self.last_operation = None
|
||||
self.generator_hints = []
|
||||
self.layer_hints = []
|
||||
|
||||
@classmethod
|
||||
def _split_commands(kls, data):
|
||||
|
|
@ -800,7 +802,34 @@ class GerberParser:
|
|||
self.graphics_state.scale_factor = a, b
|
||||
|
||||
def _parse_comment(self, match):
|
||||
self.target.comments.append(match["comment"])
|
||||
cmt = match["comment"].strip()
|
||||
|
||||
# Parse metadata from allegro comments
|
||||
# We do this for layer identification since allegro files usually do not follow any defined naming scheme
|
||||
if cmt.startswith('File Origin:') and 'Allegro' in cmt:
|
||||
self.generator_hints.append('allegro')
|
||||
|
||||
elif cmt.startswith('Layer:'):
|
||||
if 'BOARD GEOMETRY' in cmt:
|
||||
if 'SOLDERMASK_TOP' in cmt:
|
||||
self.layer_hints.append('top mask')
|
||||
if 'SOLDERMASK_BOTTOM' in cmt:
|
||||
self.layer_hints.append('bottom mask')
|
||||
if 'PASTEMASK_TOP' in cmt:
|
||||
self.layer_hints.append('top paste')
|
||||
if 'PASTEMASK_BOTTOM' in cmt:
|
||||
self.layer_hints.append('bottom paste')
|
||||
if 'SILKSCREEN_TOP' in cmt:
|
||||
self.layer_hints.append('top silk')
|
||||
if 'SILKSCREEN_BOTTOM' in cmt:
|
||||
self.layer_hints.append('bottom silk')
|
||||
elif 'ETCH' in cmt:
|
||||
_1, _2, name = cmt.partition('/')
|
||||
name = re.sub('\W+', '_', name)
|
||||
self.layer_hints.append(f'{name} copper')
|
||||
|
||||
else:
|
||||
self.target.comments.append(cmt)
|
||||
|
||||
def _parse_region_start(self, _match):
|
||||
self.current_region = go.Region(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue