Procházet zdrojové kódy

- 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

Marius Stanciu před 6 roky
rodič
revize
299ccb2eca
2 změnil soubory, kde provedl 12 přidání a 3 odebrání
  1. 1 0
      README.md
  2. 11 3
      flatcamTools/ToolCutOut.py

+ 1 - 0
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
 

+ 11 - 3
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))