summaryrefslogtreecommitdiff
path: root/gerbonara/rs274x.py
diff options
context:
space:
mode:
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)