Explorar o código

- optimized the FlatCAMGerber.clear_plot_apertures() method

Marius Stanciu %!s(int64=6) %!d(string=hai) anos
pai
achega
c00f30ef65
Modificáronse 2 ficheiros con 16 adicións e 8 borrados
  1. 15 8
      FlatCAMObj.py
  2. 1 0
      README.md

+ 15 - 8
FlatCAMObj.py

@@ -1809,18 +1809,25 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
         :param aperture: string; aperture for which to clear the mark shapes
         :return:
         """
-        try:
+
+        if self.mark_shapes:
             if aperture == 'all':
                 for apid in list(self.apertures.keys()):
+                    try:
+                        if self.app.is_legacy is True:
+                            self.mark_shapes[apid].clear(update=False)
+                        else:
+                            self.mark_shapes[apid].clear(update=True)
+                    except Exception as e:
+                        log.debug("FlatCAMGerber.clear_plot_apertures() 'all' --> %s" % str(e))
+            else:
+                try:
                     if self.app.is_legacy is True:
-                        self.mark_shapes[apid].clear(update=False)
+                        self.mark_shapes[aperture].clear(update=False)
                     else:
-                        self.mark_shapes[apid].clear(update=True)
-
-            else:
-                self.mark_shapes[aperture].clear(update=True)
-        except Exception as e:
-            log.debug("FlatCAMGerber.clear_plot_apertures() --> %s" % str(e))
+                        self.mark_shapes[aperture].clear(update=True)
+                except Exception as e:
+                    log.debug("FlatCAMGerber.clear_plot_apertures() 'aperture' --> %s" % str(e))
 
     def clear_mark_all(self):
         self.ui.mark_all_cb.set_value(False)

+ 1 - 0
README.md

@@ -15,6 +15,7 @@ CAD program, and create G-Code for Isolation routing.
 - changed the Scale Entry in Object UI to FCEntry() GUI element in order to allow expressions to be entered. E.g: 1/25.4
 - some small changes in the Scale button handler in FlatCAMObj() class
 - added option to save objects as PDF files in File -> Save menu
+- optimized the FlatCAMGerber.clear_plot_apertures() method
 
 11.12.2019