diff options
-rw-r--r-- | gerber/am_statements.py | 4 | ||||
-rw-r--r-- | gerber/gerber_statements.py | 10 | ||||
-rw-r--r-- | gerber/rs274x.py | 6 |
3 files changed, 18 insertions, 2 deletions
diff --git a/gerber/am_statements.py b/gerber/am_statements.py index 0d92a8c..a58f1dd 100644 --- a/gerber/am_statements.py +++ b/gerber/am_statements.py @@ -523,7 +523,7 @@ class AMPolygonPrimitive(AMPrimitive): return fmt.format(**data) def to_primitive(self, units): - return Polygon(self.position, self.vertices, self.diameter / 2.0, hole_radius=0, rotation=self.rotation, units=units, level_polarity=self._level_polarity) + return Polygon(self.position, self.vertices, self.diameter / 2.0, rotation=math.radians(self.rotation), units=units, level_polarity=self._level_polarity) class AMMoirePrimitive(AMPrimitive): @@ -897,7 +897,7 @@ class AMCenterLinePrimitive(AMPrimitive): return fmt.format(**data) def to_primitive(self, units): - return Rectangle(self.center, self.width, self.height, rotation=self.rotation, units=units, level_polarity=self._level_polarity) + return Rectangle(self.center, self.width, self.height, rotation=math.radians(self.rotation), units=units, level_polarity=self._level_polarity) class AMLowerLeftLinePrimitive(AMPrimitive): diff --git a/gerber/gerber_statements.py b/gerber/gerber_statements.py index 234952e..881e5bc 100644 --- a/gerber/gerber_statements.py +++ b/gerber/gerber_statements.py @@ -1022,6 +1022,16 @@ class CoordStmt(Statement): coord_str += 'Op: %s' % op return '<Coordinate Statement: %s>' % coord_str + + @property + def only_function(self): + """ + Returns if the statement only set the function. + """ + + # TODO I would like to refactor this so that the function is handled separately and then + # TODO this isn't required + return self.function != None and self.op == None and self.x == None and self.y == None and self.i == None and self.j == None class ApertureStmt(Statement): diff --git a/gerber/rs274x.py b/gerber/rs274x.py index ffac66d..384d498 100644 --- a/gerber/rs274x.py +++ b/gerber/rs274x.py @@ -536,6 +536,12 @@ class GerberParser(object): elif stmt.function in ('G02', 'G2', 'G03', 'G3'): self.interpolation = 'arc' self.direction = ('clockwise' if stmt.function in ('G02', 'G2') else 'counterclockwise') + + if stmt.only_function: + # Sometimes we get a coordinate statement + # that only sets the function. If so, don't + # try futher otherwise that might draw/flash something + return if stmt.op: self.op = stmt.op |