summaryrefslogtreecommitdiff
path: root/gerber/am_statements.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2015-03-03 03:41:55 -0300
committerPaulo Henrique Silva <ph.silva@gmail.com>2015-03-03 03:41:55 -0300
commit670d3fbbd7ebfb69bd223ac30b73ec47b195b380 (patch)
tree5373fdec50462a210f84d25caa93f1bc1204c4cb /gerber/am_statements.py
parentb8dcc86cb4560d033761db0ad41924f6d9669333 (diff)
downloadgerbonara-670d3fbbd7ebfb69bd223ac30b73ec47b195b380.tar.gz
gerbonara-670d3fbbd7ebfb69bd223ac30b73ec47b195b380.tar.bz2
gerbonara-670d3fbbd7ebfb69bd223ac30b73ec47b195b380.zip
Add aperture macro parsing and evaluation.
Aperture macros can get complex with arithmetical operations, variables and variables substitution. Current pcb-tools code just read each macro block as an independent unit, this cannot deal with variables that get changed after used. This patch splits the task in two: first we parse all macro content and creates a bytecode representation of all operations. This bytecode representation will be executed when an AD command is issues passing the required parameters. Parsing is heavily based on gerbv using a Shunting Yard approach to math parsing. Integration with rs274x.py code is not finished as I need to figure out how to integrate the final macro primitives with the graphical primitives already in use.
Diffstat (limited to 'gerber/am_statements.py')
-rw-r--r--gerber/am_statements.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/gerber/am_statements.py b/gerber/am_statements.py
index bdb12dd..c514ad7 100644
--- a/gerber/am_statements.py
+++ b/gerber/am_statements.py
@@ -406,9 +406,13 @@ class AMPolygonPrimitive(AMPrimitive):
modifiers = primitive.strip(' *').split(",")
code = int(modifiers[0])
exposure = "on" if modifiers[1].strip() == "1" else "off"
- vertices = int(modifiers[2])
+ vertices = int(float(modifiers[2]))
position = (float(modifiers[3]), float(modifiers[4]))
- diameter = float(modifiers[5])
+ try:
+ diameter = float(modifiers[5])
+ except:
+ diameter = 0
+
rotation = float(modifiers[6])
return cls(code, exposure, vertices, position, diameter, rotation)