summaryrefslogtreecommitdiff
path: root/gerber/am_statements.py
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2016-02-27 18:18:04 +0800
committerGarret Fick <garret@ficksworkshop.com>2016-02-27 18:18:04 +0800
commit223a010831f0d9dae4bd6d2e626a603a78eb0b1d (patch)
treef8e341156d652990b79f182df65c321549222e74 /gerber/am_statements.py
parent29c0d82bf53907030d11df9eb09471b716a0be2e (diff)
downloadgerbonara-223a010831f0d9dae4bd6d2e626a603a78eb0b1d.tar.gz
gerbonara-223a010831f0d9dae4bd6d2e626a603a78eb0b1d.tar.bz2
gerbonara-223a010831f0d9dae4bd6d2e626a603a78eb0b1d.zip
Fix critical issue with rotatin points (when the angle is zero the y would be flipped). Render AM with outline to gerber
Diffstat (limited to 'gerber/am_statements.py')
-rw-r--r--gerber/am_statements.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/gerber/am_statements.py b/gerber/am_statements.py
index 2bca6e6..05ebd9d 100644
--- a/gerber/am_statements.py
+++ b/gerber/am_statements.py
@@ -334,6 +334,19 @@ class AMOutlinePrimitive(AMPrimitive):
------
ValueError, TypeError
"""
+
+ @classmethod
+ def from_primitive(cls, primitive):
+
+ start_point = (round(primitive.primitives[0].start[0], 6), round(primitive.primitives[0].start[1], 6))
+ points = []
+ for prim in primitive.primitives:
+ points.append((round(prim.end[0], 6), round(prim.end[1], 6)))
+
+ rotation = 0.0
+
+ return cls(4, 'on', start_point, points, rotation)
+
@classmethod
def from_gerber(cls, primitive):
modifiers = primitive.strip(' *').split(",")
@@ -376,17 +389,18 @@ class AMOutlinePrimitive(AMPrimitive):
code=self.code,
exposure="1" if self.exposure == "on" else "0",
n_points=len(self.points),
- start_point="%.4g,%.4g" % self.start_point,
- points=",".join(["%.4g,%.4g" % point for point in self.points]),
+ start_point="%.6g,%.6g" % self.start_point,
+ points=",\n".join(["%.6g,%.6g" % point for point in self.points]),
rotation=str(self.rotation)
)
- return "{code},{exposure},{n_points},{start_point},{points},{rotation}*".format(**data)
+ # TODO I removed a closing asterix - not sure if this works for items with multiple statements
+ return "{code},{exposure},{n_points},{start_point},{points},\n{rotation}".format(**data)
def to_primitive(self, units):
lines = []
- prev_point = rotate_point(self.points[0], self.rotation)
- for point in self.points[1:]:
+ prev_point = rotate_point(self.start_point, self.rotation)
+ for point in self.points:
cur_point = rotate_point(point, self.rotation)
lines.append(Line(prev_point, cur_point, Circle((0,0), 0)))