diff options
author | jaseg <git@jaseg.de> | 2023-04-29 11:28:38 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-04-29 11:28:38 +0200 |
commit | 8d5403260b72115cfd9f401289dfd0f894e272ea (patch) | |
tree | 0f7ac51c4072477018fec6f8d153d00365735f34 /gerbonara/aperture_macros/primitive.py | |
parent | 778e81974580d910eac5e3f977acf79744d3e085 (diff) | |
download | gerbonara-8d5403260b72115cfd9f401289dfd0f894e272ea.tar.gz gerbonara-8d5403260b72115cfd9f401289dfd0f894e272ea.tar.bz2 gerbonara-8d5403260b72115cfd9f401289dfd0f894e272ea.zip |
Fix aperture macro rotation issue and add missing data files
Diffstat (limited to 'gerbonara/aperture_macros/primitive.py')
-rw-r--r-- | gerbonara/aperture_macros/primitive.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/gerbonara/aperture_macros/primitive.py b/gerbonara/aperture_macros/primitive.py index 5700743..356da9f 100644 --- a/gerbonara/aperture_macros/primitive.py +++ b/gerbonara/aperture_macros/primitive.py @@ -13,7 +13,7 @@ from .expression import Expression, UnitExpression, ConstantExpression, expr from .. import graphic_primitives as gp from .. import graphic_objects as go -from ..utils import rotate_point, LengthUnit +from ..utils import rotate_point, LengthUnit, MM def point_distance(a, b): @@ -277,8 +277,20 @@ class Outline(Primitive): return f'<Outline {len(self.coords)} points>' def to_gerber(self, unit=None): - coords = ','.join(coord.to_gerber(unit) for coord in self.coords) - return f'{self.code},{self.exposure.to_gerber()},{len(self.coords)-1},{coords},{self.rotation.to_gerber()}' + # Calculate out rotation since at least gerbv mis-renders Outlines with rotation other than zero. + rotation = self.rotation.optimized() + coords = self.coords + if isinstance(rotation, ConstantExpression): + rotation = math.radians(rotation.value) + # This will work even with variables in x and y, we just need to pass in cx and cy as UnitExpressions + unit_zero = UnitExpression(expr(0), MM) + coords = [ rotate_point(x, y, -rotation, cx=unit_zero, cy=unit_zero) for x, y in self.points ] + coords = [ e for point in coords for e in point ] + + rotation = ConstantExpression(0) + + coords = ','.join(coord.to_gerber(unit) for coord in coords) + return f'{self.code},{self.exposure.to_gerber()},{len(self.coords)-1},{coords},{rotation.to_gerber()}' def to_graphic_primitives(self, offset, rotation, variable_binding={}, unit=None, polarity_dark=True): with self.Calculator(self, variable_binding, unit) as calc: |