diff options
author | jaseg <git@jaseg.de> | 2022-01-01 17:47:50 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-01-01 17:47:50 +0100 |
commit | 27a992f1c8c0a37245168e23db160412494d0e18 (patch) | |
tree | ab7bdef14e9e2715277e1cff68adf109ca3ca963 /gerbonara/gerber/aperture_macros/parse.py | |
parent | f46b8897818439269d3fbce32773ec1ed12ad657 (diff) | |
download | gerbonara-27a992f1c8c0a37245168e23db160412494d0e18.tar.gz gerbonara-27a992f1c8c0a37245168e23db160412494d0e18.tar.bz2 gerbonara-27a992f1c8c0a37245168e23db160412494d0e18.zip |
Add dilation code
Diffstat (limited to 'gerbonara/gerber/aperture_macros/parse.py')
-rw-r--r-- | gerbonara/gerber/aperture_macros/parse.py | 14 |
1 files changed, 14 insertions, 0 deletions
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() ] |