summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2016-03-05 10:28:38 +0800
committerGarret Fick <garret@ficksworkshop.com>2016-03-05 10:28:38 +0800
commit97355475686dd4bdad1b0bd9a307843ea3c234f2 (patch)
tree1cd7a35ae6ab70b47c88cc4130e97f55bcfab6bd
parent7f47aea332ee1df45c87baa304d95ed03cc59865 (diff)
downloadgerbonara-97355475686dd4bdad1b0bd9a307843ea3c234f2.tar.gz
gerbonara-97355475686dd4bdad1b0bd9a307843ea3c234f2.tar.bz2
gerbonara-97355475686dd4bdad1b0bd9a307843ea3c234f2.zip
Make rendering more robust for bad gerber files
-rw-r--r--gerber/render/rs274x_backend.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/gerber/render/rs274x_backend.py b/gerber/render/rs274x_backend.py
index 04ecbe6..5a15fe5 100644
--- a/gerber/render/rs274x_backend.py
+++ b/gerber/render/rs274x_backend.py
@@ -2,7 +2,7 @@
from .render import GerberContext
from ..am_statements import *
from ..gerber_statements import *
-from ..primitives import AMGroup, Arc, Circle, Line, Outline, Polygon, Rectangle
+from ..primitives import AMGroup, Arc, Circle, Line, Obround, Outline, Polygon, Rectangle
from copy import deepcopy
class AMGroupContext(object):
@@ -152,6 +152,10 @@ class Rs274xContext(GerberContext):
aper = self._get_circle(aperture.diameter)
elif isinstance(aperture, Rectangle):
aper = self._get_rectangle(aperture.width, aperture.height)
+ elif isinstance(aperture, Obround):
+ aper = self._get_obround(aperture.width, aperture.height)
+ elif isinstance(aperture, AMGroup):
+ aper = self._get_amacro(aperture)
else:
raise NotImplementedError('Line with invalid aperture type')
@@ -367,7 +371,15 @@ class Rs274xContext(GerberContext):
# We hae a definition, but check that the groups actually are the same
for macro in macroinfo:
- offset = (amgroup.position[0] - macro[1].position[0], amgroup.position[1] - macro[1].position[1])
+
+ # Macros should have positions, right? But if the macro is selected for non-flashes
+ # then it won't have a position. This is of course a bad gerber, but they do exist
+ if amgroup.position:
+ position = amgroup.position
+ else:
+ position = (0, 0)
+
+ offset = (position[0] - macro[1].position[0], position[1] - macro[1].position[1])
if amgroup.equivalent(macro[1], offset):
break
macro = None