- modified the MillDrills and MillSlots TclCommands to accept as parameter a list of tool dimaeters to be milled instead of tool indexes
This commit is contained in:
@@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing.
|
|||||||
- updated code in self.on_view_source() to make it more responsive
|
- updated code in self.on_view_source() to make it more responsive
|
||||||
- fixed the TclCommand MillHoles
|
- fixed the TclCommand MillHoles
|
||||||
- changed the name of TclCommand MillHoles to MillDrills and added a new TclCommand named MillSlots
|
- changed the name of TclCommand MillHoles to MillDrills and added a new TclCommand named MillSlots
|
||||||
|
- modified the MillDrills and MillSlots TclCommands to accept as parameter a list of tool dimaeters to be milled instead of tool indexes
|
||||||
|
|
||||||
10.09.2019
|
10.09.2019
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class TclCommandMillDrills(TclCommandSignaled):
|
|||||||
# Dictionary of types from Tcl command, needs to be ordered.
|
# Dictionary of types from Tcl command, needs to be ordered.
|
||||||
# This is for options like -optionname value
|
# This is for options like -optionname value
|
||||||
option_types = collections.OrderedDict([
|
option_types = collections.OrderedDict([
|
||||||
('tools', str),
|
('milled_dias', str),
|
||||||
('outname', str),
|
('outname', str),
|
||||||
('tooldia', float),
|
('tooldia', float),
|
||||||
('use_threads', bool)
|
('use_threads', bool)
|
||||||
@@ -35,12 +35,12 @@ class TclCommandMillDrills(TclCommandSignaled):
|
|||||||
'main': "Create Geometry Object for milling drill holes from Excellon.",
|
'main': "Create Geometry Object for milling drill holes from Excellon.",
|
||||||
'args': collections.OrderedDict([
|
'args': collections.OrderedDict([
|
||||||
('name', 'Name of the Excellon Object.'),
|
('name', 'Name of the Excellon Object.'),
|
||||||
('tools', 'Comma separated indexes of tools (example: 1,3 or 2).'),
|
('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).'),
|
('tooldia', 'Diameter of the milling tool (example: 0.1).'),
|
||||||
('outname', 'Name of object to create.'),
|
('outname', 'Name of object to create.'),
|
||||||
('use_thread', 'If to use multithreading: True or False.')
|
('use_thread', 'If to use multithreading: True or False.')
|
||||||
]),
|
]),
|
||||||
'examples': ['millholes mydrills']
|
'examples': ['milldrills mydrills']
|
||||||
}
|
}
|
||||||
|
|
||||||
def execute(self, args, unnamed_args):
|
def execute(self, args, unnamed_args):
|
||||||
@@ -55,22 +55,38 @@ class TclCommandMillDrills(TclCommandSignaled):
|
|||||||
name = args['name']
|
name = args['name']
|
||||||
|
|
||||||
if 'outname' not in args:
|
if 'outname' not in args:
|
||||||
args['outname'] = name + "_mill"
|
args['outname'] = name + "_mill_drills"
|
||||||
|
|
||||||
try:
|
|
||||||
if 'tools' in args and args['tools'] != 'all':
|
|
||||||
# Split and put back. We are passing the whole dictionary later.
|
|
||||||
args['tools'] = [x.strip() for x in args['tools'].split(",")]
|
|
||||||
else:
|
|
||||||
args['tools'] = 'all'
|
|
||||||
except Exception as e:
|
|
||||||
self.raise_tcl_error("Bad tools: %s" % str(e))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj = self.app.collection.get_by_name(str(name))
|
obj = self.app.collection.get_by_name(str(name))
|
||||||
except:
|
except:
|
||||||
|
obj = None
|
||||||
self.raise_tcl_error("Could not retrieve object: %s" % name)
|
self.raise_tcl_error("Could not retrieve object: %s" % name)
|
||||||
|
|
||||||
|
if not obj.drills:
|
||||||
|
self.raise_tcl_error("The Excellon object has no drills: %s" % name)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if 'milled_dias' in args and args['milled_dias'] != 'all':
|
||||||
|
diameters = [x.strip() for x in args['tools'].split(",")]
|
||||||
|
req_tools = []
|
||||||
|
for tool in obj.tools:
|
||||||
|
for req_dia in diameters:
|
||||||
|
if float('%.4f' % float(obj.tools[tool]["C"])) == float('%.4f' % float(req_dia)):
|
||||||
|
req_tools.append(tool)
|
||||||
|
|
||||||
|
args['tools'] = req_tools
|
||||||
|
|
||||||
|
# no longer needed
|
||||||
|
del args['milled_dias']
|
||||||
|
|
||||||
|
# Split and put back. We are passing the whole dictionary later.
|
||||||
|
# args['milled_dias'] = [x.strip() for x in args['tools'].split(",")]
|
||||||
|
else:
|
||||||
|
args['tools'] = 'all'
|
||||||
|
except Exception as e:
|
||||||
|
self.raise_tcl_error("Bad tools: %s" % str(e))
|
||||||
|
|
||||||
if not isinstance(obj, FlatCAMExcellon):
|
if not isinstance(obj, FlatCAMExcellon):
|
||||||
self.raise_tcl_error('Only Excellon objects can be mill-drilled, got %s %s.' % (name, type(obj)))
|
self.raise_tcl_error('Only Excellon objects can be mill-drilled, got %s %s.' % (name, type(obj)))
|
||||||
|
|
||||||
@@ -83,8 +99,9 @@ class TclCommandMillDrills(TclCommandSignaled):
|
|||||||
|
|
||||||
# This runs in the background... Is blocking handled?
|
# This runs in the background... Is blocking handled?
|
||||||
success, msg = obj.generate_milling_drills(**args)
|
success, msg = obj.generate_milling_drills(**args)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
success = None
|
||||||
|
msg = None
|
||||||
self.raise_tcl_error("Operation failed: %s" % str(e))
|
self.raise_tcl_error("Operation failed: %s" % str(e))
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class TclCommandMillSlots(TclCommandSignaled):
|
|||||||
# Dictionary of types from Tcl command, needs to be ordered.
|
# Dictionary of types from Tcl command, needs to be ordered.
|
||||||
# This is for options like -optionname value
|
# This is for options like -optionname value
|
||||||
option_types = collections.OrderedDict([
|
option_types = collections.OrderedDict([
|
||||||
('tools', str),
|
('milled_dias', str),
|
||||||
('outname', str),
|
('outname', str),
|
||||||
('tooldia', float),
|
('tooldia', float),
|
||||||
('use_threads', bool)
|
('use_threads', bool)
|
||||||
@@ -35,7 +35,7 @@ class TclCommandMillSlots(TclCommandSignaled):
|
|||||||
'main': "Create Geometry Object for milling slot holes from Excellon.",
|
'main': "Create Geometry Object for milling slot holes from Excellon.",
|
||||||
'args': collections.OrderedDict([
|
'args': collections.OrderedDict([
|
||||||
('name', 'Name of the Excellon Object.'),
|
('name', 'Name of the Excellon Object.'),
|
||||||
('tools', 'Comma separated indexes of tools (example: 1,3 or 2).'),
|
('milled_dias', 'Comma separated tool diameters of the slots to be milled (example: 0.6, 1.0 or 3.125).'),
|
||||||
('tooldia', 'Diameter of the milling tool (example: 0.1).'),
|
('tooldia', 'Diameter of the milling tool (example: 0.1).'),
|
||||||
('outname', 'Name of object to create.'),
|
('outname', 'Name of object to create.'),
|
||||||
('use_thread', 'If to use multithreading: True or False.')
|
('use_thread', 'If to use multithreading: True or False.')
|
||||||
@@ -58,21 +58,37 @@ class TclCommandMillSlots(TclCommandSignaled):
|
|||||||
args['outname'] = name + "_mill"
|
args['outname'] = name + "_mill"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if 'tools' in args and args['tools'] != 'all':
|
obj = self.app.collection.get_by_name(str(name))
|
||||||
|
except:
|
||||||
|
obj = None
|
||||||
|
self.raise_tcl_error("Could not retrieve object: %s" % name)
|
||||||
|
|
||||||
|
if not obj.slots:
|
||||||
|
self.raise_tcl_error("The Excellon object has no slots: %s" % name)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if 'milled_dias' in args and args['milled_dias'] != 'all':
|
||||||
|
diameters = [x.strip() for x in args['tools'].split(",")]
|
||||||
|
req_tools = []
|
||||||
|
for tool in obj.tools:
|
||||||
|
for req_dia in diameters:
|
||||||
|
if float('%.4f' % float(obj.tools[tool]["C"])) == float('%.4f' % float(req_dia)):
|
||||||
|
req_tools.append(tool)
|
||||||
|
|
||||||
|
args['tools'] = req_tools
|
||||||
|
|
||||||
|
# no longer needed
|
||||||
|
del args['milled_dias']
|
||||||
|
|
||||||
# Split and put back. We are passing the whole dictionary later.
|
# Split and put back. We are passing the whole dictionary later.
|
||||||
args['tools'] = [x.strip() for x in args['tools'].split(",")]
|
# args['milled_dias'] = [x.strip() for x in args['tools'].split(",")]
|
||||||
else:
|
else:
|
||||||
args['tools'] = 'all'
|
args['tools'] = 'all'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.raise_tcl_error("Bad tools: %s" % str(e))
|
self.raise_tcl_error("Bad tools: %s" % str(e))
|
||||||
|
|
||||||
try:
|
|
||||||
obj = self.app.collection.get_by_name(str(name))
|
|
||||||
except:
|
|
||||||
self.raise_tcl_error("Could not retrieve object: %s" % name)
|
|
||||||
|
|
||||||
if not isinstance(obj, FlatCAMExcellon):
|
if not isinstance(obj, FlatCAMExcellon):
|
||||||
self.raise_tcl_error('Only Excellon objects can be mill-drilled, got %s %s.' % (name, type(obj)))
|
self.raise_tcl_error('Only Excellon objects can have mill-slots, got %s %s.' % (name, type(obj)))
|
||||||
|
|
||||||
if self.app.collection.has_promises():
|
if self.app.collection.has_promises():
|
||||||
self.raise_tcl_error('!!!Promises exists, but should not here!!!')
|
self.raise_tcl_error('!!!Promises exists, but should not here!!!')
|
||||||
@@ -85,6 +101,8 @@ class TclCommandMillSlots(TclCommandSignaled):
|
|||||||
success, msg = obj.generate_milling_slots(**args)
|
success, msg = obj.generate_milling_slots(**args)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
success = None
|
||||||
|
msg = None
|
||||||
self.raise_tcl_error("Operation failed: %s" % str(e))
|
self.raise_tcl_error("Operation failed: %s" % str(e))
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
|
|||||||
Reference in New Issue
Block a user