- added a new parameter in the TclCommands: DrillCNCJob, MillDrills, MillSlots named tol (from tolerance). If the diameters of the milled (drilled) dias are within the tolerance specified of the diameters in the Excellon object than those diameters will be processed. This is to help account for rounding errors when having units conversion

This commit is contained in:
Marius Stanciu
2019-09-12 02:07:32 +03:00
committed by Marius
parent 579cf9f620
commit 8e2cca827a
4 changed files with 63 additions and 20 deletions

View File

@@ -24,7 +24,8 @@ class TclCommandMillDrills(TclCommandSignaled):
('milled_dias', str),
('outname', str),
('tooldia', float),
('use_threads', bool)
('use_threads', bool),
('tol', float)
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
@@ -38,7 +39,11 @@ class TclCommandMillDrills(TclCommandSignaled):
('milled_dias', 'Comma separated tool diameters of the drills to be milled (example: 0.6, 1.0 or 3.125).'),
('tooldia', 'Diameter of the milling tool (example: 0.1).'),
('outname', 'Name of object to create.'),
('use_thread', 'If to use multithreading: True or False.')
('use_thread', 'If to use multithreading: True or False.'),
('tol', 'Tolerance. Percentange (0.0 ... 100.0) within which dias in milled_dias will be judged to be the'
'same as the ones in the tools from the Excellon object. E.g: if in milled_dias we have a diameter'
'with value 1.0, in the Excellon we have a tool with dia = 1.05 and we set a tolerance tol = 5.0'
'then the drills with the dia 1.05 in Excellon will be processed. Float number.')
]),
'examples': ['milldrills mydrills']
}
@@ -73,7 +78,7 @@ class TclCommandMillDrills(TclCommandSignaled):
diameters = [x.strip() for x in args['milled_dias'].split(",") if x != '']
nr_diameters = len(diameters)
req_tools = []
req_tools = set()
for tool in obj.tools:
for req_dia in diameters:
obj_dia_form = float('%.2f' % float(obj.tools[tool]["C"])) if units == 'MM' else \
@@ -81,9 +86,18 @@ class TclCommandMillDrills(TclCommandSignaled):
req_dia_form = float('%.2f' % float(req_dia)) if units == 'MM' else \
float('%.4f' % float(req_dia))
if obj_dia_form == req_dia_form:
req_tools.append(tool)
nr_diameters -= 1
if 'tol' in args:
tolerance = args['tol'] / 100
tolerance = 0.0 if tolerance < 0.0 else tolerance
tolerance = 1.0 if tolerance > 1.0 else tolerance
if math.isclose(obj_dia_form, req_dia_form, rel_tol=tolerance):
req_tools.add(tool)
nr_diameters -= 1
else:
if obj_dia_form == req_dia_form:
req_tools.add(tool)
nr_diameters -= 1
if nr_diameters > 0:
self.raise_tcl_error("One or more tool diameters of the drills to be milled passed to the "