diff options
author | jaseg <git@jaseg.de> | 2023-04-04 19:06:04 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-04-04 19:06:04 +0200 |
commit | 82fcc2445623ff0323692f8253cb81302dc9253a (patch) | |
tree | 85f575cc130df2e0235852c492fea79d43bb9904 /gerbonara/rs274x.py | |
parent | a8772612568a81d204705cb8b4a43bf5868cee40 (diff) | |
download | gerbonara-82fcc2445623ff0323692f8253cb81302dc9253a.tar.gz gerbonara-82fcc2445623ff0323692f8253cb81302dc9253a.tar.bz2 gerbonara-82fcc2445623ff0323692f8253cb81302dc9253a.zip |
Various convenience improvements, and make board name guessing really smart
Diffstat (limited to 'gerbonara/rs274x.py')
-rw-r--r-- | gerbonara/rs274x.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gerbonara/rs274x.py b/gerbonara/rs274x.py index 6620f10..271880b 100644 --- a/gerbonara/rs274x.py +++ b/gerbonara/rs274x.py @@ -73,6 +73,9 @@ class GerberFile(CamFile): self.apertures = [] # FIXME get rid of this? apertures are already in the objects. self.file_attrs = file_attrs or {} + def sync_apertures(self): + self.apertures = list({id(obj.aperture): obj.aperture for obj in self.objects if hasattr(obj, 'aperture')}.values()) + def to_excellon(self, plated=None, errors='raise'): """ Convert this excellon file into a :py:class:`~.excellon.ExcellonFile`. This will convert interpolated lines into slots, and circular aperture flashes into holes. Other features such as ``G36`` polygons or flashes with @@ -227,6 +230,8 @@ class GerberFile(CamFile): def _generate_statements(self, settings, drop_comments=True): """ Export this file as Gerber code, yields one str per line. """ + self.sync_apertures() + yield 'G04 Gerber file generated by Gerbonara*' for name, value in self.file_attrs.items(): attrdef = ','.join([name, *map(str, value)]) |