diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 606894e2..0d820b21 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -8217,20 +8217,34 @@ class App(QtCore.QObject): if obj.kind == 'gerber': flt = "Gerber Files (*.GBR);;All Files (*.*)" - else: + elif obj.kind == 'excellon': flt = "Excellon Files (*.DRL);;All Files (*.*)" + elif obj.kind == 'cncjob': + "GCode Files (*.NC);;All Files (*.*)" + else: + flt = "All Files (*.*)" self.init_code_editor(name=_("Source Editor")) self.ui.buttonOpen.clicked.connect(lambda: self.handleOpen(filt=flt)) self.ui.buttonSave.clicked.connect(lambda: self.handleSaveGCode(filt=flt)) # then append the text from GCode to the text editor - try: - file = StringIO(obj.source_file) - except AttributeError: - self.inform.emit('[WARNING_NOTCL] %s' % - _("There is no selected object for which to see it's source file code.")) - return 'fail' + if obj.kind == 'cncjob': + try: + file = obj.export_gcode(preamble='', postamble='', to_file=True) + if file == 'fail': + return 'fail' + except AttributeError: + self.inform.emit('[WARNING_NOTCL] %s' % + _("There is no selected object for which to see it's source file code.")) + return 'fail' + else: + try: + file = StringIO(obj.source_file) + except AttributeError: + self.inform.emit('[WARNING_NOTCL] %s' % + _("There is no selected object for which to see it's source file code.")) + return 'fail' self.ui.cncjob_frame.hide() try: diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 589f74e0..d1b8373f 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -5842,11 +5842,12 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): preamble = str(self.ui.prepend_text.get_value()) postamble = str(self.ui.append_text.get_value()) - gc = self.export_gcode(preamble=preamble, postamble=postamble, to_file=True) - if gc == 'fail': + + gco = self.export_gcode(preamble=preamble, postamble=postamble, to_file=True) + if gco == 'fail': return else: - self.app.gcode_edited = gc + self.app.gcode_edited = gco self.app.init_code_editor(name=_("Code Editor")) self.app.ui.buttonOpen.clicked.connect(self.app.handleOpen) diff --git a/ObjectCollection.py b/ObjectCollection.py index 9fe589e1..f85e9dea 100644 --- a/ObjectCollection.py +++ b/ObjectCollection.py @@ -320,7 +320,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): self.app.ui.menuprojectgeneratecnc.setVisible(False) if type(obj) != FlatCAMGeometry and type(obj) != FlatCAMExcellon and type(obj) != FlatCAMGerber: self.app.ui.menuprojectedit.setVisible(False) - if type(obj) != FlatCAMGerber and type(obj) != FlatCAMExcellon: + if type(obj) != FlatCAMGerber and type(obj) != FlatCAMExcellon and type(obj) != FlatCAMCNCjob: self.app.ui.menuprojectviewsource.setVisible(False) else: self.app.ui.menuprojectgeneratecnc.setVisible(False) diff --git a/README.md b/README.md index f6538fa8..cf4c0e3d 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ CAD program, and create G-Code for Isolation routing. - fixed the TclCommand cncjob to use the -outname parameter - added some more keywords in the data_model for auto-completer - fixed isolate TclCommand to use correctly the -outname parameter +- added possibility to see the GCode when right clicking on the Project tab on a CNCJob object and then clicking View Source 14.09.2019