Jelajahi Sumber

- added the multi-save capability if multiple CNCJob objects are selected in Project tab but only if all are of type CNCJob

Marius Stanciu 5 tahun lalu
induk
melakukan
c839428a83
3 mengubah file dengan 43 tambahan dan 2 penghapusan
  1. 4 0
      CHANGELOG.md
  2. 5 2
      appObjects/FlatCAMCNCJob.py
  3. 34 0
      app_Main.py

+ 4 - 0
CHANGELOG.md

@@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta
 
 
 =================================================
 =================================================
 
 
+17.06.2020
+
+- added the multi-save capability if multiple CNCJob objects are selected in Project tab but only if all are of type CNCJob
+
 16.06.2020
 16.06.2020
 
 
 - changed the data structure for the Excellon object; modified the Excellon parser and the Excellon object class
 - changed the data structure for the Excellon object; modified the Excellon parser and the Excellon object class

+ 5 - 2
appObjects/FlatCAMCNCJob.py

@@ -480,7 +480,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
 
 
         self.app.worker_task.emit({'fcn': worker_task, 'params': []})
         self.app.worker_task.emit({'fcn': worker_task, 'params': []})
 
 
-    def on_exportgcode_button_click(self, *args):
+    def on_exportgcode_button_click(self):
         """
         """
         Handler activated by a button clicked when exporting GCode.
         Handler activated by a button clicked when exporting GCode.
 
 
@@ -511,13 +511,16 @@ class CNCJobObject(FlatCAMObj, CNCjob):
         except TypeError:
         except TypeError:
             filename, _f = FCFileSaveDialog.get_saved_filename(caption=_("Export Code ..."), ext_filter=_filter_)
             filename, _f = FCFileSaveDialog.get_saved_filename(caption=_("Export Code ..."), ext_filter=_filter_)
 
 
+        self.export_gcode_handler(filename, is_gcode=save_gcode)
+
+    def export_gcode_handler(self, filename, is_gcode=True):
         filename = str(filename)
         filename = str(filename)
 
 
         if filename == '':
         if filename == '':
             self.app.inform.emit('[WARNING_NOTCL] %s' % _("Export cancelled ..."))
             self.app.inform.emit('[WARNING_NOTCL] %s' % _("Export cancelled ..."))
             return
             return
         else:
         else:
-            if save_gcode is True:
+            if is_gcode is True:
                 used_extension = filename.rpartition('.')[2]
                 used_extension = filename.rpartition('.')[2]
                 self.update_filters(last_ext=used_extension, filter_string='cncjob_save_filters')
                 self.update_filters(last_ext=used_extension, filter_string='cncjob_save_filters')
 
 

+ 34 - 0
app_Main.py

@@ -6709,6 +6709,40 @@ class App(QtCore.QObject):
         :return:
         :return:
         """
         """
 
 
+        sel_objects = self.collection.get_selected()
+        len_objects = len(sel_objects)
+
+        cnt = 0
+        if len_objects > 1:
+            for o in sel_objects:
+                if o.kind == 'cncjob':
+                    cnt += 1
+
+            if len_objects == cnt:
+                # all selected objects are of type CNCJOB therefore we issue a multiple save
+                _filter_ = self.defaults['cncjob_save_filters'] + \
+                           ";;RML1 Files .rol (*.rol);;HPGL Files .plt (*.plt)"
+
+                dir_file_to_save = self.get_last_save_folder() + '/multi_save'
+
+                try:
+                    filename, _f = FCFileSaveDialog.get_saved_filename(
+                        caption=_("Export Code ..."),
+                        directory=dir_file_to_save,
+                        ext_filter=_filter_
+                    )
+                except TypeError:
+                    filename, _f = FCFileSaveDialog.get_saved_filename(caption=_("Export Code ..."),
+                                                                       ext_filter=_filter_)
+
+                filename = filename.rpartition('/')[0]
+
+                for ob in sel_objects:
+                    ob.read_form()
+                    fname = '%s/%s' % (filename, ob.options['name'])
+                    ob.export_gcode_handler(fname, is_gcode=True)
+                return
+
         obj = self.collection.get_active()
         obj = self.collection.get_active()
         if type(obj) == GeometryObject:
         if type(obj) == GeometryObject:
             self.on_file_exportdxf()
             self.on_file_exportdxf()