Sfoglia il codice sorgente

- fixed Panelize Tool to do panelization for multiple passes type of geometry that comes out of the isolation done with multiple passes

Marius Stanciu 6 anni fa
parent
commit
8e80ec156c
4 ha cambiato i file con 55 aggiunte e 9 eliminazioni
  1. 4 0
      FlatCAMApp.py
  2. 41 2
      FlatCAMObj.py
  3. 1 0
      README.md
  4. 9 7
      flatcamTools/ToolPanelize.py

+ 4 - 0
FlatCAMApp.py

@@ -784,6 +784,8 @@ class App(QtCore.QObject):
 
 
             # Geometry Options
             # Geometry Options
             "geometry_cutz": -0.002,
             "geometry_cutz": -0.002,
+            "geometry_vtipdia": 0.1,
+            "geometry_vtipangle": 30,
             "geometry_multidepth": False,
             "geometry_multidepth": False,
             "geometry_depthperpass": 0.002,
             "geometry_depthperpass": 0.002,
             "geometry_travelz": 0.1,
             "geometry_travelz": 0.1,
@@ -1129,6 +1131,8 @@ class App(QtCore.QObject):
             "geometry_segx": 0.0,
             "geometry_segx": 0.0,
             "geometry_segy": 0.0,
             "geometry_segy": 0.0,
             "geometry_cutz": -0.002,
             "geometry_cutz": -0.002,
+            "geometry_vtipdia": 0.1,
+            "geometry_vtipangle": 30,
             "geometry_travelz": 0.1,
             "geometry_travelz": 0.1,
             "geometry_feedrate": 3.0,
             "geometry_feedrate": 3.0,
             "geometry_feedrate_z": 3.0,
             "geometry_feedrate_z": 3.0,

+ 41 - 2
FlatCAMObj.py

@@ -890,7 +890,6 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
             return geom
             return geom
 
 
         if combine:
         if combine:
-
             if self.iso_type == 0:
             if self.iso_type == 0:
                 iso_name = self.options["name"] + "_ext_iso"
                 iso_name = self.options["name"] + "_ext_iso"
             elif self.iso_type == 1:
             elif self.iso_type == 1:
@@ -914,6 +913,46 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
                         geom = generate_envelope(iso_offset, 0, envelope_iso_type=self.iso_type, follow=follow)
                         geom = generate_envelope(iso_offset, 0, envelope_iso_type=self.iso_type, follow=follow)
                     geo_obj.solid_geometry.append(geom)
                     geo_obj.solid_geometry.append(geom)
 
 
+                    # store here the default data for Geometry Data
+                    default_data = {}
+                    default_data.update({
+                        "name": iso_name,
+                        "plot": self.app.defaults['geometry_plot'],
+                        "cutz": self.app.defaults['geometry_cutz'],
+                        "vtipdia": self.app.defaults['geometry_vtipdia'],
+                        "vtipangle": self.app.defaults['geometry_vtipangle'],
+                        "travelz": self.app.defaults['geometry_travelz'],
+                        "feedrate": self.app.defaults['geometry_feedrate'],
+                        "feedrate_z": self.app.defaults['geometry_feedrate_z'],
+                        "feedrate_rapid": self.app.defaults['geometry_feedrate_rapid'],
+                        "dwell": self.app.defaults['geometry_dwell'],
+                        "dwelltime": self.app.defaults['geometry_dwelltime'],
+                        "multidepth": self.app.defaults['geometry_multidepth'],
+                        "ppname_g": self.app.defaults['geometry_ppname_g'],
+                        "depthperpass": self.app.defaults['geometry_depthperpass'],
+                        "extracut": self.app.defaults['geometry_extracut'],
+                        "toolchange": self.app.defaults['geometry_toolchange'],
+                        "toolchangez": self.app.defaults['geometry_toolchangez'],
+                        "endz": self.app.defaults['geometry_endz'],
+                        "spindlespeed": self.app.defaults['geometry_spindlespeed'],
+                        "toolchangexy": self.app.defaults['geometry_toolchangexy'],
+                        "startz": self.app.defaults['geometry_startz']
+                    })
+
+                    geo_obj.tools = dict()
+                    geo_obj.tools['1'] = dict()
+                    geo_obj.tools.update({
+                        '1': {
+                            'tooldia': float(self.options["isotooldia"]),
+                            'offset': 'Path',
+                            'offset_value': 0.0,
+                            'type': _('Rough'),
+                            'tool_type': 'C1',
+                            'data': default_data,
+                            'solid_geometry': geo_obj.solid_geometry
+                        }
+                    })
+
                 # detect if solid_geometry is empty and this require list flattening which is "heavy"
                 # detect if solid_geometry is empty and this require list flattening which is "heavy"
                 # or just looking in the lists (they are one level depth) and if any is not empty
                 # or just looking in the lists (they are one level depth) and if any is not empty
                 # proceed with object creation, if there are empty and the number of them is the length
                 # proceed with object creation, if there are empty and the number of them is the length
@@ -933,7 +972,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
 
 
                 if empty_cnt == len(geo_obj.solid_geometry):
                 if empty_cnt == len(geo_obj.solid_geometry):
                     raise ValidationError("Empty Geometry", None)
                     raise ValidationError("Empty Geometry", None)
-                geo_obj.multigeo = False
+                geo_obj.multigeo = True
 
 
             # TODO: Do something if this is None. Offer changing name?
             # TODO: Do something if this is None. Offer changing name?
             self.app.new_object("geometry", iso_name, iso_init)
             self.app.new_object("geometry", iso_name, iso_init)

+ 1 - 0
README.md

@@ -15,6 +15,7 @@ CAD program, and create G-Code for Isolation routing.
 - after unit conversion from Preferences, the default values are automatically saved by the app
 - after unit conversion from Preferences, the default values are automatically saved by the app
 - in Basic mode, the tool type column is no longer hidden as it may create issues when using an painted geometry
 - in Basic mode, the tool type column is no longer hidden as it may create issues when using an painted geometry
 - some PEP8 clean-up in FlatCAMGui.py
 - some PEP8 clean-up in FlatCAMGui.py
+- fixed Panelize Tool to do panelization for multiple passes type of geometry that comes out of the isolation done with multiple passes
 
 
 20.07.2019
 20.07.2019
 
 

+ 9 - 7
flatcamTools/ToolPanelize.py

@@ -348,7 +348,8 @@ class Panelize(FlatCAMTool):
         # Get source object.
         # Get source object.
         try:
         try:
             obj = self.app.collection.get_by_name(str(name))
             obj = self.app.collection.get_by_name(str(name))
-        except:
+        except Exception as e:
+            log.debug("Panelize.on_panelize() --> %s" % str(e))
             self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % name)
             self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % name)
             return "Could not retrieve object: %s" % name
             return "Could not retrieve object: %s" % name
 
 
@@ -362,7 +363,8 @@ class Panelize(FlatCAMTool):
 
 
         try:
         try:
             box = self.app.collection.get_by_name(boxname)
             box = self.app.collection.get_by_name(boxname)
-        except:
+        except Exception as e:
+            log.debug("Panelize.on_panelize() --> %s" % str(e))
             self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % boxname)
             self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % boxname)
             return "Could not retrieve object: %s" % boxname
             return "Could not retrieve object: %s" % boxname
 
 
@@ -491,8 +493,8 @@ class Panelize(FlatCAMTool):
                         if option is not 'name':
                         if option is not 'name':
                             try:
                             try:
                                 obj_fin.options[option] = panel_obj.options[option]
                                 obj_fin.options[option] = panel_obj.options[option]
-                            except:
-                                log.warning("Failed to copy option.", option)
+                            except KeyError:
+                                log.warning("Failed to copy option. %s" % str(option))
 
 
                     for row in range(rows):
                     for row in range(rows):
                         currentx = 0.0
                         currentx = 0.0
@@ -534,7 +536,7 @@ class Panelize(FlatCAMTool):
                             for local_geom in geom:
                             for local_geom in geom:
                                 res_geo = translate_recursion(local_geom)
                                 res_geo = translate_recursion(local_geom)
                                 try:
                                 try:
-                                    geoms += (res_geo)
+                                    geoms += res_geo
                                 except TypeError:
                                 except TypeError:
                                     geoms.append(res_geo)
                                     geoms.append(res_geo)
                             return geoms
                             return geoms
@@ -638,9 +640,9 @@ class Panelize(FlatCAMTool):
             try:
             try:
                 panelize_2()
                 panelize_2()
                 self.app.inform.emit(_("[success] Panel created successfully."))
                 self.app.inform.emit(_("[success] Panel created successfully."))
-            except Exception as e:
+            except Exception as ee:
                 proc.done()
                 proc.done()
-                log.debug(str(e))
+                log.debug(str(ee))
                 return
                 return
             proc.done()
             proc.done()