- allow the old projects to be loaded without crashing the app, although the load is incomplete

This commit is contained in:
Marius Stanciu
2021-03-14 22:08:42 +02:00
committed by Marius
parent 8e02ff4bf2
commit d846b24d66
2 changed files with 50 additions and 33 deletions

View File

@@ -14,6 +14,7 @@ CHANGELOG for FlatCAM beta
- small fix in the Toolchange_Manual preprocessor - small fix in the Toolchange_Manual preprocessor
- Drilling Plugin - added in the UI the toolchange X,Y parameter and made it to work as expected - Drilling Plugin - added in the UI the toolchange X,Y parameter and made it to work as expected
- Milling Plugin - added in the UI the toolchange X,Y parameter and made it to work as expected - Milling Plugin - added in the UI the toolchange X,Y parameter and made it to work as expected
- allow the old projects to be loaded without crashing the app, although the load is incomplete
13.03.2021 13.03.2021

View File

@@ -297,6 +297,9 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.ui.cnc_tools_table.setMaximumHeight(self.ui.cnc_tools_table.getHeight()) self.ui.cnc_tools_table.setMaximumHeight(self.ui.cnc_tools_table.getHeight())
def build_excellon_cnc_tools(self): def build_excellon_cnc_tools(self):
# for the case that self.tools is empty: old projects
if not self.tools:
return
n = len(self.tools) n = len(self.tools)
self.ui.exc_cnc_tools_table.setRowCount(n) self.ui.exc_cnc_tools_table.setRowCount(n)
@@ -925,16 +928,21 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# if this dict is not empty then the object is an Excellon object # if this dict is not empty then the object is an Excellon object
if self.options['type'].lower() == 'excellon': if self.options['type'].lower() == 'excellon':
first_key = next(iter(self.tools)) # for the case that self.tools is empty: old projects
try: try:
include_header = self.app.preprocessors[ first_key = next(iter(self.tools))
self.tools[first_key]['data']['tools_drill_ppname_e'] try:
].include_header include_header = self.app.preprocessors[
except KeyError: self.tools[first_key]['data']['tools_drill_ppname_e']
# for older loaded projects ].include_header
include_header = self.app.preprocessors[ except KeyError:
self.tools[first_key]['data']['ppname_e'] # for older loaded projects
].include_header include_header = self.app.preprocessors[
self.tools[first_key]['data']['ppname_e']
].include_header
except TypeError:
# when self.tools is empty - old projects
include_header = self.app.preprocessors['default'].include_header
gcode = '' gcode = ''
if include_header is False: if include_header is False:
@@ -965,18 +973,22 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# detect if using multi-tool and make the Gcode summation correctly for each case # detect if using multi-tool and make the Gcode summation correctly for each case
if self.multitool is True: if self.multitool is True:
if self.options['type'].lower() == 'excellon': # for the case that self.tools is empty: old projects
for tooluid_key in self.tools: try:
for key, value in self.tools[tooluid_key].items(): if self.options['type'].lower() == 'excellon':
if key == 'gcode' and value: for tooluid_key in self.tools:
gcode += value for key, value in self.tools[tooluid_key].items():
break if key == 'gcode' and value:
else: gcode += value
for tooluid_key in self.cnc_tools: break
for key, value in self.cnc_tools[tooluid_key].items(): else:
if key == 'gcode' and value: for tooluid_key in self.cnc_tools:
gcode += value for key, value in self.cnc_tools[tooluid_key].items():
break if key == 'gcode' and value:
gcode += value
break
except TypeError:
pass
else: else:
gcode += self.gcode gcode += self.gcode
@@ -984,18 +996,22 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# detect if using a HPGL preprocessor # detect if using a HPGL preprocessor
hpgl = False hpgl = False
if self.options['type'].lower() == 'geometry': # for the case that self.tools is empty: old projects
for key in self.cnc_tools: try:
if 'tools_mill_ppname_g' in self.cnc_tools[key]['data']: if self.options['type'].lower() == 'geometry':
if 'hpgl' in self.cnc_tools[key]['data']['tools_mill_ppname_g']: for key in self.cnc_tools:
hpgl = True if 'tools_mill_ppname_g' in self.cnc_tools[key]['data']:
break if 'hpgl' in self.cnc_tools[key]['data']['tools_mill_ppname_g']:
elif self.options['type'].lower() == 'excellon': hpgl = True
for key in self.tools: break
if 'ppname_e' in self.tools[key]['data']: elif self.options['type'].lower() == 'excellon':
if 'hpgl' in self.tools[key]['data']['ppname_e']: for key in self.tools:
hpgl = True if 'ppname_e' in self.tools[key]['data']:
break if 'hpgl' in self.tools[key]['data']['ppname_e']:
hpgl = True
break
except TypeError:
hpgl = False
if hpgl: if hpgl:
processed_body_gcode = '' processed_body_gcode = ''