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

- work in Gerber Export: finished the body export but have some errors with clear geometry (LPC)

Marius Stanciu 6 лет назад
Родитель
Сommit
5b663c5f20
3 измененных файлов с 36 добавлено и 31 удалено
  1. 27 26
      FlatCAMObj.py
  2. 1 0
      README.md
  3. 8 5
      camlib.py

+ 27 - 26
FlatCAMObj.py

@@ -1330,33 +1330,34 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
                         gerber_code += 'D02*\n'
                         gerber_code += 'G37*\n'
 
-                if 'clear_geometry' in self.apertures['0']:
-                    gerber_code += '%LPC*%\n'
-                    for geo in self.apertures['0']['clear_geometry']:
-                        gerber_code += 'G36*\n'
-                        geo_coords = list(geo.exterior.coords)
+                        clear_list = list(geo.interiors)
+                        if clear_list:
+                            gerber_code += '%LPC*%\n'
+                            for clear_geo in clear_list:
+                                gerber_code += 'G36*\n'
+                                geo_coords = list(clear_geo.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)
-                        for coord in geo_coords[1:]:
-                            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)
-                        gerber_code += 'D02*\n'
-                        gerber_code += 'G37*\n'
-                    gerber_code += '%LPD*%\n'
+                                # 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)
+                                for coord in geo_coords[1:]:
+                                    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)
+                                gerber_code += 'D02*\n'
+                                gerber_code += 'G37*\n'
+                            gerber_code += '%LPD*%\n'
 
             for apid in self.apertures:
                 if apid == '0':

+ 1 - 0
README.md

@@ -15,6 +15,7 @@ CAD program, and create G-Code for Isolation routing.
 - work in Gerber Export: finished the header export
 - fixed the Gerber Object and Gerber Editor Apertures Table to not show extra rows when there are aperture macros in the object
 - work in Gerber Export: finished the body export but have some errors with clear geometry (LPC)
+- Gerber Export - finished
 
 6.05.2019
 

+ 8 - 5
camlib.py

@@ -3219,7 +3219,7 @@ class Gerber (Geometry):
                 if 'clear_geometry' in self.apertures[apid]:
                     for pol in self.apertures[apid]['clear_geometry']:
                         global_clear_geo.append(pol)
-                # self.apertures[apid].pop('clear_geometry', None)
+                self.apertures[apid].pop('clear_geometry', None)
             log.warning("Found %d clear polygons." % len(global_clear_geo))
 
             temp_geo = []
@@ -3497,11 +3497,14 @@ class Gerber (Geometry):
         # we need to scale the geometry stored in the Gerber apertures, too
         try:
             for apid in self.apertures:
-                self.apertures[apid]['solid_geometry'] = scale_geom(self.apertures[apid]['solid_geometry'])
-                self.apertures[apid]['clear_geometry'] = scale_geom(self.apertures[apid]['clear_geometry'])
-
+                if 'solid_geometry' in self.apertures[apid]:
+                    self.apertures[apid]['solid_geometry'] = scale_geom(self.apertures[apid]['solid_geometry'])
+                if 'follow_geometry' in self.apertures[apid]:
+                    self.apertures[apid]['follow_geometry'] = scale_geom(self.apertures[apid]['follow_geometry'])
+                if 'clear_geometry' in self.apertures[apid]:
+                    self.apertures[apid]['clear_geometry'] = scale_geom(self.apertures[apid]['clear_geometry'])
         except Exception as e:
-            log.debug('FlatCAMGeometry.scale() --> %s' % str(e))
+            log.debug('camlib.Gerber.scale() Exception --> %s' % str(e))
 
         self.app.inform.emit(_("[success] Gerber Scale done."))