Просмотр исходного кода

- fixed the FlatCMAScript object when loading it from a project

Marius Stanciu 6 лет назад
Родитель
Сommit
5143cafc59
3 измененных файлов с 20 добавлено и 4 удалено
  1. 1 0
      FlatCAMApp.py
  2. 17 3
      FlatCAMObj.py
  3. 2 1
      README.md

+ 1 - 0
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:]

+ 17 - 3
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):

+ 2 - 1
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