From 299ccb2ecacdcf9045110e1c4217752f4bb3ae25 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 22 Aug 2019 22:56:02 +0300 Subject: [PATCH] - fixed Tool Cutout so when the target Gerber is a single Polygon then the created manual geometry will follow the shape if shape is freeform --- README.md | 1 + flatcamTools/ToolCutOut.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 36a2084b..4911e47f 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ CAD program, and create G-Code for Isolation routing. - added possibility to turn application portable from the Edit -> Preferences -> General -> App. Preferences -> Portable checkbox - moved the canvas setup into it's own function and called it in the init() function - fixed the Buffer Tool in Geometry Editor; made the Buffer entry field a QDoubleSpinner and set the lower limit to zero. +- fixed Tool Cutout so when the target Gerber is a single Polygon then the created manual geometry will follow the shape if shape is freeform 21.08.2019 diff --git a/flatcamTools/ToolCutOut.py b/flatcamTools/ToolCutOut.py index 6388705a..82c544db 100644 --- a/flatcamTools/ToolCutOut.py +++ b/flatcamTools/ToolCutOut.py @@ -864,9 +864,17 @@ class CutOut(FlatCAMTool): geo = geo_union.convex_hull geo_obj.solid_geometry = geo.buffer(margin + abs(dia / 2)) elif kind == 'single': - x0, y0, x1, y1 = geo_union.bounds - geo = box(x0, y0, x1, y1) - geo_obj.solid_geometry = geo.buffer(margin + abs(dia / 2)) + if isinstance(geo_union, Polygon) or \ + (isinstance(geo_union, list) and len(geo_union) == 1) or \ + (isinstance(geo_union, MultiPolygon) and len(geo_union) == 1): + geo_obj.solid_geometry = geo_union.buffer(margin + abs(dia / 2)).exterior + elif isinstance(geo_union, MultiPolygon): + x0, y0, x1, y1 = geo_union.bounds + geo = box(x0, y0, x1, y1) + geo_obj.solid_geometry = geo.buffer(margin + abs(dia / 2)) + else: + self.app.inform.emit(_("[ERROR_NOTCL] Geometry not supported for cutout: %s") % type(geo_union)) + return 'fail' else: geo = geo_union geo = geo.buffer(margin + abs(dia / 2))