Sfoglia il codice sorgente

- improved the FlatCAMGerber.isolate() function to work for geometry in the form of list and also in case that the elements of the list are LinearRings (like when doing the Exterior Isolation)
- in NCC Tool made sure that at each run the old objects are deleted

Marius Stanciu 6 anni fa
parent
commit
cac92f75f2
3 ha cambiato i file con 41 aggiunte e 6 eliminazioni
  1. 31 6
      FlatCAMObj.py
  2. 2 0
      README.md
  3. 8 0
      flatcamTools/ToolNonCopperClear.py

+ 31 - 6
FlatCAMObj.py

@@ -879,21 +879,46 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
 
 
             if invert:
             if invert:
                 try:
                 try:
-                    if type(geom) is MultiPolygon:
+                    try:
                         pl = []
                         pl = []
                         for p in geom:
                         for p in geom:
                             if p is not None:
                             if p is not None:
-                                pl.append(Polygon(p.exterior.coords[::-1], p.interiors))
+                                if isinstance(p, Polygon):
+                                    pl.append(Polygon(p.exterior.coords[::-1], p.interiors))
+                                elif isinstance(p, LinearRing):
+                                    pl.append(Polygon(p.coords[::-1]))
                         geom = MultiPolygon(pl)
                         geom = MultiPolygon(pl)
-                    elif type(geom) is Polygon and geom is not None:
-                        geom = Polygon(geom.exterior.coords[::-1], geom.interiors)
-                    else:
-                        log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> Unexpected Geometry")
+                    except TypeError:
+                        if isinstance(geom, Polygon) and geom is not None:
+                            geom = Polygon(geom.exterior.coords[::-1], geom.interiors)
+                        elif isinstance(geom, LinearRing) and geom is not None:
+                            geom = Polygon(geom.coords[::-1])
+                        else:
+                            log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> Unexpected Geometry %s" %
+                                      type(geom))
                 except Exception as e:
                 except Exception as e:
                     log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> %s" % str(e))
                     log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> %s" % str(e))
                     return 'fail'
                     return 'fail'
             return geom
             return geom
 
 
+            # if invert:
+            #     try:
+            #         if type(geom) is MultiPolygon:
+            #             pl = []
+            #             for p in geom:
+            #                 if p is not None:
+            #                     pl.append(Polygon(p.exterior.coords[::-1], p.interiors))
+            #             geom = MultiPolygon(pl)
+            #         elif type(geom) is Polygon and geom is not None:
+            #             geom = Polygon(geom.exterior.coords[::-1], geom.interiors)
+            #         else:
+            #             log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> Unexpected Geometry %s" %
+            #                       type(geom))
+            #     except Exception as e:
+            #         log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> %s" % str(e))
+            #         return 'fail'
+            # return geom
+
         # if float(self.options["isotooldia"]) < 0:
         # if float(self.options["isotooldia"]) < 0:
         #     self.options["isotooldia"] = -self.options["isotooldia"]
         #     self.options["isotooldia"] = -self.options["isotooldia"]
 
 

+ 2 - 0
README.md

@@ -14,6 +14,8 @@ CAD program, and create G-Code for Isolation routing.
 - done regression to solve the bug with multiple passes cutting from the copper features (I should remember not to make mods here)
 - done regression to solve the bug with multiple passes cutting from the copper features (I should remember not to make mods here)
 - if 'combine' is checked in Gerber isolation but there is only one pass, the resulting geometry will still be single geo
 - if 'combine' is checked in Gerber isolation but there is only one pass, the resulting geometry will still be single geo
 - the 'passes' entry was changed to a IntSpinner so it will allow passes to be entered only in range (1, 999) - it will not allow entry of 0 which may create some issues
 - the 'passes' entry was changed to a IntSpinner so it will allow passes to be entered only in range (1, 999) - it will not allow entry of 0 which may create some issues
+- improved the FlatCAMGerber.isolate() function to work for geometry in the form of list and also in case that the elements of the list are LinearRings (like when doing the Exterior Isolation)
+- in NCC Tool made sure that at each run the old objects are deleted
 
 
 11.08.2019
 11.08.2019
 
 

+ 8 - 0
flatcamTools/ToolNonCopperClear.py

@@ -332,6 +332,12 @@ class NonCopperClear(FlatCAMTool, Gerber):
         FlatCAMTool.run(self)
         FlatCAMTool.run(self)
         self.set_tool_ui()
         self.set_tool_ui()
 
 
+        # reset those objects on a new run
+        self.ncc_obj = None
+        self.bound_obj = None
+        self.obj_name = ''
+        self.bound_obj_name = ''
+
         self.build_ui()
         self.build_ui()
         self.app.ui.notebook.setTabText(2, _("NCC Tool"))
         self.app.ui.notebook.setTabText(2, _("NCC Tool"))
 
 
@@ -692,6 +698,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
         self.build_ui()
         self.build_ui()
 
 
     def on_ncc(self):
     def on_ncc(self):
+        self.bound_obj = None
+        self.ncc_obj = None
 
 
         try:
         try:
             over = float(self.ncc_overlap_entry.get_value())
             over = float(self.ncc_overlap_entry.get_value())