diff options
author | opiopan <opiopan@gmail.com> | 2019-03-21 22:00:32 +0900 |
---|---|---|
committer | opiopan <opiopan@gmail.com> | 2019-03-21 22:00:32 +0900 |
commit | 9febca7da6a730b3b3ca3a54129a9f88e5c44d14 (patch) | |
tree | 3f260096ab0c40eca527195630ab004208b4ee78 /gerberex/statements.py | |
download | pcb-tools-extension-9febca7da6a730b3b3ca3a54129a9f88e5c44d14.tar.gz pcb-tools-extension-9febca7da6a730b3b3ca3a54129a9f88e5c44d14.tar.bz2 pcb-tools-extension-9febca7da6a730b3b3ca3a54129a9f88e5c44d14.zip |
initial commit
Diffstat (limited to 'gerberex/statements.py')
-rw-r--r-- | gerberex/statements.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gerberex/statements.py b/gerberex/statements.py new file mode 100644 index 0000000..77ca235 --- /dev/null +++ b/gerberex/statements.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com> + +from gerber.gerber_statements import AMParamStmt +from gerberex.am_primitive import to_primitive_defs + +class AMParamStmtEx(AMParamStmt): + @classmethod + def from_stmt(cls, stmt): + return cls(stmt.param, stmt.name, stmt.macro) + + def __init__(self, param, name, macro): + super(AMParamStmtEx, self).__init__(param, name, macro) + self.primitive_defs = to_primitive_defs(self.instructions) + + def to_inch(self): + if self.units == 'metric': + self.units = 'inch' + for p in self.primitive_defs: + p.to_inch() + + def to_metric(self): + if self.units == 'inch': + self.units = 'metric' + for p in self.primitive_defs: + p.to_metric() + + def to_gerber(self, settings = None): + def plist(): + for p in self.primitive_defs: + yield p.to_gerber(settings) + return "%%AM%s*\n%s%%" % (self.name, '\n'.join(plist())) |