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

This commit is contained in:
Marius Stanciu 2020-06-17 00:38:19 +03:00 committed by Marius
parent 0a64b02397
commit c839428a83
3 changed files with 43 additions and 2 deletions

View File

@ -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
- changed the data structure for the Excellon object; modified the Excellon parser and the Excellon object class

View File

@ -480,7 +480,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
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.
@ -511,13 +511,16 @@ class CNCJobObject(FlatCAMObj, CNCjob):
except TypeError:
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)
if filename == '':
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Export cancelled ..."))
return
else:
if save_gcode is True:
if is_gcode is True:
used_extension = filename.rpartition('.')[2]
self.update_filters(last_ext=used_extension, filter_string='cncjob_save_filters')

View File

@ -6709,6 +6709,40 @@ class App(QtCore.QObject):
: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()
if type(obj) == GeometryObject:
self.on_file_exportdxf()