diff options
author | jaseg <git@jaseg.de> | 2023-03-24 00:12:50 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-03-24 00:12:50 +0100 |
commit | 0037195543b8bd30d003947d0151402f00e0a8fa (patch) | |
tree | e26da9b78e1ebc187209927f279412d1cf539fc7 /gerbonara/rs274x.py | |
parent | 2a3deb6c00483b324a6ab22a85729807549f7864 (diff) | |
download | gerbonara-0037195543b8bd30d003947d0151402f00e0a8fa.tar.gz gerbonara-0037195543b8bd30d003947d0151402f00e0a8fa.tar.bz2 gerbonara-0037195543b8bd30d003947d0151402f00e0a8fa.zip |
Dedup both Excellon and Gerber tools during write
Diffstat (limited to 'gerbonara/rs274x.py')
-rw-r--r-- | gerbonara/rs274x.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gerbonara/rs274x.py b/gerbonara/rs274x.py index 0c50991..5956b53 100644 --- a/gerbonara/rs274x.py +++ b/gerbonara/rs274x.py @@ -247,7 +247,9 @@ class GerberFile(CamFile): processed_macros = set() aperture_map = {} - for number, aperture in enumerate(self.apertures, start=10): + defined_apertures = {} + number = 10 + for aperture in self.apertures: if isinstance(aperture, apertures.ApertureMacroInstance): macro_def = am_stmt(aperture._rotated().macro) @@ -255,9 +257,15 @@ class GerberFile(CamFile): processed_macros.add(macro_def) yield macro_def - yield f'%ADD{number}{aperture.to_gerber(settings)}*%' + ap_def = aperture.to_gerber(settings) + if ap_def in defined_apertures: + aperture_map[id(aperture)] = defined_apertures[ap_def] - aperture_map[id(aperture)] = number + else: + yield f'%ADD{number}{ap_def}*%' + defined_apertures[ap_def] = number + aperture_map[id(aperture)] = number + number += 1 def warn(msg, kls=SyntaxWarning): warnings.warn(msg, kls) |