- brought up-to-date and fixed the Tcl Command Drillcncjob and Cncjob

- fixed Tcl command Isolate to not print messages on message bar in case it is run headless
- fixed Tcl command Copper Clear (NCC)
- fixed Tcl command Paint
This commit is contained in:
Marius Stanciu 2020-10-28 13:15:38 +02:00 committed by Marius
parent 7ca44fa107
commit 9c97ce49b9
10 changed files with 70 additions and 47 deletions

View File

@ -21,6 +21,10 @@ CHANGELOG for FlatCAM beta
- added a new string to the translatable strings - added a new string to the translatable strings
- fixed an error that sometime showed in Legacy Mode when moving the mouse outside canvas - fixed an error that sometime showed in Legacy Mode when moving the mouse outside canvas
- reactivated the shortcut key 'S' in TCL Shell, to close the shell dock when it was open (of course the focus has to be not on the command line) - reactivated the shortcut key 'S' in TCL Shell, to close the shell dock when it was open (of course the focus has to be not on the command line)
- brought up-to-date and fixed the Tcl Command Drillcncjob and Cncjob
- fixed Tcl command Isolate to not print messages on message bar in case it is run headless
- fixed Tcl command Copper Clear (NCC)
- fixed Tcl command Paint
27.10.2020 27.10.2020

View File

@ -372,7 +372,12 @@ class CNCJobObject(FlatCAMObj, CNCjob):
dia_item = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, float(tooldia_key))) dia_item = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, float(tooldia_key)))
nr_drills_item = QtWidgets.QTableWidgetItem('%d' % int(dia_value['nr_drills'])) nr_drills_item = QtWidgets.QTableWidgetItem('%d' % int(dia_value['nr_drills']))
nr_slots_item = QtWidgets.QTableWidgetItem('%d' % int(dia_value['nr_slots'])) nr_slots_item = QtWidgets.QTableWidgetItem('%d' % int(dia_value['nr_slots']))
cutz_item = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, float(dia_value['offset']) + self.z_cut)) try:
offset_val = self.app.dec_format(float(dia_value['offset']), self.decimals) + self.z_cut
except KeyError:
offset_val = self.app.dec_format(float(dia_value['offset_z']), self.decimals) + self.z_cut
cutz_item = QtWidgets.QTableWidgetItem('%f' % offset_val)
t_id.setFlags(QtCore.Qt.ItemIsEnabled) t_id.setFlags(QtCore.Qt.ItemIsEnabled)
dia_item.setFlags(QtCore.Qt.ItemIsEnabled) dia_item.setFlags(QtCore.Qt.ItemIsEnabled)

View File

@ -493,7 +493,7 @@ class GerberObject(FlatCAMObj, Gerber):
geo_obj.solid_geometry = [] geo_obj.solid_geometry = []
# transfer the Cut Z and Vtip and VAngle values in case that we use the V-Shape tool in Gerber UI # transfer the Cut Z and Vtip and Vangle values in case that we use the V-Shape tool in Gerber UI
if geo_obj.tool_type.lower() == 'v': if geo_obj.tool_type.lower() == 'v':
new_cutz = self.app.defaults["tools_iso_tool_cutz"] new_cutz = self.app.defaults["tools_iso_tool_cutz"]
new_vtipdia = self.app.defaults["tools_iso_tool_vtipdia"] new_vtipdia = self.app.defaults["tools_iso_tool_vtipdia"]
@ -555,7 +555,8 @@ class GerberObject(FlatCAMObj, Gerber):
follow=follow, nr_passes=nr_pass) follow=follow, nr_passes=nr_pass)
if geom == 'fail': if geom == 'fail':
app_obj.inform.emit('[ERROR_NOTCL] %s' % _("Isolation geometry could not be generated.")) if plot:
app_obj.inform.emit('[ERROR_NOTCL] %s' % _("Isolation geometry could not be generated."))
return 'fail' return 'fail'
geo_obj.solid_geometry.append(geom) geo_obj.solid_geometry.append(geom)
@ -580,7 +581,9 @@ class GerberObject(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)
else: else:
app_obj.inform.emit('[success] %s" %s' % (_("Isolation geometry created"), geo_obj.options["name"])) if plot:
app_obj.inform.emit('[success] %s: %s' %
(_("Isolation geometry created"), geo_obj.options["name"]))
# even if combine is checked, one pass is still single-geo # even if combine is checked, one pass is still single-geo
geo_obj.multigeo = True if passes > 1 else False geo_obj.multigeo = True if passes > 1 else False
@ -629,7 +632,8 @@ class GerberObject(FlatCAMObj, Gerber):
follow=follow, nr_passes=i) follow=follow, nr_passes=i)
if geom == 'fail': if geom == 'fail':
app_obj.inform.emit('[ERROR_NOTCL] %s' % _("Isolation geometry could not be generated.")) if plot:
app_obj.inform.emit('[ERROR_NOTCL] %s' % _("Isolation geometry could not be generated."))
return 'fail' return 'fail'
geo_obj.solid_geometry = geom geo_obj.solid_geometry = geom
@ -706,8 +710,9 @@ class GerberObject(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)
else: else:
app_obj.inform.emit('[success] %s: %s' % if plot:
(_("Isolation geometry created"), geo_obj.options["name"])) app_obj.inform.emit('[success] %s: %s' %
(_("Isolation geometry created"), geo_obj.options["name"]))
geo_obj.multigeo = False geo_obj.multigeo = False
# ############################################################ # ############################################################

View File

@ -2836,10 +2836,10 @@ class NonCopperClear(AppTool, Gerber):
# Generate area for each tool # Generate area for each tool
offset_a = sum(sorted_tools) offset_a = sum(sorted_tools)
current_uid = int(1) current_uid = int(1)
try: # try:
tool = eval(self.app.defaults["tools_ncc_tools"])[0] # tool = eval(self.app.defaults["tools_ncc_tools"])[0]
except TypeError: # except TypeError:
tool = eval(self.app.defaults["tools_ncc_tools"]) # tool = eval(self.app.defaults["tools_ncc_tools"])
# ################################################################################################### # ###################################################################################################
# Calculate the empty area by subtracting the solid_geometry from the object bounding box geometry ## # Calculate the empty area by subtracting the solid_geometry from the object bounding box geometry ##
@ -2854,6 +2854,8 @@ class NonCopperClear(AppTool, Gerber):
sol_geo = ncc_obj.solid_geometry.buffer(0) sol_geo = ncc_obj.solid_geometry.buffer(0)
else: else:
sol_geo = ncc_obj.solid_geometry sol_geo = ncc_obj.solid_geometry
if isinstance(sol_geo, list):
sol_geo = unary_union(sol_geo)
if has_offset is True: if has_offset is True:
app_obj.inform.emit('[WARNING_NOTCL] %s ...' % _("Buffering")) app_obj.inform.emit('[WARNING_NOTCL] %s ...' % _("Buffering"))

View File

@ -2234,7 +2234,9 @@ class ToolPaint(AppTool, Gerber):
self.app.inform.emit('%s %s' % (_("Paint Tool."), _("Normal painting polygon task started."))) self.app.inform.emit('%s %s' % (_("Paint Tool."), _("Normal painting polygon task started.")))
if inside_pt and poly_list is None: if inside_pt and poly_list is None:
polygon_list = [self.find_polygon(point=inside_pt, geoset=obj.solid_geometry)] polygon_list = self.find_polygon(point=inside_pt, geoset=obj.solid_geometry)
if polygon_list:
polygon_list = [polygon_list]
elif (inside_pt is None and poly_list) or (inside_pt and poly_list): elif (inside_pt is None and poly_list) or (inside_pt and poly_list):
polygon_list = poly_list polygon_list = poly_list
else: else:
@ -2244,7 +2246,7 @@ class ToolPaint(AppTool, Gerber):
if polygon_list is None: if polygon_list is None:
self.app.log.warning('No polygon found.') self.app.log.warning('No polygon found.')
self.app.inform.emit('[WARNING] %s' % _('No polygon found.')) self.app.inform.emit('[WARNING] %s' % _('No polygon found.'))
return return "fail"
self.paint_geo(obj, polygon_list, tooldia=tooldia, order=order, method=method, outname=outname, self.paint_geo(obj, polygon_list, tooldia=tooldia, order=order, method=method, outname=outname,
tools_storage=tools_storage, plot=plot, run_threaded=run_threaded) tools_storage=tools_storage, plot=plot, run_threaded=run_threaded)

View File

@ -3596,6 +3596,7 @@ class CNCjob(Geometry):
for k, v in list(self.options.items()): for k, v in list(self.options.items()):
default_data[k] = deepcopy(v) default_data[k] = deepcopy(v)
# it[1] is the tool diameter
self.exc_cnc_tools[it[1]] = {} self.exc_cnc_tools[it[1]] = {}
self.exc_cnc_tools[it[1]]['tool'] = it[0] self.exc_cnc_tools[it[1]]['tool'] = it[0]
self.exc_cnc_tools[it[1]]['nr_drills'] = drill_no self.exc_cnc_tools[it[1]]['nr_drills'] = drill_no
@ -6349,10 +6350,11 @@ class CNCjob(Geometry):
# Current path: temporary storage until tool is # Current path: temporary storage until tool is
# lifted or lowered. # lifted or lowered.
if self.toolchange_xy_type == "excellon": if self.toolchange_xy_type == "excellon":
if self.app.defaults["excellon_toolchangexy"] == '' or self.app.defaults["excellon_toolchangexy"] is None: if self.app.defaults["tools_drill_toolchangexy"] == '' or \
self.app.defaults["tools_drill_toolchangexy"] is None:
pos_xy = (0, 0) pos_xy = (0, 0)
else: else:
pos_xy = self.app.defaults["excellon_toolchangexy"] pos_xy = self.app.defaults["tools_drill_toolchangexy"]
try: try:
pos_xy = [float(eval(a)) for a in pos_xy.split(",")] pos_xy = [float(eval(a)) for a in pos_xy.split(",")]
except Exception: except Exception:

View File

@ -169,7 +169,7 @@ class TclCommandCncjob(TclCommandSignaled):
args["endxy"] = args["endxy"] args["endxy"] = args["endxy"]
else: else:
if self.app.defaults["geometry_endxy"]: if self.app.defaults["geometry_endxy"]:
args["endxy"] = self.app.defaults["geometry_endxy"] args["endxy"] = str(self.app.defaults["geometry_endxy"])
else: else:
args["endxy"] = '0, 0' args["endxy"] = '0, 0'
if len(eval(args["endxy"])) != 2: if len(eval(args["endxy"])) != 2:
@ -204,7 +204,7 @@ class TclCommandCncjob(TclCommandSignaled):
args["toolchangexy"] = args["toolchangexy"] args["toolchangexy"] = args["toolchangexy"]
else: else:
if self.app.defaults["geometry_toolchangexy"]: if self.app.defaults["geometry_toolchangexy"]:
args["toolchangexy"] = self.app.defaults["geometry_toolchangexy"] args["toolchangexy"] = str(self.app.defaults["geometry_toolchangexy"])
else: else:
args["toolchangexy"] = '0, 0' args["toolchangexy"] = '0, 0'
if len(eval(args["toolchangexy"])) != 2: if len(eval(args["toolchangexy"])) != 2:

View File

@ -103,7 +103,7 @@ class TclCommandCopperClear(TclCommand):
if 'tooldia' in args: if 'tooldia' in args:
tooldia = str(args['tooldia']) tooldia = str(args['tooldia'])
else: else:
tooldia = self.app.defaults["tools_ncc_tools"] tooldia = str(self.app.defaults["tools_ncc_tools"])
if 'overlap' in args: if 'overlap' in args:
overlap = float(args['overlap']) / 100.0 overlap = float(args['overlap']) / 100.0
@ -223,8 +223,8 @@ class TclCommandCopperClear(TclCommand):
"area_strategy": self.app.defaults["geometry_area_strategy"], "area_strategy": self.app.defaults["geometry_area_strategy"],
"area_overz": float(self.app.defaults["geometry_area_overz"]), "area_overz": float(self.app.defaults["geometry_area_overz"]),
"tooldia": self.app.defaults["tools_paint_tooldia"], "tooldia": tooldia,
"tools_ncc_operation": self.app.defaults["tools_ncc_operation"], "tools_ncc_operation": self.app.defaults["tools_ncc_operation"],
"tools_ncc_margin": margin, "tools_ncc_margin": margin,
"tools_ncc_method": method_data, "tools_ncc_method": method_data,
@ -253,7 +253,7 @@ class TclCommandCopperClear(TclCommand):
'solid_geometry': [] 'solid_geometry': []
} }
}) })
ncc_tools[int(tooluid)]['data']['tooldia'] = float('%.*f' % (obj.decimals, tool)) ncc_tools[int(tooluid)]['data']['tooldia'] = self.app.dec_format(tool, obj.decimals)
# Non-Copper clear all polygons in the non-copper clear object # Non-Copper clear all polygons in the non-copper clear object
if 'all' in args: if 'all' in args:

View File

@ -235,7 +235,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
xy_toolchange = args["toolchangexy"] xy_toolchange = args["toolchangexy"]
else: else:
if self.app.defaults["tools_drill_toolchangexy"]: if self.app.defaults["tools_drill_toolchangexy"]:
xy_toolchange = self.app.defaults["tools_drill_toolchangexy"] xy_toolchange = str(self.app.defaults["tools_drill_toolchangexy"])
else: else:
xy_toolchange = '0, 0' xy_toolchange = '0, 0'
if len(eval(xy_toolchange)) != 2: if len(eval(xy_toolchange)) != 2:
@ -249,7 +249,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
xy_end = args["endxy"] xy_end = args["endxy"]
else: else:
if self.app.defaults["tools_drill_endxy"]: if self.app.defaults["tools_drill_endxy"]:
xy_end = self.app.defaults["tools_drill_endxy"] xy_end = str(self.app.defaults["tools_drill_endxy"])
else: else:
xy_end = '0, 0' xy_end = '0, 0'
@ -322,14 +322,15 @@ class TclCommandDrillcncjob(TclCommandSignaled):
if "startz" in args and args["startz"] is not None: if "startz" in args and args["startz"] is not None:
job_obj.startz = float(args["startz"]) job_obj.startz = float(args["startz"])
else: else:
if self.app.defaults["excellon_startz"]: if self.app.defaults["tools_drill_startz"]:
job_obj.startz = self.app.defaults["tools_drill_startz"] job_obj.startz = self.app.defaults["tools_drill_startz"]
else: else:
job_obj.startz = (0, 0) job_obj.startz = self.app.defaults["tools_drill_travelz"]
job_obj.endz = float(endz) job_obj.endz = float(endz)
job_obj.xy_end = xy_end job_obj.xy_end = xy_end
job_obj.excellon_optimization_type = opt_type job_obj.excellon_optimization_type = opt_type
job_obj.spindledir = self.app.defaults["tools_drill_spindledir"]
ret_val = job_obj.generate_from_excellon_by_tool(obj, tools, use_ui=False) ret_val = job_obj.generate_from_excellon_by_tool(obj, tools, use_ui=False)
job_obj.source_file = ret_val job_obj.source_file = ret_val
@ -338,9 +339,9 @@ class TclCommandDrillcncjob(TclCommandSignaled):
return 'fail' return 'fail'
for t_item in job_obj.exc_cnc_tools: for t_item in job_obj.exc_cnc_tools:
job_obj.exc_cnc_tools[t_item]['data']['offset'] = \ job_obj.exc_cnc_tools[t_item]['data']['tools_drill_offset'] = \
float(job_obj.exc_cnc_tools[t_item]['offset']) + float(drillz) float(job_obj.exc_cnc_tools[t_item]['offset_z']) + float(drillz)
job_obj.exc_cnc_tools[t_item]['data']['ppname_e'] = obj.options['ppname_e'] job_obj.exc_cnc_tools[t_item]['data']['tools_drill_ppname_e'] = job_obj.options['ppname_e']
job_obj.gcode_parse() job_obj.gcode_parse()
job_obj.create_geometry() job_obj.create_geometry()

View File

@ -102,7 +102,7 @@ class TclCommandPaint(TclCommand):
if 'tooldia' in args: if 'tooldia' in args:
tooldia = str(args['tooldia']) tooldia = str(args['tooldia'])
else: else:
tooldia = float(self.app.defaults["tools_paint_overlap"]) tooldia = str(self.app.defaults["tools_paint_tooldia"])
if 'overlap' in args: if 'overlap' in args:
overlap = float(args['overlap']) / 100.0 overlap = float(args['overlap']) / 100.0
@ -202,13 +202,13 @@ class TclCommandPaint(TclCommand):
"area_strategy": self.app.defaults["geometry_area_strategy"], "area_strategy": self.app.defaults["geometry_area_strategy"],
"area_overz": float(self.app.defaults["geometry_area_overz"]), "area_overz": float(self.app.defaults["geometry_area_overz"]),
"tooldia": self.app.defaults["tools_paint_tooldia"], "tooldia": tooldia,
"tools_paint_offset": offset, "tools_paint_offset": offset,
"tools_paint_method": method, "tools_paint_method": method,
"tools_paint_selectmethod": select, "tools_paint_selectmethod": select,
"tools_paint_connect": connect, "tools_paint_connect": connect,
"tools_paint_contour": contour, "tools_paint_contour": contour,
"tools_paint_overlap": overlap "tools_paint_overlap": overlap
}) })
paint_tools = {} paint_tools = {}
@ -217,7 +217,7 @@ class TclCommandPaint(TclCommand):
tooluid += 1 tooluid += 1
paint_tools.update({ paint_tools.update({
int(tooluid): { int(tooluid): {
'tooldia': float('%.*f' % (obj.decimals, tool)), 'tooldia': self.app.dec_format(float(tool), self.app.decimals),
'offset': 'Path', 'offset': 'Path',
'offset_value': 0.0, 'offset_value': 0.0,
'type': 'Iso', 'type': 'Iso',
@ -226,7 +226,7 @@ class TclCommandPaint(TclCommand):
'solid_geometry': [] 'solid_geometry': []
} }
}) })
paint_tools[int(tooluid)]['data']['tooldia'] = float('%.*f' % (obj.decimals, tool)) paint_tools[int(tooluid)]['data']['tooldia'] = self.app.dec_format(float(tool), self.app.decimals)
if obj is None: if obj is None:
return "Object not found: %s" % name return "Object not found: %s" % name
@ -257,15 +257,17 @@ class TclCommandPaint(TclCommand):
x = coords_xy[0] x = coords_xy[0]
y = coords_xy[1] y = coords_xy[1]
self.app.paint_tool.paint_poly(obj=obj, ret_val = self.app.paint_tool.paint_poly(obj=obj,
inside_pt=[x, y], inside_pt=[x, y],
tooldia=tooldia, tooldia=tooldia,
order=order, order=order,
method=method, method=method,
outname=outname, outname=outname,
tools_storage=paint_tools, tools_storage=paint_tools,
plot=False, plot=False,
run_threaded=False) run_threaded=False)
if ret_val == 'fail':
return "Could not find a Polygon at the specified location."
return return
# Paint all polygons found within the box object from the the painted object # Paint all polygons found within the box object from the the painted object