diff options
author | Nino van Hooff <ninovanhooff@gmail.com> | 2020-06-30 14:31:21 +0300 |
---|---|---|
committer | Nino van Hooff <ninovanhooff@gmail.com> | 2020-06-30 14:32:08 +0300 |
commit | 67836851261d04db192e9d5bfd7b4fa933018e58 (patch) | |
tree | 95ecf241cddd486a50560dea2da4365043a9777a | |
parent | 5055b53063e32aebd60c43b8acbfe475cffdb186 (diff) |
Write a list of object names to the global metadata of ufp
files
CURA-6915
-rw-r--r-- | plugins/UFPWriter/UFPWriter.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/UFPWriter/UFPWriter.py b/plugins/UFPWriter/UFPWriter.py index 3c241670b0..122f943766 100644 --- a/plugins/UFPWriter/UFPWriter.py +++ b/plugins/UFPWriter/UFPWriter.py @@ -18,6 +18,9 @@ from cura.Snapshot import Snapshot from cura.Utils.Threading import call_on_qt_thread from UM.i18n import i18nCatalog + +METADATA_OBJECTS_PATH = "metadata/objects" + catalog = i18nCatalog("cura") @@ -53,6 +56,8 @@ class UFPWriter(MeshWriter): archive = VirtualFile() archive.openStream(stream, "application/x-ufp", OpenMode.WriteOnly) + self._writeObjectList(archive) + #Store the g-code from the scene. archive.addContentType(extension = "gcode", mime_type = "text/x-gcode") gcode_textio = StringIO() #We have to convert the g-code into bytes. @@ -139,3 +144,15 @@ class UFPWriter(MeshWriter): Logger.error(error_msg) return False return True + + @staticmethod + def _writeObjectList(archive): + """Write a json list of object names to the METADATA_OBJECTS_PATH metadata field + + To retrieve, use: `archive.getMetadata(METADATA_OBJECTS_PATH)` + """ + objectsModel = CuraApplication.getInstance().getObjectsModel() + objectMetas = [{"name": item["name"]} for item in objectsModel.items] + + data = {METADATA_OBJECTS_PATH: objectMetas} + archive.setMetadata(data) |