Merged in marius_stanciu/flatcam_beta/Beta (pull request #207)

Beta - enhancements
This commit is contained in:
Marius Stanciu 2019-09-16 01:26:21 +00:00
commit 52c4a90b90
5 changed files with 58 additions and 16 deletions

View File

@ -8240,7 +8240,10 @@ class App(QtCore.QObject):
# then append the text from GCode to the text editor
if obj.kind == 'cncjob':
try:
file = obj.export_gcode(preamble='', postamble='', to_file=True)
file = obj.export_gcode(
preamble=self.defaults["cncjob_prepend"],
postamble=self.defaults["cncjob_append"],
to_file=True)
if file == 'fail':
return 'fail'
except AttributeError:

View File

@ -12,6 +12,8 @@ CAD program, and create G-Code for Isolation routing.
16.09.2019
- 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
- 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

View File

@ -42,6 +42,7 @@ class TclCommandCncjob(TclCommandSignaled):
('dwell', bool),
('dwelltime', float),
('pp', str),
('muted', int),
('outname', str)
])
@ -71,7 +72,8 @@ class TclCommandCncjob(TclCommandSignaled):
('dwell', 'True or False; use (or not) the dwell'),
('dwelltime', 'Time to pause to allow the spindle to reach the full speed'),
('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']
}
@ -91,13 +93,22 @@ class TclCommandCncjob(TclCommandSignaled):
if 'outname' not in args:
args['outname'] = str(name) + "_cnc"
if 'muted' in args:
muted = args['muted']
obj = self.app.collection.get_by_name(str(name), isCaseSensitive=False)
if obj is None:
self.raise_tcl_error("Object not found: %s" % str(name))
if not muted:
self.raise_tcl_error("Object not found: %s" % str(name))
else:
return
if not isinstance(obj, FlatCAMGeometry):
self.raise_tcl_error('Expected FlatCAMGeometry, got %s %s.' % (str(name), type(obj)))
if not muted:
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"]
@ -134,9 +145,12 @@ class TclCommandCncjob(TclCommandSignaled):
continue
else:
if args[arg] is None:
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'
'generated by the TclCommand "list_sys geom". or in the arguments.')
if not muted:
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'
'generated by the TclCommand "list_sys geom". or in the arguments.')
else:
return
# HACK !!! Should be solved elsewhere!!!
# default option for multidepth is False

View File

@ -31,7 +31,8 @@ class TclCommandDrillcncjob(TclCommandSignaled):
('pp', str),
('outname', str),
('opt_type', str),
('diatol', float)
('diatol', float),
('muted', int)
])
# 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 '
'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) '
'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'
' -toolchange True -toolchangez 33 -endz 22 -pp default\n'
@ -84,12 +86,18 @@ class TclCommandDrillcncjob(TclCommandSignaled):
if 'outname' not in args:
args['outname'] = name + "_cnc"
if 'muted' in args:
muted = args['muted']
obj = self.app.collection.get_by_name(name)
if obj is None:
self.raise_tcl_error("Object not found: %s" % name)
if not isinstance(obj, FlatCAMExcellon):
self.raise_tcl_error('Expected FlatCAMExcellon, got %s %s.' % (name, type(obj)))
if not muted:
self.raise_tcl_error('Expected FlatCAMExcellon, got %s %s.' % (name, type(obj)))
else:
return
xmin = obj.options['xmin']
ymin = obj.options['ymin']
@ -127,8 +135,11 @@ class TclCommandDrillcncjob(TclCommandSignaled):
nr_diameters -= 1
if nr_diameters > 0:
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.")
if not muted:
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.")
else:
return
# make a string of diameters separated by comma; this is what generate_from_excellon_by_tool() is
# expecting as tools parameter

View File

@ -22,7 +22,8 @@ class TclCommandWriteGCode(TclCommandSignaled):
# For options like -optionname value
option_types = collections.OrderedDict([
('preamble', str),
('postamble', str)
('postamble', str),
('muted', int)
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
@ -35,7 +36,9 @@ class TclCommandWriteGCode(TclCommandSignaled):
('name', 'Source CNC Job object.'),
('filename', 'Output filename.'),
('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"]
}
@ -62,6 +65,9 @@ class TclCommandWriteGCode(TclCommandSignaled):
preamble = args['preamble'] if 'preamble' 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.
# If there are promised objects, wait until all promises have been fulfilled.
# if self.collection.has_promises():
@ -82,9 +88,15 @@ class TclCommandWriteGCode(TclCommandSignaled):
try:
obj = self.app.collection.get_by_name(str(obj_name))
except:
return "Could not retrieve object: %s" % obj_name
if not muted:
return "Could not retrieve object: %s" % obj_name
else:
return
try:
obj.export_gcode(str(filename), str(preamble), str(postamble))
except Exception as e:
return "Operation failed: %s" % str(e)
if not muted:
return "Operation failed: %s" % str(e)
else:
return