diff options
author | jaseg <git@jaseg.de> | 2023-11-09 14:30:12 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-11-14 21:52:12 +0100 |
commit | 37b6b8f8d26d6ef83d76cee1516398ee4fcc4fa4 (patch) | |
tree | 1a6833a7294945cd5cec64848cddc6b512e117cb /gerbonara/aperture_macros/primitive.py | |
parent | 07362c592feeda71ec9b583ae54ae107f983039e (diff) | |
download | gerbonara-37b6b8f8d26d6ef83d76cee1516398ee4fcc4fa4.tar.gz gerbonara-37b6b8f8d26d6ef83d76cee1516398ee4fcc4fa4.tar.bz2 gerbonara-37b6b8f8d26d6ef83d76cee1516398ee4fcc4fa4.zip |
Aperture macro expression simplification WIP
Diffstat (limited to 'gerbonara/aperture_macros/primitive.py')
-rw-r--r-- | gerbonara/aperture_macros/primitive.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gerbonara/aperture_macros/primitive.py b/gerbonara/aperture_macros/primitive.py index f575b0c..1372dfa 100644 --- a/gerbonara/aperture_macros/primitive.py +++ b/gerbonara/aperture_macros/primitive.py @@ -48,7 +48,7 @@ class Primitive: def to_gerber(self, unit=None): return f'{self.code},' + ','.join( - getattr(self, field.name).to_gerber(unit) for field in fields(self) if field.name != 'unit') + getattr(self, field.name).optimized().to_gerber(unit) for field in fields(self) if field.name != 'unit') def __str__(self): attrs = ','.join(str(getattr(self, name)).strip('<>') for name in type(self).__annotations__) @@ -253,6 +253,9 @@ class Outline(Primitive): object.__setattr__(self, 'exposure', expr(self.exposure)) if self.length.calculate() != len(self.coords)//2-1: + print(self.length, self.length.calculate(), len(self.coords)) + import pprint + pprint.pprint(self.coords) raise ValueError('length must exactly equal number of segments, which is the number of points minus one') if self.coords[-2:] != self.coords[:2]: @@ -289,8 +292,8 @@ class Outline(Primitive): rotation = ConstantExpression(0) - coords = ','.join(coord.to_gerber(unit) for coord in coords) - return f'{self.code},{self.exposure.to_gerber()},{len(self.coords)//2-1},{coords},{rotation.to_gerber()}' + coords = ','.join(coord.optimized().to_gerber(unit) for coord in coords) + return f'{self.code},{self.exposure.optimized().to_gerber()},{len(self.coords)//2-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: |