summaryrefslogtreecommitdiff
path: root/gerber/excellon.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-18 23:13:23 -0500
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-18 23:13:23 -0500
commit5966d7830bda7f37ed5ddcc1bfccb93e7f780eaa (patch)
treeb5d96312c9dab598ec342d2215d235f2b00e8a48 /gerber/excellon.py
parent4b92e1b59dcaff48bda4e1c906506432651fcd4f (diff)
downloadgerbonara-5966d7830bda7f37ed5ddcc1bfccb93e7f780eaa.tar.gz
gerbonara-5966d7830bda7f37ed5ddcc1bfccb93e7f780eaa.tar.bz2
gerbonara-5966d7830bda7f37ed5ddcc1bfccb93e7f780eaa.zip
Add offset operation
Diffstat (limited to 'gerber/excellon.py')
-rwxr-xr-xgerber/excellon.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/gerber/excellon.py b/gerber/excellon.py
index ebc307f..900e2df 100755
--- a/gerber/excellon.py
+++ b/gerber/excellon.py
@@ -28,6 +28,7 @@ import math
from .excellon_statements import *
from .cam import CamFile, FileSettings
from .primitives import Drill
+from .utils import inch, metric
def read(filename):
@@ -134,6 +135,9 @@ class ExcellonFile(CamFile):
tool.to_inch()
for primitive in self.primitives:
primitive.to_inch()
+ self.hits = [(tool, tuple(map(inch, pos)))
+ for tool, pos in self.hits]
+
def to_metric(self):
""" Convert units to metric
@@ -146,6 +150,16 @@ class ExcellonFile(CamFile):
tool.to_metric()
for primitive in self.primitives:
primitive.to_metric()
+ self.hits = [(tool, tuple(map(metric, pos)))
+ for tool, pos in self.hits]
+
+ def offset(self, x_offset=0, y_offset=0):
+ for statement in self.statements:
+ statement.offset(x_offset, y_offset)
+ for primitive in self.primitives:
+ primitive.offset(x_offset, y_offset)
+ self.hits = [(tool, (pos[0] + x_offset, pos[1] + y_offset))
+ for tool, pos in self.hits]
class ExcellonParser(object):