From 5143cafc596b7fa0d6d988cabc91d56766457bb0 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 2 Oct 2019 22:59:50 +0300 Subject: [PATCH] - fixed the FlatCMAScript object when loading it from a project --- FlatCAMApp.py | 1 + FlatCAMObj.py | 20 +++++++++++++++++--- README.md | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 90e110b6..badff99a 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -3980,6 +3980,7 @@ class App(QtCore.QObject): # object that is created, it will strip the name of the object and the underline (if the original key was # let's say "excellon_toolchange", it will strip the excellon_) and to the obj.options the key will become # "toolchange" + for option in self.options: if option.find(kind + "_") == 0: oname = option[len(kind) + 1:] diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 6d549270..2facfce6 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -6492,6 +6492,21 @@ class FlatCAMScript(FlatCAMObj): self.kind = "script" + self.options.update({ + "plot": True, + "type": 'Script', + "source_file": '', + }) + + self.units = '' + self.decimals = 4 + + self.ser_attrs = ['options', 'kind', 'source_file'] + self.source_file = '' + self.script_code = '' + + self.script_editor_tab = None + def set_ui(self, ui): FlatCAMObj.set_ui(self, ui) FlatCAMApp.App.log.debug("FlatCAMScript.set_ui()") @@ -6542,12 +6557,11 @@ class FlatCAMScript(FlatCAMObj): self.ui.autocomplete_cb.stateChanged.connect(self.on_autocomplete_changed) - # add the source file to the Code Editor + self.ser_attrs = ['options', 'kind', 'source_file'] + for line in self.source_file.splitlines(): self.script_editor_tab.code_editor.append(line) - self.ser_attrs = ['options', 'kind', 'source_file'] - self.build_ui() def build_ui(self): diff --git a/README.md b/README.md index a2231ed5..312c579c 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,9 @@ CAD program, and create G-Code for Isolation routing. - reused the Multiprocessing Pool declared in the App for the ToolRulesCheck() class - adapted the Project context menu for the new types of FLatCAM objects - modified the setup_recent_files to accommodate the new FlatCAM objects -- made sure that when an FlatCAMscript object is deleted, it's associated Tab is closed +- made sure that when an FlatCAMScript object is deleted, it's associated Tab is closed - fixed the FlatCMAScript object saving when project is saved (loading a project with this script object is not working yet) +- fixed the FlatCMAScript object when loading it from a project 1.10.2019