summaryrefslogtreecommitdiff
path: root/gerber
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2016-03-05 09:24:54 +0800
committerGarret Fick <garret@ficksworkshop.com>2016-03-05 09:24:54 +0800
commit7b88509c4acb4edbbe1a39762758bf28efecfc7f (patch)
treea6f4fb02d025ed473ae117772a387dd4d3e84719 /gerber
parent20a9af279ac2217a39b73903ff94b916a3025be2 (diff)
downloadgerbonara-7b88509c4acb4edbbe1a39762758bf28efecfc7f.tar.gz
gerbonara-7b88509c4acb4edbbe1a39762758bf28efecfc7f.tar.bz2
gerbonara-7b88509c4acb4edbbe1a39762758bf28efecfc7f.zip
Make writer resilient to similar macro defs
Diffstat (limited to 'gerber')
-rw-r--r--gerber/render/rs274x_backend.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/gerber/render/rs274x_backend.py b/gerber/render/rs274x_backend.py
index 2a0420e..d4456e2 100644
--- a/gerber/render/rs274x_backend.py
+++ b/gerber/render/rs274x_backend.py
@@ -355,8 +355,19 @@ class Rs274xContext(GerberContext):
# but in most cases, this should work
hash = self._hash_amacro(amgroup)
- macro = self._macros.get(hash, None)
+ macro = None
+ macroinfo = self._macros.get(hash, None)
+ if macroinfo:
+
+ # 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])
+ if amgroup.equivalent(macro[1], offset):
+ break
+ macro = None
+
+ # Did we find one in the group0
if not macro:
# This is a new macro, so define it
if not dcode:
@@ -377,13 +388,11 @@ class Rs274xContext(GerberContext):
# Store the dcode and the original so we can check if it really is the same
macro = (aperdef, amgroup)
- self._macros[hash] = macro
-
- else:
- # We hae a definition, but check that the groups actually are the same
- offset = (amgroup.position[0] - macro[1].position[0], amgroup.position[1] - macro[1].position[1])
- if not amgroup.equivalent(macro[1], offset):
- raise ValueError('Two AMGroup have the same hash but are not equivalent')
+
+ if macroinfo:
+ macroinfo.append(macro)
+ else:
+ self._macros[hash] = [macro]
return macro[0]