summaryrefslogtreecommitdiff
path: root/gerbonara/gerber/gerber_statements.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-01-01 16:28:49 +0100
committerjaseg <git@jaseg.de>2022-01-01 16:28:49 +0100
commitf46b8897818439269d3fbce32773ec1ed12ad657 (patch)
tree51c9b820ef7c18d6371a968b8f1bd7345904d86f /gerbonara/gerber/gerber_statements.py
parentad87bb610f5d1b063fb5a8259d6aabbc6955b65e (diff)
downloadgerbonara-f46b8897818439269d3fbce32773ec1ed12ad657.tar.gz
gerbonara-f46b8897818439269d3fbce32773ec1ed12ad657.tar.bz2
gerbonara-f46b8897818439269d3fbce32773ec1ed12ad657.zip
Merge works.
Diffstat (limited to 'gerbonara/gerber/gerber_statements.py')
-rw-r--r--gerbonara/gerber/gerber_statements.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/gerbonara/gerber/gerber_statements.py b/gerbonara/gerber/gerber_statements.py
index b47dfe3..4e46475 100644
--- a/gerbonara/gerber/gerber_statements.py
+++ b/gerbonara/gerber/gerber_statements.py
@@ -21,6 +21,14 @@ Gerber (RS-274X) Statements
"""
+def convert(value, src, dst):
+ if src == dst or src is None or dst is None or value is None:
+ return value
+ elif dst == 'mm':
+ return value * 25.4
+ else:
+ return value / 25.4
+
class Statement:
pass
@@ -88,6 +96,9 @@ class ApertureDefStmt(ParamStmt):
def __str__(self):
return f'<AD aperture def for {str(self.aperture).strip("<>")}>'
+ def __repr__(self):
+ return f'ApertureDefStmt({self.number}, {repr(self.aperture)})'
+
class ApertureMacroStmt(ParamStmt):
""" AM - Aperture Macro Statement """
@@ -117,13 +128,14 @@ class ImagePolarityStmt(ParamStmt):
class CoordStmt(Statement):
""" D01 - D03 operation statements """
- def __init__(self, x, y, i=None, j=None):
+ def __init__(self, x, y, i=None, j=None, unit=None):
self.x, self.y, self.i, self.j = x, y, i, j
+ self.unit = unit
def to_gerber(self, settings=None):
ret = ''
for var in 'xyij':
- val = getattr(self, var)
+ val = convert(getattr(self, var), self.unit, settings.unit)
if val is not None:
ret += var.upper() + settings.write_gerber_value(val)
return ret + self.code + '*'