summaryrefslogtreecommitdiff
path: root/gerbonara/rs274x.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-11-09 20:08:26 +0100
committerjaseg <git@jaseg.de>2023-11-14 21:52:12 +0100
commit11325b213b6ef7cebcdcf0c79f966cda3ce61a89 (patch)
tree90922e50e32b30fb1d7431de9e48d8b5aa5e51ad /gerbonara/rs274x.py
parent74fb384c4c0899f4d6f153da8db748a7a49e78ee (diff)
downloadgerbonara-11325b213b6ef7cebcdcf0c79f966cda3ce61a89.tar.gz
gerbonara-11325b213b6ef7cebcdcf0c79f966cda3ce61a89.tar.bz2
gerbonara-11325b213b6ef7cebcdcf0c79f966cda3ce61a89.zip
Calculate out all aperture macros by default.
There are just too many severely buggy implementations around. Today I ran into problems with both gerbv and with whatever JLC uses. You can still export macros with raw expressions by setting a flag in the export FileSettings.
Diffstat (limited to 'gerbonara/rs274x.py')
-rw-r--r--gerbonara/rs274x.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/gerbonara/rs274x.py b/gerbonara/rs274x.py
index ad78ceb..d5cbb34 100644
--- a/gerbonara/rs274x.py
+++ b/gerbonara/rs274x.py
@@ -284,12 +284,23 @@ class GerberFile(CamFile):
self.dedup_apertures()
am_stmt = lambda macro: f'%AM{macro.name}*\n{macro.to_gerber(settings)}*\n%'
- for macro in self.aperture_macros():
- yield am_stmt(macro)
-
aperture_map = {ap: num for num, ap in enumerate(self.apertures(), start=10)}
- for aperture, number in aperture_map.items():
- yield f'%ADD{number}{aperture.to_gerber(settings)}*%'
+
+ if settings.calculate_out_all_aperture_macros:
+ adds = []
+ for aperture, number in aperture_map.items():
+ if isinstance(aperture, apertures.ApertureMacroInstance):
+ aperture = aperture.calculate_out(settings.unit, macro_name=f'CALCM{number}')
+ yield am_stmt(aperture.macro)
+ adds.append(f'%ADD{number}{aperture.to_gerber(settings)}*%')
+ yield from adds
+
+ else:
+ for macro in self.aperture_macros():
+ yield am_stmt(macro)
+
+ for aperture, number in aperture_map.items():
+ yield f'%ADD{number}{aperture.to_gerber(settings)}*%'
def warn(msg, kls=SyntaxWarning):
warnings.warn(msg, kls)