瀏覽代碼

- updated the Gerber parser such that it will parse correctly Gerber files that have only one solid polygon inside with multiple clear polygons (like those generated by the Invert Tool)

Marius Stanciu 5 年之前
父節點
當前提交
2623bb0a65
共有 4 個文件被更改,包括 9 次插入3 次删除
  1. 1 1
      AppParsers/ParseGerber.py
  2. 5 0
      AppTools/ToolInvertGerber.py
  3. 1 1
      CHANGELOG.md
  4. 2 1
      camlib.py

+ 1 - 1
AppParsers/ParseGerber.py

@@ -1476,7 +1476,7 @@ class Gerber(Geometry):
                 sol_geo_length = 1
 
             try:
-                if buff_length == 0 and sol_geo_length in [0, 1]:
+                if buff_length == 0 and sol_geo_length in [0, 1] and self.solid_geometry.area == 0:
                     log.error("Object is not Gerber file or empty. Aborting Object creation.")
                     return 'fail'
             except TypeError as e:

+ 5 - 0
AppTools/ToolInvertGerber.py

@@ -228,6 +228,11 @@ class ToolInvertGerber(AppTool):
         for poly in grb_obj.solid_geometry:
             new_solid_geometry = new_solid_geometry.difference(poly)
 
+        try:
+            __ = iter(new_solid_geometry)
+        except TypeError:
+            new_solid_geometry = [new_solid_geometry]
+
         new_options = {}
         for opt in grb_obj.options:
             new_options[opt] = deepcopy(grb_obj.options[opt])

+ 1 - 1
CHANGELOG.md

@@ -13,7 +13,7 @@ CHANGELOG for FlatCAM beta
 - added a new GUI element which is a evaluated LineEdit that accepts only float numbers and /,*,+,-,% chars
 - finished the Etch Compensation Tool
 - fixed unreliable work of Gerber Editor and optimized the App.editor2object() method
-
+- updated the Gerber parser such that it will parse correctly Gerber files that have only one solid polygon inside with multiple clear polygons (like those generated by the Invert Tool)
 
 23.05.2020
 

+ 2 - 1
camlib.py

@@ -586,7 +586,8 @@ class Geometry(object):
             return
 
     def is_empty(self):
-        if isinstance(self.solid_geometry, BaseGeometry):
+        if isinstance(self.solid_geometry, BaseGeometry) or isinstance(self.solid_geometry, Polygon) or \
+                isinstance(self.solid_geometry, MultiPolygon):
             return self.solid_geometry.is_empty
 
         if isinstance(self.solid_geometry, list):