diff options
author | opiopan <opiopan@gmail.com> | 2019-03-30 11:16:13 +0900 |
---|---|---|
committer | opiopan <opiopan@gmail.com> | 2019-03-30 11:16:13 +0900 |
commit | fcd704e1eef9034e2000f55b2918d7df41379408 (patch) | |
tree | 4bc9f8f3f5f8cced53f9f2dfa8f414dfc6466488 /gerberex/composition.py | |
parent | 7e8f90b3724c62f72cf58ad28c11506212f3b706 (diff) | |
download | gerbonara-fcd704e1eef9034e2000f55b2918d7df41379408.tar.gz gerbonara-fcd704e1eef9034e2000f55b2918d7df41379408.tar.bz2 gerbonara-fcd704e1eef9034e2000f55b2918d7df41379408.zip |
add mouse bites generator function
Diffstat (limited to 'gerberex/composition.py')
-rw-r--r-- | gerberex/composition.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gerberex/composition.py b/gerberex/composition.py index afcaf97..73f5702 100644 --- a/gerberex/composition.py +++ b/gerberex/composition.py @@ -127,10 +127,13 @@ class DrillComposition(Composition): self.header2_statements = [] self.tools = [] self.hits = [] + self.dxf_statements = [] def merge(self, file): if isinstance(file, gerberex.excellon.ExcellonFileEx): self._merge_excellon(file) + elif isinstance(file, gerberex.DxfFile): + self._merge_dxf(file) else: raise Exception('unsupported file type') @@ -147,6 +150,9 @@ class DrillComposition(Composition): for h in self.hits: if h.tool.number == t.number: yield CoordinateStmt(*h.position).to_excellon(self.settings) + for num, statement in self.dxf_statements: + if num == t.number: + yield statement.to_excellon(self.settings) yield EndOfProgramStmt().to_excellon() with open(path, 'w') as f: @@ -186,6 +192,22 @@ class DrillComposition(Composition): hit.tool = tool_map[hit.tool.number] self.hits.append(hit) + def _merge_dxf(self, file): + if not self.settings: + self.settings = file.settings + else: + if self.settings.units == 'metric': + file.to_metric() + else: + file.to_inch() + + if not self.header1_statements: + self.header1_statements = file.header + self.header2_statements = file.header2 + + tool = self._register_tool(ExcellonTool(self.settings, number=1, diameter=file.width)) + self.dxf_statements.append((tool.number, file.statements)) + def _register_tool(self, tool): for existing in self.tools: if existing.equivalent(tool): |