- updated the Milling Plugin and all the related parts in the CNCJob Object and in all preprocessors. Now, the parent 'tools' attribute is inherited and also the GCode is stored here

- made sure that old projects load but without the CNCjob objects which would have crashed the app due different data structures
- the FlatCAm Evo projects load now in succession, no longer on threads
This commit is contained in:
Marius Stanciu
2021-03-15 00:02:33 +02:00
committed by Marius
parent d846b24d66
commit 546f4c2361
10 changed files with 303 additions and 273 deletions

View File

@@ -2899,7 +2899,7 @@ class ToolMilling(AppTool, Excellon):
# this turn on the FlatCAMCNCJob plot for multiple tools
new_cncjob_obj.multitool = True
new_cncjob_obj.multigeo = False
new_cncjob_obj.cnc_tools.clear()
new_cncjob_obj.tools.clear()
new_cncjob_obj.segx = segx
new_cncjob_obj.segy = segy
@@ -3020,7 +3020,7 @@ class ToolMilling(AppTool, Excellon):
except Exception as er:
app_obj.inform.emit('[ERROR] %s: %s' % (_("G-Code processing failed with error"), str(er)))
new_cncjob_obj.cnc_tools.update({
new_cncjob_obj.tools.update({
tooluid_key: deepcopy(dia_cnc_dict)
})
dia_cnc_dict.clear()
@@ -3046,7 +3046,7 @@ class ToolMilling(AppTool, Excellon):
# this turn on the FlatCAMCNCJob plot for multiple tools
new_cncjob_obj.multitool = True
new_cncjob_obj.multigeo = True
new_cncjob_obj.cnc_tools.clear()
new_cncjob_obj.tools.clear()
new_cncjob_obj.segx = segx
new_cncjob_obj.segy = segy
@@ -3180,7 +3180,7 @@ class ToolMilling(AppTool, Excellon):
# object is the source of gcode
# Update the CNCJob tools dictionary
new_cncjob_obj.cnc_tools.update({
new_cncjob_obj.tools.update({
tooluid_key: deepcopy(dia_cnc_dict)
})
dia_cnc_dict.clear()

View File

@@ -262,8 +262,8 @@ class ObjectReport(AppTool):
log.error("PropertiesTool.addItems() --> %s" % str(ee))
try:
for tool_k in obj_prop.cnc_tools:
x0, y0, x1, y1 = unary_union(obj_prop.cnc_tools[tool_k]['solid_geometry']).bounds
for tool_k in obj_prop.tools:
x0, y0, x1, y1 = unary_union(obj_prop.tools[tool_k]['solid_geometry']).bounds
xmin.append(x0)
ymin.append(y0)
xmax.append(x1)
@@ -460,104 +460,106 @@ class ObjectReport(AppTool):
else:
self.treeWidget.addChild(geo_tool, [str(k), str(v)], True)
elif obj.kind.lower() == 'cncjob':
# for cncjob objects made from gerber or geometry
for tool, value in obj.cnc_tools.items():
geo_tool = self.treeWidget.addParent(
tools, str(tool), expanded=True, color=p_color, font=font)
for k, v in value.items():
if k == 'solid_geometry':
printed_value = _('Present') if v else _('None')
self.treeWidget.addChild(geo_tool, [_("Solid Geometry"), printed_value], True)
elif k == 'gcode':
printed_value = _('Present') if v != '' else _('None')
self.treeWidget.addChild(geo_tool, [_("GCode Text"), printed_value], True)
elif k == 'gcode_parsed':
printed_value = _('Present') if v else _('None')
self.treeWidget.addChild(geo_tool, [_("GCode Geometry"), printed_value], True)
elif k == 'data':
pass
else:
self.treeWidget.addChild(geo_tool, [str(k), str(v)], True)
# for CNCJob objects made from Gerber or Geometry objects
if obj.options['type'].lower() == 'geometry':
for tool, value in obj.tools.items():
geo_tool = self.treeWidget.addParent(
tools, str(tool), expanded=True, color=p_color, font=font)
for k, v in value.items():
if k == 'solid_geometry':
printed_value = _('Present') if v else _('None')
self.treeWidget.addChild(geo_tool, [_("Solid Geometry"), printed_value], True)
elif k == 'gcode':
printed_value = _('Present') if v != '' else _('None')
self.treeWidget.addChild(geo_tool, [_("GCode Text"), printed_value], True)
elif k == 'gcode_parsed':
printed_value = _('Present') if v else _('None')
self.treeWidget.addChild(geo_tool, [_("GCode Geometry"), printed_value], True)
elif k == 'data':
pass
else:
self.treeWidget.addChild(geo_tool, [str(k), str(v)], True)
v = value['data']
tool_data = self.treeWidget.addParent(
geo_tool, _("Tool Data"), color=p_color, font=font)
for data_k, data_v in v.items():
self.treeWidget.addChild(tool_data, [str(data_k).capitalize(), str(data_v)], True)
v = value['data']
tool_data = self.treeWidget.addParent(
geo_tool, _("Tool Data"), color=p_color, font=font)
for data_k, data_v in v.items():
self.treeWidget.addChild(tool_data, [str(data_k).capitalize(), str(data_v)], True)
# for CNCJob objects made from Excellon
for tool_id, value in obj.tools.items():
tool_dia = obj.tools[tool_id]['tooldia']
exc_tool = self.treeWidget.addParent(
tools, str(tool_id), expanded=False, color=p_color, font=font
)
self.treeWidget.addChild(
exc_tool,
[
_('Diameter'),
'%.*f %s' % (self.decimals, tool_dia, self.app.defaults['units'].lower())
],
True
)
for k, v in value.items():
if k == 'solid_geometry':
printed_value = _('Present') if v else _('None')
self.treeWidget.addChild(exc_tool, [_("Solid Geometry"), printed_value], True)
elif k == 'nr_drills':
self.treeWidget.addChild(exc_tool, [_("Drills number"), str(v)], True)
elif k == 'nr_slots':
self.treeWidget.addChild(exc_tool, [_("Slots number"), str(v)], True)
elif k == 'gcode':
printed_value = _('Present') if v != '' else _('None')
self.treeWidget.addChild(exc_tool, [_("GCode Text"), printed_value], True)
elif k == 'gcode_parsed':
printed_value = _('Present') if v else _('None')
self.treeWidget.addChild(exc_tool, [_("GCode Geometry"), printed_value], True)
else:
pass
# for CNCJob objects made from Excellon objects
if obj.options['type'].lower() == 'excellon':
for tool_id, value in obj.tools.items():
tool_dia = obj.tools[tool_id]['tooldia']
exc_tool = self.treeWidget.addParent(
tools, str(tool_id), expanded=False, color=p_color, font=font
)
self.treeWidget.addChild(
exc_tool,
[
_('Diameter'),
'%.*f %s' % (self.decimals, tool_dia, self.app.defaults['units'].lower())
],
True
)
for k, v in value.items():
if k == 'solid_geometry':
printed_value = _('Present') if v else _('None')
self.treeWidget.addChild(exc_tool, [_("Solid Geometry"), printed_value], True)
elif k == 'nr_drills':
self.treeWidget.addChild(exc_tool, [_("Drills number"), str(v)], True)
elif k == 'nr_slots':
self.treeWidget.addChild(exc_tool, [_("Slots number"), str(v)], True)
elif k == 'gcode':
printed_value = _('Present') if v != '' else _('None')
self.treeWidget.addChild(exc_tool, [_("GCode Text"), printed_value], True)
elif k == 'gcode_parsed':
printed_value = _('Present') if v else _('None')
self.treeWidget.addChild(exc_tool, [_("GCode Geometry"), printed_value], True)
else:
pass
self.treeWidget.addChild(
exc_tool,
[
_("Depth of Cut"),
'%.*f %s' % (
self.decimals,
(obj.z_cut - abs(value['data']['tools_drill_offset'])),
self.app.defaults['units'].lower()
)
],
True
)
self.treeWidget.addChild(
exc_tool,
[
_("Clearance Height"),
'%.*f %s' % (
self.decimals,
obj.z_move,
self.app.defaults['units'].lower()
)
],
True
)
self.treeWidget.addChild(
exc_tool,
[
_("Feedrate"),
'%.*f %s/min' % (
self.decimals,
obj.feedrate,
self.app.defaults['units'].lower()
)
],
True
)
self.treeWidget.addChild(
exc_tool,
[
_("Depth of Cut"),
'%.*f %s' % (
self.decimals,
(obj.z_cut - abs(value['data']['tools_drill_offset'])),
self.app.defaults['units'].lower()
)
],
True
)
self.treeWidget.addChild(
exc_tool,
[
_("Clearance Height"),
'%.*f %s' % (
self.decimals,
obj.z_move,
self.app.defaults['units'].lower()
)
],
True
)
self.treeWidget.addChild(
exc_tool,
[
_("Feedrate"),
'%.*f %s/min' % (
self.decimals,
obj.feedrate,
self.app.defaults['units'].lower()
)
],
True
)
v = value['data']
tool_data = self.treeWidget.addParent(
exc_tool, _("Tool Data"), color=p_color, font=font)
for data_k, data_v in v.items():
self.treeWidget.addChild(tool_data, [str(data_k).capitalize(), str(data_v)], True)
v = value['data']
tool_data = self.treeWidget.addParent(
exc_tool, _("Tool Data"), color=p_color, font=font)
for data_k, data_v in v.items():
self.treeWidget.addChild(tool_data, [str(data_k).capitalize(), str(data_v)], True)
r_time = obj.routing_time
if r_time > 1:

View File

@@ -930,7 +930,8 @@ class SolderPaste(AppTool):
# this turn on the FlatCAMCNCJob plot for multiple tools
new_obj.multitool = True
new_obj.multigeo = True
new_obj.cnc_tools.clear()
# new_obj object is a CNCJob object made from an Geometry object
new_obj.tools.clear()
new_obj.special_group = 'solder_paste_tool'
new_obj.options['xmin'] = xmin
@@ -970,7 +971,8 @@ class SolderPaste(AppTool):
# tell gcode_parse from which point to start drawing the lines depending on what kind of
# object is the source of gcode
new_obj.cnc_tools.update({
# new_obj is a CNCJob made from Geometry object
new_obj.tools.update({
tooluid_key: deepcopy(tool_cnc_dict)
})
tool_cnc_dict.clear()
@@ -1031,13 +1033,14 @@ class SolderPaste(AppTool):
gcode += '(Units: ' + self.units.upper() + ')\n' + "\n"
gcode += '(Created on ' + time_str + ')\n' + '\n'
for tool in obj.cnc_tools:
# obj is a CNCJob object made from an Geometry object
for tool in obj.tools:
try:
# it's text
gcode += obj.cnc_tools[tool]['gcode']
gcode += obj.tools[tool]['gcode']
except TypeError:
# it's StringIO
gcode += obj.cnc_tools[tool]['gcode'].getvalue()
gcode += obj.tools[tool]['gcode'].getvalue()
# then append the text from GCode to the text editor
# try:
@@ -1101,8 +1104,9 @@ class SolderPaste(AppTool):
gcode += '(Units: ' + self.units.upper() + ')\n' + "\n"
gcode += '(Created on ' + time_str + ')\n' + '\n'
for tool in obj.cnc_tools:
gcode += obj.cnc_tools[tool]['gcode']
# for CNCJob objects made from Gerber or Geometry objects
for tool in obj.tools:
gcode += obj.tools[tool]['gcode']
lines = StringIO(gcode)
# ## Write