diff options
author | opiopan <opiopan@gmail.com> | 2019-04-07 22:22:33 +0900 |
---|---|---|
committer | opiopan <opiopan@gmail.com> | 2019-04-07 22:22:33 +0900 |
commit | e3c59e39cf9bc64ce9d76c324b82956a65515f16 (patch) | |
tree | 96a87bab252420c14d955ad4c1d59a5101b77cf4 /gerberex/excellon.py | |
parent | d53293a609a83aa945af6864285b90d36bcbdd69 (diff) | |
download | gerbonara-e3c59e39cf9bc64ce9d76c324b82956a65515f16.tar.gz gerbonara-e3c59e39cf9bc64ce9d76c324b82956a65515f16.tar.bz2 gerbonara-e3c59e39cf9bc64ce9d76c324b82956a65515f16.zip |
expand test and fix many issues
Diffstat (limited to 'gerberex/excellon.py')
-rw-r--r-- | gerberex/excellon.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gerberex/excellon.py b/gerberex/excellon.py index 90d6742..b72b95b 100644 --- a/gerberex/excellon.py +++ b/gerberex/excellon.py @@ -6,6 +6,7 @@ from gerber.excellon import (ExcellonParser, detect_excellon_format, ExcellonFile) from gerber.excellon_statements import UnitStmt from gerber.cam import FileSettings +from gerber.utils import inch, metric from gerberex.utility import rotate def loads(data, filename=None, settings=None, tools=None, format=None): @@ -33,6 +34,19 @@ class ExcellonFileEx(ExcellonFile): return for hit in self.hits: hit.position = rotate(hit.position[0], hit.position[1], angle, center) + + def to_inch(self): + if self.units == 'metric': + super(ExcellonFileEx, self).to_inch() + for hit in self.hits: + hit.position = (inch(hit.position[0]), inch(hit.position[1])) + + def to_metric(self): + if self.units == 'inch': + super(ExcellonFileEx, self).to_metric() + for hit in self.hits: + hit.position = (metric(hit.position[0]), metric(hit.position[1])) + class UnitStmtEx(UnitStmt): @classmethod @@ -43,7 +57,8 @@ class UnitStmtEx(UnitStmt): super(UnitStmtEx, self).__init__(units, zeros, format, **kwargs) def to_excellon(self, settings=None): + format = settings.format if settings else self.format stmt = '%s,%s,%s.%s' % ('INCH' if self.units == 'inch' else 'METRIC', 'LZ' if self.zeros == 'leading' else 'TZ', - '0' * self.format[0], '0' * self.format[1]) + '0' * format[0], '0' * format[1]) return stmt |