From fee24505ae4ed9863f428f13e72930ff40c509b7 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 5 May 2019 00:15:21 +0300 Subject: [PATCH] - fixed bug in parsing Gerber regions (a point was added unnecessary) --- README.md | 1 + camlib.py | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8c2795dc..3c45a0bd 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing. 4.05.2019 - fixed bug in camlib.parse_lines() in the clear_geometry processing section for self.apertures +- fixed bug in parsing Gerber regions (a point was added unnecessary) 01.05.2019 diff --git a/camlib.py b/camlib.py index 60c963f0..805b05f3 100644 --- a/camlib.py +++ b/camlib.py @@ -2446,6 +2446,14 @@ class Gerber (Geometry): self.apertures[current_aperture]['clear_geometry'] = [] self.apertures[current_aperture]['clear_geometry'].append(flash) else: + try: + self.apertures[current_aperture]['follow_geometry'].append(Point( + current_x, current_y)) + except KeyError: + self.apertures[current_aperture]['follow_geometry'] = [] + self.apertures[current_aperture]['follow_geometry'].append(Point( + current_x, current_y)) + try: self.apertures[current_aperture]['solid_geometry'].append(flash) except KeyError: @@ -2692,11 +2700,10 @@ class Gerber (Geometry): # Pen down: add segment if current_operation_code == 1: # if linear_x or linear_y are None, ignore those - if linear_x is not None and linear_y is not None: + if current_x is not None and current_y is not None: # only add the point if it's a new one otherwise skip it (harder to process) - if path[-1] != [linear_x, linear_y]: - path.append([linear_x, linear_y]) - + if path[-1] != [current_x, current_y]: + path.append([current_x, current_y]) if making_region is False: # if the aperture is rectangle then add a rectangular shape having as parameters the # coordinates of the start and end point and also the width and height @@ -2791,9 +2798,9 @@ class Gerber (Geometry): self.apertures['0']['size'] = 0.0 self.apertures['0']['solid_geometry'] = [] last_path_aperture = '0' - elem = [linear_x, linear_y] - if elem != path[-1]: - path.append([linear_x, linear_y]) + # elem = [current_x, current_y] + # if elem != path[-1]: + # path.append([current_x, current_y]) try: geo = Polygon(path) @@ -3200,7 +3207,7 @@ class Gerber (Geometry): conversion_factor = 25.4 if file_units == 'IN' else (1/25.4) if file_units != app_units else 1 - # --- the following section is usefull for Gerber editor only --- # + # --- the following section is useful for Gerber editor only --- # # list of clear geos that are to be applied to the entire file global_clear_geo = [] @@ -3246,7 +3253,7 @@ class Gerber (Geometry): if len(poly_buffer) == 0: log.error("Object is not Gerber file or empty. Aborting Object creation.") - return + return 'fail' if self.use_buffer_for_union: log.debug("Union by buffer...")