summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2016-02-16 22:24:03 +0800
committerGarret Fick <garret@ficksworkshop.com>2016-02-16 22:24:03 +0800
commit4bc7a6345b16bfeaa969f533a1da97cbf9e44e4c (patch)
treee8ac13be9b1d42bb5607cd5e1032a977082cde1a
parent991a3687ef741831c860fcbde38651f3660b6b23 (diff)
downloadgerbonara-4bc7a6345b16bfeaa969f533a1da97cbf9e44e4c.tar.gz
gerbonara-4bc7a6345b16bfeaa969f533a1da97cbf9e44e4c.tar.bz2
gerbonara-4bc7a6345b16bfeaa969f533a1da97cbf9e44e4c.zip
Keep aperature macros as single statement. Don't generate regions with no points
-rw-r--r--gerber/rs274x.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/gerber/rs274x.py b/gerber/rs274x.py
index 9d5b141..92f4c4b 100644
--- a/gerber/rs274x.py
+++ b/gerber/rs274x.py
@@ -237,18 +237,29 @@ class GerberParser(object):
length = len(data)
start = 0
+ in_header = True
for cur in range(0, length):
-
+
val = data[cur]
+
+ if val == '%' and start == cur:
+ in_header = True
+ continue
+
if val == '\r' or val == '\n':
if start != cur:
yield data[start:cur]
start = cur + 1
- elif val == '*':
+ elif not in_header and val == '*':
+ yield data[start:cur + 1]
+ start = cur + 1
+
+ elif in_header and val == '%':
yield data[start:cur + 1]
start = cur + 1
+ in_header = False
def dump_json(self):
stmts = {"statements": [stmt.__dict__ for stmt in self.statements]}
@@ -457,7 +468,9 @@ class GerberParser(object):
def _evaluate_mode(self, stmt):
if stmt.type == 'RegionMode':
if self.region_mode == 'on' and stmt.mode == 'off':
- self.primitives.append(Region(self.current_region, level_polarity=self.level_polarity, units=self.settings.units))
+ # Sometimes we have regions that have no points. Skip those
+ if self.current_region:
+ self.primitives.append(Region(self.current_region, level_polarity=self.level_polarity, units=self.settings.units))
self.current_region = None
self.region_mode = stmt.mode
elif stmt.type == 'QuadrantMode':