From 82fcc2445623ff0323692f8253cb81302dc9253a Mon Sep 17 00:00:00 2001 From: jaseg Date: Tue, 4 Apr 2023 19:06:04 +0200 Subject: Various convenience improvements, and make board name guessing really smart --- gerbonara/rs274x.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gerbonara/rs274x.py') 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)]) -- cgit