diff options
author | jaseg <git@jaseg.de> | 2022-01-21 21:41:16 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-01-21 21:41:16 +0100 |
commit | fd8a259fb00af3e5b516ca3a94ecf54178920b92 (patch) | |
tree | 6a6a074d71a00b1bd464a03e95f7af5dcfccf07b /gerbonara | |
parent | 002d1ed0cfad09d444c086398823f2769008bbe2 (diff) | |
download | gerbonara-fd8a259fb00af3e5b516ca3a94ecf54178920b92.tar.gz gerbonara-fd8a259fb00af3e5b516ca3a94ecf54178920b92.tar.bz2 gerbonara-fd8a259fb00af3e5b516ca3a94ecf54178920b92.zip |
Add allegro gerber comment parser
Diffstat (limited to 'gerbonara')
-rw-r--r-- | gerbonara/gerber/layers.py | 2 | ||||
-rw-r--r-- | gerbonara/gerber/rs274x.py | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/gerbonara/gerber/layers.py b/gerbonara/gerber/layers.py index 26dd9c1..bb72ff0 100644 --- a/gerbonara/gerber/layers.py +++ b/gerbonara/gerber/layers.py @@ -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:
diff --git a/gerbonara/gerber/rs274x.py b/gerbonara/gerber/rs274x.py index a572d94..a1cd207 100644 --- a/gerbonara/gerber/rs274x.py +++ b/gerbonara/gerber/rs274x.py @@ -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( |