summaryrefslogtreecommitdiff
path: root/gerber/excellon.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-18 04:31:23 -0500
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-18 04:31:23 -0500
commit288ac27084b47166ac662402ea340d0aa25d8f56 (patch)
tree792374b99932120fb08e1d689518eed69e0feccb /gerber/excellon.py
parentbc532997aecc60f5a939f9ca6ba55dd3eae27a42 (diff)
downloadgerbonara-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/excellon.py')
-rwxr-xr-xgerber/excellon.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/gerber/excellon.py b/gerber/excellon.py
index a7f3a27..a339827 100755
--- a/gerber/excellon.py
+++ b/gerber/excellon.py
@@ -23,12 +23,12 @@ Excellon File module
This module provides Excellon file classes and parsing utilities
"""
+import math
from .excellon_statements import *
from .cam import CamFile, FileSettings
from .primitives import Drill
-import math
-import re
+
def read(filename):
""" Read data from filename and return an ExcellonFile
@@ -122,6 +122,31 @@ class ExcellonFile(CamFile):
for statement in self.statements:
f.write(statement.to_excellon(self.settings) + '\n')
+ def to_inch(self):
+ """
+ Convert units to inches
+ """
+ if self.units != 'inch':
+ self.units = 'inch'
+ for statement in self.statements:
+ statement.to_inch()
+ for tool in self.tools.itervalues():
+ tool.to_inch()
+ for primitive in self.primitives:
+ primitive.to_inch()
+
+ def to_metric(self):
+ """ Convert units to metric
+ """
+ if self.units != 'metric':
+ self.units = 'metric'
+ for statement in self.statements:
+ statement.to_metric()
+ for tool in self.tools.itervalues():
+ tool.to_metric()
+ for primitive in self.primitives:
+ primitive.to_metric()
+
class ExcellonParser(object):
""" Excellon File Parser