- added protection against creating CNCJob from an empty Geometry object (with no geometry inside)
- changed the shortcut key for YouTube channel from F2 to key F4 - changed the way APP LEVEL is showed both in Edit -> Preferences -> General tab and in each Selected Tab. Changed the ToolTips content for this. - added the functions for GCode View and GCode Save in Tool SolderPaste
This commit is contained in:
@@ -854,18 +854,24 @@ class ToolSolderPaste(FlatCAMTool):
|
||||
# self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab)
|
||||
|
||||
def on_view_gcode(self):
|
||||
name = self.obj_combo.currentText()
|
||||
# add the tab if it was closed
|
||||
self.app.ui.plot_tab_area.addTab(self.app.ui.cncjob_tab, "Code Editor")
|
||||
|
||||
# Switch plot_area to CNCJob tab
|
||||
self.app.ui.plot_tab_area.setCurrentWidget(self.app.ui.cncjob_tab)
|
||||
|
||||
name = self.cnc_obj_combo.currentText()
|
||||
obj = self.app.collection.get_by_name(name)
|
||||
|
||||
# then append the text from GCode to the text editor
|
||||
try:
|
||||
file = StringIO(obj.gcode)
|
||||
except:
|
||||
pass
|
||||
self.app.inform.emit("[ERROR_NOTCL] No Gcode in the object...")
|
||||
return
|
||||
|
||||
try:
|
||||
for line in file:
|
||||
print(line)
|
||||
proc_line = str(line).strip('\n')
|
||||
self.app.ui.code_editor.append(proc_line)
|
||||
except Exception as e:
|
||||
@@ -879,14 +885,54 @@ class ToolSolderPaste(FlatCAMTool):
|
||||
self.app.ui.show()
|
||||
|
||||
def on_save_gcode(self):
|
||||
name = self.obj_combo.currentText()
|
||||
time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
|
||||
name = self.cnc_obj_combo.currentText()
|
||||
obj = self.app.collection.get_by_name(name)
|
||||
|
||||
def geo_init(geo_obj, app_obj):
|
||||
pass
|
||||
_filter_ = "G-Code Files (*.nc);;G-Code Files (*.txt);;G-Code Files (*.tap);;G-Code Files (*.cnc);;" \
|
||||
"G-Code Files (*.g-code);;All Files (*.*)"
|
||||
|
||||
# self.app.new_object("geometry", name + "_cutout", geo_init)
|
||||
# self.app.inform.emit("[success] Rectangular CutOut operation finished.")
|
||||
# self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab)
|
||||
try:
|
||||
dir_file_to_save = self.app.get_last_save_folder() + '/' + str(name)
|
||||
filename, _ = QtWidgets.QFileDialog.getSaveFileName(
|
||||
caption="Export GCode ...",
|
||||
directory=dir_file_to_save,
|
||||
filter=_filter_
|
||||
)
|
||||
except TypeError:
|
||||
filename, _ = QtWidgets.QFileDialog.getSaveFileName(caption="Export Machine Code ...", filter=_filter_)
|
||||
|
||||
if filename == '':
|
||||
self.app.inform.emit("[WARNING_NOTCL]Export Machine Code cancelled ...")
|
||||
return
|
||||
|
||||
gcode = '(G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s)\n' % \
|
||||
(str(self.app.version), str(self.app.version_date)) + '\n'
|
||||
|
||||
gcode += '(Name: ' + str(name) + ')\n'
|
||||
gcode += '(Type: ' + "G-code from " + str(obj.options['type']) + " for Solder Paste dispenser" + ')\n'
|
||||
|
||||
# if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry':
|
||||
# gcode += '(Tools in use: ' + str(p['options']['Tools_in_use']) + ')\n'
|
||||
|
||||
gcode += '(Units: ' + self.units.upper() + ')\n' + "\n"
|
||||
gcode += '(Created on ' + time_str + ')\n' + '\n'
|
||||
|
||||
gcode += obj.gcode
|
||||
lines = StringIO(gcode)
|
||||
|
||||
## Write
|
||||
if filename is not None:
|
||||
try:
|
||||
with open(filename, 'w') as f:
|
||||
for line in lines:
|
||||
f.write(line)
|
||||
except FileNotFoundError:
|
||||
self.app.inform.emit("[WARNING_NOTCL] No such file or directory")
|
||||
return
|
||||
|
||||
self.app.file_saved.emit("gcode", filename)
|
||||
self.app.inform.emit("[success] Solder paste dispenser GCode file saved to: %s" % filename)
|
||||
|
||||
def on_create_gcode(self, use_thread=True):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user