Fix last test failures
This commit is contained in:
parent
3b4b72bc59
commit
07d279f89f
3 changed files with 13 additions and 12 deletions
|
|
@ -204,27 +204,27 @@ class Outline(Primitive):
|
|||
if len(args) > 5004:
|
||||
raise ValueError(f'Invalid aperture macro outline primitive, too many points ({len(args)//2-2}).')
|
||||
|
||||
self.exposure = args[0]
|
||||
self.exposure = args.pop(0)
|
||||
|
||||
# length arg must not contain variables (that would not make sense)
|
||||
length_arg = args[1].calculate()
|
||||
length_arg = args.pop(0).calculate()
|
||||
|
||||
if length_arg != len(args)//2 - 2:
|
||||
raise ValueError(f'Invalid aperture macro outline primitive, given size does not match length of coordinate list({len(args)}).')
|
||||
if length_arg != len(args)//2-1:
|
||||
raise ValueError(f'Invalid aperture macro outline primitive, given size {length_arg} does not match length of coordinate list({len(args)//2-1}).')
|
||||
|
||||
if len(args) % 1 != 1:
|
||||
if len(args) % 2 == 1:
|
||||
self.rotation = args.pop()
|
||||
else:
|
||||
self.rotation = ConstantExpression(0.0)
|
||||
|
||||
if args[2] != args[-2] or args[3] != args[-1]:
|
||||
if args[0] != args[-2] or args[1] != args[-1]:
|
||||
raise ValueError(f'Invalid aperture macro outline primitive, polygon is not closed {args[2:4], args[-3:-1]}')
|
||||
|
||||
self.coords = [(UnitExpression(x, unit), UnitExpression(y, unit)) for x, y in zip(args[1::2], args[2::2])]
|
||||
self.coords = [(UnitExpression(x, unit), UnitExpression(y, unit)) for x, y in zip(args[0::2], args[1::2])]
|
||||
|
||||
def to_gerber(self, unit=None):
|
||||
coords = ','.join(coord.to_gerber(unit) for xy in self.coords for coord in xy)
|
||||
return f'{self.code},{self.exposure.to_gerber()},{len(self.coords)//2-1},{coords},{self.rotation.to_gerber()}'
|
||||
return f'{self.code},{self.exposure.to_gerber()},{len(self.coords)-1},{coords},{self.rotation.to_gerber()}'
|
||||
|
||||
def to_graphic_primitives(self, offset, rotation, variable_binding={}, unit=None):
|
||||
with self.Calculator(self, variable_binding, unit) as calc:
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class Aperture:
|
|||
#print(f'aperture to gerber {self.unit=} {settings=} {unit=}')
|
||||
actual_inst = self._rotated()
|
||||
params = 'X'.join(f'{float(par):.4}' for par in actual_inst.params(unit) if par is not None)
|
||||
return f'{actual_inst.gerber_shape_code},{params}'
|
||||
return ','.join((actual_inst.gerber_shape_code, params))
|
||||
|
||||
def __eq__(self, other):
|
||||
# We need to choose some unit here.
|
||||
|
|
|
|||
|
|
@ -579,7 +579,8 @@ class GerberParser:
|
|||
elif match['interpolation'] == 'G75':
|
||||
self.multi_quadrant_mode = False
|
||||
|
||||
if match['interpolation'] in ('G74', 'G75') and (match['x'] or match['y'] or match['i'] or match['j']):
|
||||
has_coord = (match['x'] or match['y'] or match['i'] or match['j'])
|
||||
if match['interpolation'] in ('G74', 'G75') and has_coord:
|
||||
raise SyntaxError('G74/G75 combined with coord')
|
||||
|
||||
x = self.file_settings.parse_gerber_value(match['x'])
|
||||
|
|
@ -587,12 +588,12 @@ class GerberParser:
|
|||
i = self.file_settings.parse_gerber_value(match['i'])
|
||||
j = self.file_settings.parse_gerber_value(match['j'])
|
||||
|
||||
if not (op := match['operation']):
|
||||
if not (op := match['operation']) and has_coord:
|
||||
if self.last_operation == 'D01':
|
||||
warnings.warn('Coordinate statement without explicit operation code. This is forbidden by spec.', SyntaxWarning)
|
||||
op = 'D01'
|
||||
|
||||
elif match['x'] or match['y'] or match['i'] or match['j']:
|
||||
else:
|
||||
raise SyntaxError('Ambiguous coordinate statement. Coordinate statement does not have an operation '\
|
||||
'mode and the last operation statement was not D01.')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue