From 789dcc5da52e5976669f74433e34f56489cfeb5e Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 22 Mar 2019 20:28:43 +0200 Subject: [PATCH] - fixed the Gerber.merge() function. When some of the Gerber files have apertures with same id, create a new aperture id for the object that is fused because each aperture id may hold different geometries. --- FlatCAMObj.py | 13 +++++++++---- README.md | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index cd7be03f..51e53584 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -423,10 +423,15 @@ class FlatCAMGerber(FlatCAMObj, Gerber): if ap not in grb_final.apertures: grb_final.apertures[ap] = grb.apertures[ap] else: - if 'solid_geometry' not in grb_final.apertures[ap]: - grb_final.apertures[ap]['solid_geometry'] = [] - for geo in grb.apertures[ap]['solid_geometry']: - grb_final.apertures[ap]['solid_geometry'].append(geo) + # create a list of integers out of the grb.apertures keys and find the max of that value + # then, the aperture duplicate is assigned an id value incremented with 1, + # and finally made string because the apertures dict keys are strings + max_ap = str(max([int(k) for k in grb_final.apertures.keys()]) + 1) + grb_final.apertures[max_ap] = {} + grb_final.apertures[max_ap]['solid_geometry'] = [] + + for k, v in grb.apertures[ap].items(): + grb_final.apertures[max_ap][k] = v grb_final.solid_geometry = MultiPolygon(grb_final.solid_geometry) grb_final.follow_geometry = MultiPolygon(grb_final.follow_geometry) diff --git a/README.md b/README.md index ee9026f6..5a591b8e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ CAD program, and create G-Code for Isolation routing. 22.03.2019 - fixed an error that created a situation that when saving a project with some of the CNCJob objects disabled, on project reload the CNCJob objects are no longer loaded +- fixed the Gerber.merge() function. When some of the Gerber files have apertures with same id, create a new aperture id for the object that is fused because each aperture id may hold different geometries. + 20.03.2019