diff options
author | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2015-02-18 04:31:23 -0500 |
---|---|---|
committer | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2015-02-18 04:31:23 -0500 |
commit | 288ac27084b47166ac662402ea340d0aa25d8f56 (patch) | |
tree | 792374b99932120fb08e1d689518eed69e0feccb /gerber/rs274x.py | |
parent | bc532997aecc60f5a939f9ca6ba55dd3eae27a42 (diff) | |
download | gerbonara-288ac27084b47166ac662402ea340d0aa25d8f56.tar.gz gerbonara-288ac27084b47166ac662402ea340d0aa25d8f56.tar.bz2 gerbonara-288ac27084b47166ac662402ea340d0aa25d8f56.zip |
Get unit conversion working for Gerber/Excellon files
Started operations module for file operations/transforms
Diffstat (limited to 'gerber/rs274x.py')
-rw-r--r-- | gerber/rs274x.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gerber/rs274x.py b/gerber/rs274x.py index 71ca111..21947e1 100644 --- a/gerber/rs274x.py +++ b/gerber/rs274x.py @@ -18,14 +18,15 @@ """ This module provides an RS-274-X class and parser. """ - import copy import json import re + from .gerber_statements import * from .primitives import * from .cam import CamFile, FileSettings + def read(filename): """ Read data from filename and return a GerberFile @@ -112,6 +113,21 @@ class GerberFile(CamFile): f.write(statement.to_gerber(settings or self.settings)) f.write("\n") + def to_inch(self): + if self.units != 'inch': + self.units = 'inch' + for statement in self.statements: + statement.to_inch() + for primitive in self.primitives: + primitive.to_inch() + + def to_metric(self): + if self.units != 'metric': + self.units = 'metric' + for statement in self.statements: + statement.to_metric() + for primitive in self.primitives: + primitive.to_metric() class GerberParser(object): |