From 27a992f1c8c0a37245168e23db160412494d0e18 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 1 Jan 2022 17:47:50 +0100 Subject: Add dilation code --- gerbonara/gerber/aperture_macros/parse.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gerbonara/gerber/aperture_macros/parse.py') diff --git a/gerbonara/gerber/aperture_macros/parse.py b/gerbonara/gerber/aperture_macros/parse.py index 86f2882..00227c6 100644 --- a/gerbonara/gerber/aperture_macros/parse.py +++ b/gerbonara/gerber/aperture_macros/parse.py @@ -98,6 +98,20 @@ class ApertureMacro: def __hash__(self): return hash(self.to_gerber()) + def dilated(self, offset, unit='mm'): + dup = copy.deepcopy(self) + new_primitives = [] + for primitive in dup.primitives: + try: + if primitive.exposure.calculate(): + primitive.dilate(offset, unit) + new_primitives.append(primitive) + except IndexError: + warnings.warn('Cannot dilate aperture macro primitive with exposure value computed from macro variable.') + pass + dup.primitives = new_primitives + return dup + def to_gerber(self, unit=None): comments = [ c.to_gerber() for c in self.comments ] variable_defs = [ f'${var.to_gerber(unit)}={expr}' for var, expr in self.variables.items() ] -- cgit