Просмотр исходного кода

- 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 лет назад
Родитель
Сommit
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
                 sol_geo_length = 1
 
 
             try:
             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.")
                     log.error("Object is not Gerber file or empty. Aborting Object creation.")
                     return 'fail'
                     return 'fail'
             except TypeError as e:
             except TypeError as e:

+ 5 - 0
AppTools/ToolInvertGerber.py

@@ -228,6 +228,11 @@ class ToolInvertGerber(AppTool):
         for poly in grb_obj.solid_geometry:
         for poly in grb_obj.solid_geometry:
             new_solid_geometry = new_solid_geometry.difference(poly)
             new_solid_geometry = new_solid_geometry.difference(poly)
 
 
+        try:
+            __ = iter(new_solid_geometry)
+        except TypeError:
+            new_solid_geometry = [new_solid_geometry]
+
         new_options = {}
         new_options = {}
         for opt in grb_obj.options:
         for opt in grb_obj.options:
             new_options[opt] = deepcopy(grb_obj.options[opt])
             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
 - added a new GUI element which is a evaluated LineEdit that accepts only float numbers and /,*,+,-,% chars
 - finished the Etch Compensation Tool
 - finished the Etch Compensation Tool
 - fixed unreliable work of Gerber Editor and optimized the App.editor2object() method
 - 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
 23.05.2020
 
 

+ 2 - 1
camlib.py

@@ -586,7 +586,8 @@ class Geometry(object):
             return
             return
 
 
     def is_empty(self):
     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
             return self.solid_geometry.is_empty
 
 
         if isinstance(self.solid_geometry, list):
         if isinstance(self.solid_geometry, list):