From 2c229d8677e40f069e81060a026c9f1b8c418aae Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 19 Oct 2022 02:35:19 +0300 Subject: [PATCH] - added a hack so the Gerber files from Allegro 17.2 (which do not follow the Gerber specifications) can be loaded --- CHANGELOG.md | 4 ++++ camlib.py | 26 +++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39621195..e2898e16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM Evo beta ================================================= +19.10.2022 + +- added a hack so the Gerber files from Allegro 17.2 (which do not follow the Gerber specifications) can be loaded + 2.10.2022 - really small UI change in 2-Sided Plugin diff --git a/camlib.py b/camlib.py index af06ab01..e946a4c4 100644 --- a/camlib.py +++ b/camlib.py @@ -335,13 +335,29 @@ class ApertureMacro: """ pol = mods[0] - n = mods[1] - points = [(0, 0)] * (n + 1) - for i in range(n + 1): - points[i] = mods[2 * i + 2:2 * i + 4] + # n = mods[1] + # points = [(0, 0)] * (n + 1) + # + # for i in range(n + 1): + # points[i] = mods[2 * i + 2:2 * i + 4] + # + # angle = mods[2 * n + 4] - angle = mods[2 * n + 4] + # --------------------------- + # added to fix the issue on Allegro 17.2 Gerber's which have fewer points than declared + # discard first 2 values (exposure and vertex points number) and last one (rotation) + vertex_list = mods[2:-1] + # rotation is the last value + angle = mods[-1] + n = int(len(vertex_list) / 2) + points = [(0, 0)] * n + + for i in range(n): + start = 2 * i + stop = (2 * i) + 2 + points[i] = vertex_list[start:stop] + # --------------------------- poly = Polygon(points) poly_rotated = affinity.rotate(poly, angle, origin=(0, 0))