From dab46ef3aef9acf442e96046ca8f3bbf072891c9 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 19 Feb 2020 22:09:32 +0200 Subject: [PATCH] - in FlatCAMObj.export_gerber() method took into account the possibility of polygons of type 'clear' (the ones found in the Gerber files under the LPC command) --- FlatCAMObj.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 58 insertions(+) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 8073b9da..6d8f640a 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -2233,6 +2233,63 @@ class FlatCAMGerber(FlatCAMObj, Gerber): x_formatted, y_formatted = lz_format(geo.x, geo.y, factor) gerber_code += "X{xform}Y{yform}D03*\n".format(xform=x_formatted, yform=y_formatted) + elif isinstance(geo, Polygon): + geo_coords = list(geo.exterior.coords) + # first command is a move with pen-up D02 at the beginning of the geo + if g_zeros == 'T': + x_formatted, y_formatted = tz_format( + geo_coords[0][0], geo_coords[0][1], factor) + gerber_code += "X{xform}Y{yform}D02*\n".format(xform=x_formatted, + yform=y_formatted) + else: + x_formatted, y_formatted = lz_format( + geo_coords[0][0], geo_coords[0][1], factor) + gerber_code += "X{xform}Y{yform}D02*\n".format(xform=x_formatted, + yform=y_formatted) + + prev_coord = geo_coords[0] + for coord in geo_coords[1:]: + if coord != prev_coord: + if g_zeros == 'T': + x_formatted, y_formatted = tz_format(coord[0], coord[1], factor) + gerber_code += "X{xform}Y{yform}D01*\n".format(xform=x_formatted, + yform=y_formatted) + else: + x_formatted, y_formatted = lz_format(coord[0], coord[1], factor) + gerber_code += "X{xform}Y{yform}D01*\n".format(xform=x_formatted, + yform=y_formatted) + + prev_coord = coord + + for geo_int in geo.interiors: + geo_coords = list(geo_int.coords) + # first command is a move with pen-up D02 at the beginning of the geo + if g_zeros == 'T': + x_formatted, y_formatted = tz_format( + geo_coords[0][0], geo_coords[0][1], factor) + gerber_code += "X{xform}Y{yform}D02*\n".format(xform=x_formatted, + yform=y_formatted) + else: + x_formatted, y_formatted = lz_format( + geo_coords[0][0], geo_coords[0][1], factor) + gerber_code += "X{xform}Y{yform}D02*\n".format(xform=x_formatted, + yform=y_formatted) + + prev_coord = geo_coords[0] + for coord in geo_coords[1:]: + if coord != prev_coord: + if g_zeros == 'T': + x_formatted, y_formatted = tz_format(coord[0], coord[1], factor) + gerber_code += "X{xform}Y{yform}D01*\n".format( + xform=x_formatted, + yform=y_formatted) + else: + x_formatted, y_formatted = lz_format(coord[0], coord[1], factor) + gerber_code += "X{xform}Y{yform}D01*\n".format( + xform=x_formatted, + yform=y_formatted) + + prev_coord = coord else: geo_coords = list(geo.coords) # first command is a move with pen-up D02 at the beginning of the geo diff --git a/README.md b/README.md index c4358a4f..128613cd 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing. - fixed some issues in the Geometry Editor; the jump sigmal disconnect was failing for repeated Editor tool operation - fixed an issue in Gerber Editor where the multiprocessing pool was reported as closed and an ValueError exception was raised in a certain scneraio - on Set Origin, Move to Origin and Move actions for Gerber and Excellon objects the source file will be also updated (the export functions will export an updated object) +- in FlatCAMObj.export_gerber() method took into account the possibility of polygons of type 'clear' (the ones found in the Gerber files under the LPC command) 17.02.2020