diff options
Diffstat (limited to 'gerbonara/aperture_macros')
-rw-r--r-- | gerbonara/aperture_macros/expression.py | 2 | ||||
-rw-r--r-- | gerbonara/aperture_macros/parse.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/gerbonara/aperture_macros/expression.py b/gerbonara/aperture_macros/expression.py index 44abf51..af43d9a 100644 --- a/gerbonara/aperture_macros/expression.py +++ b/gerbonara/aperture_macros/expression.py @@ -167,7 +167,7 @@ class VariableExpression(Expression): def optimized(self, variable_binding={}): if self.number in variable_binding: - return ConstantExpression(variable_binding[self.number]) + return ConstantExpression(expr(variable_binding[self.number]).optimized(variable_binding)) return self def __eq__(self, other): diff --git a/gerbonara/aperture_macros/parse.py b/gerbonara/aperture_macros/parse.py index b8970ff..a4c2956 100644 --- a/gerbonara/aperture_macros/parse.py +++ b/gerbonara/aperture_macros/parse.py @@ -111,12 +111,12 @@ class ApertureMacro: def to_gerber(self, unit=None): comments = [ str(c) for c in self.comments ] - variable_defs = [ f'${var.to_gerber(unit)}={expr}' for var, expr in enumerate(self.variables, start=1) ] + variable_defs = [ f'${var}={expr}' for var, expr in enumerate(self.variables, start=1) if expr is not None ] primitive_defs = [ prim.to_gerber(unit) for prim in self.primitives ] return '*\n'.join(comments + variable_defs + primitive_defs) def to_graphic_primitives(self, offset, rotation, parameters : [float], unit=None, polarity_dark=True): - variables = {i: v for i, v in enumerate(self.variables, start=1)} + variables = {i: v for i, v in enumerate(self.variables, start=1) if v is not None} for number, value in enumerate(parameters, start=1): if number in variables: raise SyntaxError(f'Re-definition of aperture macro variable {number} through parameter {value}') |