summaryrefslogtreecommitdiff
path: root/gerber/rs274x.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2015-11-13 04:17:27 -0200
committerPaulo Henrique Silva <ph.silva@gmail.com>2015-11-13 04:17:27 -0200
commit2208fe22052bf04816e5492cdcb4469c19644e4b (patch)
treea666f1eba88d71c9d88a96ab92724c1ce265760b /gerber/rs274x.py
parent6d8b5377a8624ca35bcf93fb0751bc5ebebfd126 (diff)
downloadgerbonara-2208fe22052bf04816e5492cdcb4469c19644e4b.tar.gz
gerbonara-2208fe22052bf04816e5492cdcb4469c19644e4b.tar.bz2
gerbonara-2208fe22052bf04816e5492cdcb4469c19644e4b.zip
Fix issue when a region is created as the first graphical object in a file
When regions were the first thing draw there is no current aperture defined, as regions do not require an aperture, so we use an zeroed Circle as aperture in this case. Gerber spec says that apertures have no graphical meaning for regions, so this should be enough.
Diffstat (limited to 'gerber/rs274x.py')
-rw-r--r--gerber/rs274x.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/gerber/rs274x.py b/gerber/rs274x.py
index 210b590..72d7e95 100644
--- a/gerber/rs274x.py
+++ b/gerber/rs274x.py
@@ -483,10 +483,13 @@ class GerberParser(object):
if self.region_mode == 'off':
self.primitives.append(Line(start, end, self.apertures[self.aperture], level_polarity=self.level_polarity, units=self.settings.units))
else:
+ # from gerber spec revision J3, Section 4.5, page 55:
+ # The segments are not graphics objects in themselves; segments are part of region which is the graphics object. The segments have no thickness.
+ # The current aperture is associated with the region. This has no graphical effect, but allows all its attributes to be applied to the region.
if self.current_region is None:
- self.current_region = [Line(start, end, self.apertures[self.aperture], level_polarity=self.level_polarity, units=self.settings.units),]
+ self.current_region = [Line(start, end, self.apertures.get(self.aperture, Circle((0,0), 0)), level_polarity=self.level_polarity, units=self.settings.units),]
else:
- self.current_region.append(Line(start, end, self.apertures[self.aperture], level_polarity=self.level_polarity, units=self.settings.units))
+ self.current_region.append(Line(start, end, self.apertures.get(self.aperture, Circle((0,0), 0)), level_polarity=self.level_polarity, units=self.settings.units))
else:
i = 0 if stmt.i is None else stmt.i
j = 0 if stmt.j is None else stmt.j