- Drilling Tool - now slots are converted to drills if the checkbox is ON for the tool investigated

- Drilling Tool - fixes due of changes in properties (preferences)
- fixed the Drillcncjob TCL command
This commit is contained in:
Marius Stanciu 2020-07-13 15:19:24 +03:00
parent ed96f97d9a
commit 1c77e3cc2a
4 changed files with 82 additions and 83 deletions

View File

@ -13,6 +13,9 @@ CHANGELOG for FlatCAM beta
- Drilling Tool - working in adding tools auto-load from Tools DB
- some updates to the Excellon Object options
- Drilling Tool - manual add from Tools DB is working
- Drilling Tool - now slots are converted to drills if the checkbox is ON for the tool investigated
- Drilling Tool - fixes due of changes in properties (preferences)
- fixed the Drillcncjob TCL command
12.07.2020

View File

@ -1392,7 +1392,7 @@ class ToolDrilling(AppTool, Excellon):
selected_uid.add(uid)
return list(selected_uid)
def create_drill_points(self, selected_tools, selected_sorted_tools, convert_slots=False):
def create_drill_points(self, selected_tools, selected_sorted_tools):
points = {}
# create drill points out of the drills locations
@ -1408,8 +1408,10 @@ class ToolDrilling(AppTool, Excellon):
# convert slots to a sequence of drills and add them to drill points
should_add_last_pt = self.t_ui.last_drill_cb.get_value()
if convert_slots:
for tool_key, tl_dict in self.excellon_tools.items():
for tool_key, tl_dict in self.excellon_tools.items():
convert_slots = tl_dict['data']['tools_drill_drill_slots']
if convert_slots:
if tool_key in selected_tools:
overlap = 1 - (self.t_ui.drill_overlap_entry.get_value() / 100.0)
drill_overlap = 0.0
@ -1429,7 +1431,7 @@ class ToolDrilling(AppTool, Excellon):
points[tool_key] += new_drills
except Exception:
points[tool_key] = new_drills
log.debug("Found %d TOOLS with drills after converting slots to drills." % len(points))
log.debug("Found %d TOOLS with drills after converting slots to drills." % len(points))
return points
@ -1465,8 +1467,6 @@ class ToolDrilling(AppTool, Excellon):
job_name = obj.options["name"] + "_cnc"
obj.pp_excellon_name = self.t_ui.pp_excellon_name_cb.get_value()
convert_slots = self.t_ui.drill_slots_cb.get_value()
if self.is_valid_excellon() is False:
log.debug("camlib.CNCJob.generate_from_excellon_by_tool() --> "
"The loaded Excellon file has no drills ...")
@ -1520,8 +1520,7 @@ class ToolDrilling(AppTool, Excellon):
self.app.inform.emit(_("Creating a list of points to drill..."))
# points is a dictionary: keys are tools ad values are lists of Shapely Points
points = self.create_drill_points(selected_tools=sel_tools, selected_sorted_tools=sorted_tools,
convert_slots=convert_slots)
points = self.create_drill_points(selected_tools=sel_tools, selected_sorted_tools=sorted_tools)
# check if there are drill points in the exclusion areas (if any areas)
if self.app.exc_areas.exclusion_areas_storage and self.check_intersection(points) is True:
@ -1661,6 +1660,7 @@ class ToolDrilling(AppTool, Excellon):
tool_points = points[tool]
used_tooldia = self.excellon_tools[tool]['tooldia']
convert_slots = self.excellon_tools[tool]['data']['tools_drill_drill_slots']
if convert_slots is True:
nr_drills = len(points[tool])
nr_slots = 0
@ -1711,6 +1711,8 @@ class ToolDrilling(AppTool, Excellon):
# process all in one go with no toolchange and with only one tool
nr_drills = 0
nr_slots = 0
convert_slots = self.excellon_tools[used_tool]['data']['tools_drill_drill_slots']
if convert_slots is False:
for line in range(1, len(tool_table_items)):
# we may have exception ValueError if there are no drills/slots for the current tool/line
@ -1812,9 +1814,6 @@ class ToolDrilling(AppTool, Excellon):
# self.app.worker.add_task(job_thread, [self.app])
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
def drilling_handler(self, obj):
pass
def reset_fields(self):
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
@ -2521,9 +2520,3 @@ def distance(pt1, pt2):
def distance_euclidian(x1, y1, x2, y2):
return np.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
class AttrDict(dict):
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self

View File

@ -2941,28 +2941,28 @@ class CNCjob(Geometry):
self.tooldia = tools[tool]["tooldia"]
self.postdata['toolC'] = tools[tool]["tooldia"]
self.z_feedrate = tool_dict['feedrate_z']
self.feedrate = tool_dict['feedrate']
self.z_feedrate = tool_dict['tools_drill_feedrate_z']
self.feedrate = tool_dict['tools_drill_feedrate_z']
# Z_cut parameter
if self.machinist_setting == 0:
self.z_cut = self.check_zcut(zcut=tool_dict["excellon_cutz"])
self.z_cut = self.check_zcut(zcut=tool_dict["tools_drill_cutz"])
if self.z_cut == 'fail':
return 'fail'
self.z_cut = tool_dict['cutz']
self.z_cut = tool_dict['tools_drill_cutz']
# multidepth use this
old_zcut = tool_dict["cutz"]
old_zcut = tool_dict["tools_drill_cutz"]
self.z_move = tool_dict['travelz']
self.spindlespeed = tool_dict['spindlespeed']
self.dwell = tool_dict['dwell']
self.dwelltime = tool_dict['dwelltime']
self.multidepth = tool_dict['multidepth']
self.z_depthpercut = tool_dict['depthperpass']
self.z_move = tool_dict['tools_drill_travelz']
self.spindlespeed = tool_dict['tools_drill_spindlespeed']
self.dwell = tool_dict['tools_drill_dwell']
self.dwelltime = tool_dict['tools_drill_dwelltime']
self.multidepth = tool_dict['tools_drill_multidepth']
self.z_depthpercut = tool_dict['tools_drill_depthperpass']
# XY_toolchange parameter
self.xy_toolchange = tool_dict["toolchangexy"]
self.xy_toolchange = tool_dict["tools_drill_toolchangexy"]
try:
if self.xy_toolchange == '':
self.xy_toolchange = None
@ -2984,7 +2984,7 @@ class CNCjob(Geometry):
pass
# XY_end parameter
self.xy_end = tool_dict["endxy"]
self.xy_end = tool_dict["tools_drill_endxy"]
self.xy_end = re.sub('[()\[\]]', '', str(self.xy_end)) if self.xy_end else None
if self.xy_end and self.xy_end != '':
self.xy_end = [float(eval(a)) for a in self.xy_end.split(",")]
@ -3079,7 +3079,7 @@ class CNCjob(Geometry):
# because the values for Z offset are created in build_tool_ui()
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
try:
z_offset = float(tool_dict['offset']) * (-1)
z_offset = float(tool_dict['tools_drill_offset']) * (-1)
except KeyError:
z_offset = 0
self.z_cut = z_offset + old_zcut
@ -3123,7 +3123,7 @@ class CNCjob(Geometry):
t_gcode += self.doformat(p.lift_code, x=locx, y=locy)
# restore z_move
self.z_move = tool_dict['travelz']
self.z_move = tool_dict['tools_drill_travelz']
else:
if prev_z is not None:
# move to next point
@ -3131,7 +3131,7 @@ class CNCjob(Geometry):
# we assume that previously the z_move was altered therefore raise to
# the travel_z (z_move)
self.z_move = tool_dict['travelz']
self.z_move = tool_dict['tools_drill_travelz']
t_gcode += self.doformat(p.lift_code, x=locx, y=locy)
else:
# move to next point
@ -3343,7 +3343,7 @@ class CNCjob(Geometry):
if self.use_ui:
try:
z_off = float(exobj.tools[it[0]]['data']['offset']) * (-1)
z_off = float(exobj.tools[it[0]]['data']['tools_drill_offset']) * (-1)
except KeyError:
z_off = 0
else:
@ -3403,8 +3403,8 @@ class CNCjob(Geometry):
# this holds the resulting GCode
self.gcode = []
self.f_plunge = self.app.defaults["excellon_f_plunge"]
self.f_retract = self.app.defaults["excellon_f_retract"]
self.f_plunge = self.app.defaults["tools_drill_f_plunge"]
self.f_retract = self.app.defaults["tools_drill_f_retract"]
# #############################################################################################################
# #############################################################################################################
@ -3488,9 +3488,9 @@ class CNCjob(Geometry):
self.postdata['toolC'] = self.tooldia
if self.use_ui:
self.z_feedrate = self.exc_tools[tool]['data']['feedrate_z']
self.feedrate = self.exc_tools[tool]['data']['feedrate']
self.z_cut = self.exc_tools[tool]['data']['cutz']
self.z_feedrate = self.exc_tools[tool]['data']['tools_drill_feedrate_z']
self.feedrate = self.exc_tools[tool]['data']['tools_drill_feedrate_z']
self.z_cut = self.exc_tools[tool]['data']['tools_drill_cutz']
gcode += self.doformat(p.z_feedrate_code)
if self.machinist_setting == 0:
@ -3513,12 +3513,12 @@ class CNCjob(Geometry):
old_zcut = deepcopy(self.z_cut)
self.z_move = self.exc_tools[tool]['data']['travelz']
self.spindlespeed = self.exc_tools[tool]['data']['spindlespeed']
self.dwell = self.exc_tools[tool]['data']['dwell']
self.dwelltime = self.exc_tools[tool]['data']['dwelltime']
self.multidepth = self.exc_tools[tool]['data']['multidepth']
self.z_depthpercut = self.exc_tools[tool]['data']['depthperpass']
self.z_move = self.exc_tools[tool]['data']['tools_drill_travelz']
self.spindlespeed = self.exc_tools[tool]['data']['tools_drill_spindlespeed']
self.dwell = self.exc_tools[tool]['data']['tools_drill_dwell']
self.dwelltime = self.exc_tools[tool]['data']['tools_drill_dwelltime']
self.multidepth = self.exc_tools[tool]['data']['tools_drill_multidepth']
self.z_depthpercut = self.exc_tools[tool]['data']['tools_drill_depthperpass']
else:
old_zcut = deepcopy(self.z_cut)
@ -3589,7 +3589,7 @@ class CNCjob(Geometry):
# because the values for Z offset are created in build_ui()
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
try:
z_offset = float(self.exc_tools[tool]['data']['offset']) * (-1)
z_offset = float(self.exc_tools[tool]['data']['tools_drill_offset']) * (-1)
except KeyError:
z_offset = 0
self.z_cut = z_offset + old_zcut
@ -3633,7 +3633,7 @@ class CNCjob(Geometry):
gcode += self.doformat(p.lift_code, x=locx, y=locy)
# restore z_move
self.z_move = self.exc_tools[tool]['data']['travelz']
self.z_move = self.exc_tools[tool]['data']['tools_drill_travelz']
else:
if prev_z is not None:
# move to next point
@ -3641,7 +3641,7 @@ class CNCjob(Geometry):
# we assume that previously the z_move was altered therefore raise to
# the travel_z (z_move)
self.z_move = self.exc_tools[tool]['data']['travelz']
self.z_move = self.exc_tools[tool]['data']['tools_drill_travelz']
gcode += self.doformat(p.lift_code, x=locx, y=locy)
else:
# move to next point
@ -3723,9 +3723,9 @@ class CNCjob(Geometry):
self.postdata['toolC'] = self.tooldia
if self.use_ui:
self.z_feedrate = self.exc_tools[one_tool]['data']['feedrate_z']
self.feedrate = self.exc_tools[one_tool]['data']['feedrate']
self.z_cut = self.exc_tools[one_tool]['data']['cutz']
self.z_feedrate = self.exc_tools[one_tool]['data']['tools_drill_feedrate_z']
self.feedrate = self.exc_tools[one_tool]['data']['tools_drill_feedrate_z']
self.z_cut = self.exc_tools[one_tool]['data']['tools_drill_cutz']
gcode += self.doformat(p.z_feedrate_code)
if self.machinist_setting == 0:
@ -3748,12 +3748,12 @@ class CNCjob(Geometry):
old_zcut = deepcopy(self.z_cut)
self.z_move = self.exc_tools[one_tool]['data']['travelz']
self.spindlespeed = self.exc_tools[one_tool]['data']['spindlespeed']
self.dwell = self.exc_tools[one_tool]['data']['dwell']
self.dwelltime = self.exc_tools[one_tool]['data']['dwelltime']
self.multidepth = self.exc_tools[one_tool]['data']['multidepth']
self.z_depthpercut = self.exc_tools[one_tool]['data']['depthperpass']
self.z_move = self.exc_tools[one_tool]['data']['tools_drill_travelz']
self.spindlespeed = self.exc_tools[one_tool]['data']['tools_drill_spindlespeed']
self.dwell = self.exc_tools[one_tool]['data']['tools_drill_dwell']
self.dwelltime = self.exc_tools[one_tool]['data']['tools_drill_dwelltime']
self.multidepth = self.exc_tools[one_tool]['data']['tools_drill_multidepth']
self.z_depthpercut = self.exc_tools[one_tool]['data']['tools_drill_depthperpass']
else:
old_zcut = deepcopy(self.z_cut)
@ -3821,7 +3821,7 @@ class CNCjob(Geometry):
# because the values for Z offset are created in build_ui()
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
try:
z_offset = float(self.exc_tools[one_tool]['data']['offset']) * (-1)
z_offset = float(self.exc_tools[one_tool]['data']['tools_drill_offset']) * (-1)
except KeyError:
z_offset = 0
self.z_cut = z_offset + old_zcut
@ -3865,7 +3865,7 @@ class CNCjob(Geometry):
gcode += self.doformat(p.lift_code, x=locx, y=locy)
# restore z_move
self.z_move = self.exc_tools[one_tool]['data']['travelz']
self.z_move = self.exc_tools[one_tool]['data']['tools_drill_travelz']
else:
if prev_z is not None:
# move to next point
@ -3873,7 +3873,7 @@ class CNCjob(Geometry):
# we assume that previously the z_move was altered therefore raise to
# the travel_z (z_move)
self.z_move = self.exc_tools[one_tool]['data']['travelz']
self.z_move = self.exc_tools[one_tool]['data']['tools_drill_travelz']
gcode += self.doformat(p.lift_code, x=locx, y=locy)
else:
# move to next point

View File

@ -218,36 +218,38 @@ class TclCommandDrillcncjob(TclCommandSignaled):
used_tools_info.append([str(tool_no), str(tool_dia_used), str(drill_cnt), str(slot_cnt)])
drillz = args["drillz"] if "drillz" in args and args["drillz"] is not None else obj.options["cutz"]
drillz = args["drillz"] if "drillz" in args and args["drillz"] is not None else \
obj.options["tools_drill_cutz"]
if "toolchangez" in args:
toolchange = True
if args["toolchangez"] is not None:
toolchangez = args["toolchangez"]
else:
toolchangez = obj.options["toolchangez"]
toolchangez = obj.options["tools_drill_toolchangez"]
else:
toolchange = self.app.defaults["excellon_toolchange"]
toolchangez = float(self.app.defaults["excellon_toolchangez"])
toolchange = self.app.defaults["tools_drill_toolchange"]
toolchangez = float(self.app.defaults["tools_drill_toolchangez"])
if "toolchangexy" in args and args["toolchangexy"]:
if "toolchangexy" in args and args["tools_drill_toolchangexy"]:
xy_toolchange = args["toolchangexy"]
else:
if self.app.defaults["excellon_toolchangexy"]:
xy_toolchange = self.app.defaults["excellon_toolchangexy"]
if self.app.defaults["tools_drill_toolchangexy"]:
xy_toolchange = self.app.defaults["tools_drill_toolchangexy"]
else:
xy_toolchange = '0, 0'
if len(eval(xy_toolchange)) != 2:
self.raise_tcl_error("The entered value for 'toolchangexy' needs to have the format x,y or "
"in format (x, y) - no spaces allowed. But always two comma separated values.")
endz = args["endz"] if "endz" in args and args["endz"] is not None else self.app.defaults["excellon_endz"]
endz = args["endz"] if "endz" in args and args["endz"] is not None else \
self.app.defaults["tools_drill_endz"]
if "endxy" in args and args["endxy"]:
xy_end = args["endxy"]
else:
if self.app.defaults["excellon_endxy"]:
xy_end = self.app.defaults["excellon_endxy"]
if self.app.defaults["tools_drill_endxy"]:
xy_end = self.app.defaults["tools_drill_endxy"]
else:
xy_end = '0, 0'
@ -265,7 +267,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
job_obj.options['Tools_in_use'] = used_tools_info
job_obj.options['type'] = 'Excellon'
pp_excellon_name = args["pp"] if "pp" in args and args["pp"] else self.app.defaults["excellon_ppname_e"]
pp_excellon_name = args["pp"] if "pp" in args and args["pp"] else self.app.defaults["tools_drill_ppname_e"]
job_obj.pp_excellon_name = pp_excellon_name
job_obj.options['ppname_e'] = pp_excellon_name
@ -276,31 +278,32 @@ class TclCommandDrillcncjob(TclCommandSignaled):
else:
job_obj.z_depthpercut = float(obj.options["dpp"])
else:
job_obj.multidepth = self.app.defaults["excellon_multidepth"]
job_obj.z_depthpercut = self.app.defaults["excellon_depthperpass"]
job_obj.multidepth = self.app.defaults["tools_drill_multidepth"]
job_obj.z_depthpercut = self.app.defaults["tools_drill_depthperpass"]
job_obj.z_move = float(args["travelz"]) if "travelz" in args and args["travelz"] else \
self.app.defaults["excellon_travelz"]
self.app.defaults["tools_drill_travelz"]
job_obj.feedrate = float(args["feedrate_z"]) if "feedrate_z" in args and args["feedrate_z"] else \
self.app.defaults["excellon_feedrate_z"]
self.app.defaults["tools_drill_feedrate_z"]
job_obj.z_feedrate = float(args["feedrate_z"]) if "feedrate_z" in args and args["feedrate_z"] else \
self.app.defaults["excellon_feedrate_z"]
self.app.defaults["tools_drill_feedrate_z"]
job_obj.feedrate_rapid = float(args["feedrate_rapid"]) \
if "feedrate_rapid" in args and args["feedrate_rapid"] else self.app.defaults["excellon_feedrate_rapid"]
if "feedrate_rapid" in args and args["feedrate_rapid"] else \
self.app.defaults["tools_drill_feedrate_rapid"]
job_obj.spindlespeed = float(args["spindlespeed"]) if "spindlespeed" in args else None
job_obj.spindledir = self.app.defaults['excellon_spindledir']
job_obj.spindledir = self.app.defaults['tools_drill_spindlespeed']
if 'dwelltime' in args:
job_obj.dwell = True
if args['dwelltime'] is not None:
job_obj.dwelltime = float(args['dwelltime'])
else:
job_obj.dwelltime = float(self.app.defaults["excellon_dwelltime"])
job_obj.dwelltime = float(self.app.defaults["tools_drill_dwelltime"])
else:
job_obj.dwell = self.app.defaults["excellon_dwell"]
job_obj.dwelltime = self.app.defaults["excellon_dwelltime"]
job_obj.dwell = self.app.defaults["tools_drill_dwell"]
job_obj.dwelltime = self.app.defaults["tools_drill_dwelltime"]
job_obj.toolchange_xy_type = "excellon"
job_obj.coords_decimals = int(self.app.defaults["cncjob_coords_decimals"])
@ -320,7 +323,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
job_obj.startz = float(args["startz"])
else:
if self.app.defaults["excellon_startz"]:
job_obj.startz = self.app.defaults["excellon_startz"]
job_obj.startz = self.app.defaults["tools_drill_startz"]
else:
job_obj.startz = (0, 0)
@ -335,7 +338,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
for t_item in job_obj.exc_cnc_tools:
job_obj.exc_cnc_tools[t_item]['data']['offset'] = \
float(job_obj.exc_cnc_tools[t_item]['offset_z']) + float(drillz)
float(job_obj.exc_cnc_tools[t_item]['offset']) + float(drillz)
job_obj.exc_cnc_tools[t_item]['data']['ppname_e'] = obj.options['ppname_e']
job_obj.gcode_parse()