- added a new parameter named 'muted' for the TclCommands: cncjob, drillcncjob and write_gcode. Setting it as -muted 1 will disable the error reporting in TCL Shell
This commit is contained in:
@@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing.
|
|||||||
|
|
||||||
- modified the TclCommand New so it will no longer close all tabs when called (it closed the Code Editor tab which may have been holding the code that run)
|
- modified the TclCommand New so it will no longer close all tabs when called (it closed the Code Editor tab which may have been holding the code that run)
|
||||||
- fixed the App.on_view_source() method for CNCJob objects: the Gcode will now contain the Prepend and Append code from the Edit -> Preferences -> CNCJob -> CNCJob Options
|
- fixed the App.on_view_source() method for CNCJob objects: the Gcode will now contain the Prepend and Append code from the Edit -> Preferences -> CNCJob -> CNCJob Options
|
||||||
|
- added a new parameter named 'muted' for the TclCommands: cncjob, drillcncjob and write_gcode. Setting it as -muted 1 will disable the error reporting in TCL Shell
|
||||||
|
|
||||||
15.09.2019
|
15.09.2019
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class TclCommandCncjob(TclCommandSignaled):
|
|||||||
('dwell', bool),
|
('dwell', bool),
|
||||||
('dwelltime', float),
|
('dwelltime', float),
|
||||||
('pp', str),
|
('pp', str),
|
||||||
|
('muted', int),
|
||||||
('outname', str)
|
('outname', str)
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -71,7 +72,8 @@ class TclCommandCncjob(TclCommandSignaled):
|
|||||||
('dwell', 'True or False; use (or not) the dwell'),
|
('dwell', 'True or False; use (or not) the dwell'),
|
||||||
('dwelltime', 'Time to pause to allow the spindle to reach the full speed'),
|
('dwelltime', 'Time to pause to allow the spindle to reach the full speed'),
|
||||||
('outname', 'Name of the resulting Geometry object.'),
|
('outname', 'Name of the resulting Geometry object.'),
|
||||||
('pp', 'Name of the Geometry postprocessor. No quotes, case sensitive')
|
('pp', 'Name of the Geometry postprocessor. No quotes, case sensitive'),
|
||||||
|
('muted', 'It will not put errors in the Shell.')
|
||||||
]),
|
]),
|
||||||
'examples': ['cncjob geo_name -tooldia 0.5 -z_cut -1.7 -z_move 2 -feedrate 120 -ppname_g default']
|
'examples': ['cncjob geo_name -tooldia 0.5 -z_cut -1.7 -z_move 2 -feedrate 120 -ppname_g default']
|
||||||
}
|
}
|
||||||
@@ -91,13 +93,22 @@ class TclCommandCncjob(TclCommandSignaled):
|
|||||||
if 'outname' not in args:
|
if 'outname' not in args:
|
||||||
args['outname'] = str(name) + "_cnc"
|
args['outname'] = str(name) + "_cnc"
|
||||||
|
|
||||||
|
if 'muted' in args:
|
||||||
|
muted = args['muted']
|
||||||
|
|
||||||
obj = self.app.collection.get_by_name(str(name), isCaseSensitive=False)
|
obj = self.app.collection.get_by_name(str(name), isCaseSensitive=False)
|
||||||
|
|
||||||
if obj is None:
|
if obj is None:
|
||||||
|
if not muted:
|
||||||
self.raise_tcl_error("Object not found: %s" % str(name))
|
self.raise_tcl_error("Object not found: %s" % str(name))
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
if not isinstance(obj, FlatCAMGeometry):
|
if not isinstance(obj, FlatCAMGeometry):
|
||||||
|
if not muted:
|
||||||
self.raise_tcl_error('Expected FlatCAMGeometry, got %s %s.' % (str(name), type(obj)))
|
self.raise_tcl_error('Expected FlatCAMGeometry, got %s %s.' % (str(name), type(obj)))
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
args["tooldia"] = args["tooldia"] if "tooldia" in args else obj.options["cnctooldia"]
|
args["tooldia"] = args["tooldia"] if "tooldia" in args else obj.options["cnctooldia"]
|
||||||
|
|
||||||
@@ -134,9 +145,12 @@ class TclCommandCncjob(TclCommandSignaled):
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if args[arg] is None:
|
if args[arg] is None:
|
||||||
|
if not muted:
|
||||||
self.raise_tcl_error('One of the command parameters that have to be not None, is None.\n'
|
self.raise_tcl_error('One of the command parameters that have to be not None, is None.\n'
|
||||||
'The parameter that is None is in the default values found in the list \n'
|
'The parameter that is None is in the default values found in the list \n'
|
||||||
'generated by the TclCommand "list_sys geom". or in the arguments.')
|
'generated by the TclCommand "list_sys geom". or in the arguments.')
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
# HACK !!! Should be solved elsewhere!!!
|
# HACK !!! Should be solved elsewhere!!!
|
||||||
# default option for multidepth is False
|
# default option for multidepth is False
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ class TclCommandDrillcncjob(TclCommandSignaled):
|
|||||||
('pp', str),
|
('pp', str),
|
||||||
('outname', str),
|
('outname', str),
|
||||||
('opt_type', str),
|
('opt_type', str),
|
||||||
('diatol', float)
|
('diatol', float),
|
||||||
|
('muted', int)
|
||||||
])
|
])
|
||||||
|
|
||||||
# array of mandatory options for current Tcl command: required = {'name','outname'}
|
# array of mandatory options for current Tcl command: required = {'name','outname'}
|
||||||
@@ -62,7 +63,8 @@ class TclCommandDrillcncjob(TclCommandSignaled):
|
|||||||
'the same as the ones in the tools from the Excellon object. E.g: if in drill_dias we have a '
|
'the same as the ones in the tools from the Excellon object. E.g: if in drill_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 '
|
'diameter with value 1.0, in the Excellon we have a tool with dia = 1.05 and we set a tolerance '
|
||||||
'diatol = 5.0 then the drills with the dia = (0.95 ... 1.05) '
|
'diatol = 5.0 then the drills with the dia = (0.95 ... 1.05) '
|
||||||
'in Excellon will be processed. Float number.')
|
'in Excellon will be processed. Float number.'),
|
||||||
|
('muted', 'It will not put errors in the Shell or status bar.')
|
||||||
]),
|
]),
|
||||||
'examples': ['drillcncjob test.TXT -drillz -1.5 -travelz 14 -feedrate 222 -feedrate_rapid 456 -spindlespeed 777'
|
'examples': ['drillcncjob test.TXT -drillz -1.5 -travelz 14 -feedrate 222 -feedrate_rapid 456 -spindlespeed 777'
|
||||||
' -toolchange True -toolchangez 33 -endz 22 -pp default\n'
|
' -toolchange True -toolchangez 33 -endz 22 -pp default\n'
|
||||||
@@ -84,12 +86,18 @@ class TclCommandDrillcncjob(TclCommandSignaled):
|
|||||||
if 'outname' not in args:
|
if 'outname' not in args:
|
||||||
args['outname'] = name + "_cnc"
|
args['outname'] = name + "_cnc"
|
||||||
|
|
||||||
|
if 'muted' in args:
|
||||||
|
muted = args['muted']
|
||||||
|
|
||||||
obj = self.app.collection.get_by_name(name)
|
obj = self.app.collection.get_by_name(name)
|
||||||
if obj is None:
|
if obj is None:
|
||||||
self.raise_tcl_error("Object not found: %s" % name)
|
self.raise_tcl_error("Object not found: %s" % name)
|
||||||
|
|
||||||
if not isinstance(obj, FlatCAMExcellon):
|
if not isinstance(obj, FlatCAMExcellon):
|
||||||
|
if not muted:
|
||||||
self.raise_tcl_error('Expected FlatCAMExcellon, got %s %s.' % (name, type(obj)))
|
self.raise_tcl_error('Expected FlatCAMExcellon, got %s %s.' % (name, type(obj)))
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
xmin = obj.options['xmin']
|
xmin = obj.options['xmin']
|
||||||
ymin = obj.options['ymin']
|
ymin = obj.options['ymin']
|
||||||
@@ -127,8 +135,11 @@ class TclCommandDrillcncjob(TclCommandSignaled):
|
|||||||
nr_diameters -= 1
|
nr_diameters -= 1
|
||||||
|
|
||||||
if nr_diameters > 0:
|
if nr_diameters > 0:
|
||||||
|
if not muted:
|
||||||
self.raise_tcl_error("One or more tool diameters of the drills to be drilled passed to the "
|
self.raise_tcl_error("One or more tool diameters of the drills to be drilled passed to the "
|
||||||
"TclCommand are not actual tool diameters in the Excellon object.")
|
"TclCommand are not actual tool diameters in the Excellon object.")
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
# make a string of diameters separated by comma; this is what generate_from_excellon_by_tool() is
|
# make a string of diameters separated by comma; this is what generate_from_excellon_by_tool() is
|
||||||
# expecting as tools parameter
|
# expecting as tools parameter
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ class TclCommandWriteGCode(TclCommandSignaled):
|
|||||||
# For options like -optionname value
|
# For options like -optionname value
|
||||||
option_types = collections.OrderedDict([
|
option_types = collections.OrderedDict([
|
||||||
('preamble', str),
|
('preamble', str),
|
||||||
('postamble', str)
|
('postamble', str),
|
||||||
|
('muted', int)
|
||||||
])
|
])
|
||||||
|
|
||||||
# array of mandatory options for current Tcl command: required = {'name','outname'}
|
# array of mandatory options for current Tcl command: required = {'name','outname'}
|
||||||
@@ -35,7 +36,9 @@ class TclCommandWriteGCode(TclCommandSignaled):
|
|||||||
('name', 'Source CNC Job object.'),
|
('name', 'Source CNC Job object.'),
|
||||||
('filename', 'Output filename.'),
|
('filename', 'Output filename.'),
|
||||||
('preamble', 'Text to append at the beginning.'),
|
('preamble', 'Text to append at the beginning.'),
|
||||||
('postamble', 'Text to append at the end.')
|
('postamble', 'Text to append at the end.'),
|
||||||
|
('muted', 'It will not put errors in the Shell or status bar.')
|
||||||
|
|
||||||
]),
|
]),
|
||||||
'examples': ["write_gcode name c:\\\\gcode_repo"]
|
'examples': ["write_gcode name c:\\\\gcode_repo"]
|
||||||
}
|
}
|
||||||
@@ -62,6 +65,9 @@ class TclCommandWriteGCode(TclCommandSignaled):
|
|||||||
preamble = args['preamble'] if 'preamble' in args else ''
|
preamble = args['preamble'] if 'preamble' in args else ''
|
||||||
postamble = args['postamble'] if 'postamble' in args else ''
|
postamble = args['postamble'] if 'postamble' in args else ''
|
||||||
|
|
||||||
|
if 'muted' in args:
|
||||||
|
muted = args['muted']
|
||||||
|
|
||||||
# TODO: This is not needed any more? All targets should be present.
|
# TODO: This is not needed any more? All targets should be present.
|
||||||
# If there are promised objects, wait until all promises have been fulfilled.
|
# If there are promised objects, wait until all promises have been fulfilled.
|
||||||
# if self.collection.has_promises():
|
# if self.collection.has_promises():
|
||||||
@@ -82,9 +88,15 @@ class TclCommandWriteGCode(TclCommandSignaled):
|
|||||||
try:
|
try:
|
||||||
obj = self.app.collection.get_by_name(str(obj_name))
|
obj = self.app.collection.get_by_name(str(obj_name))
|
||||||
except:
|
except:
|
||||||
|
if not muted:
|
||||||
return "Could not retrieve object: %s" % obj_name
|
return "Could not retrieve object: %s" % obj_name
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj.export_gcode(str(filename), str(preamble), str(postamble))
|
obj.export_gcode(str(filename), str(preamble), str(postamble))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if not muted:
|
||||||
return "Operation failed: %s" % str(e)
|
return "Operation failed: %s" % str(e)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user