From 600e2abce1545619b3792929af338e179b7a5e19 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 26 Jan 2018 13:25:49 +0100 Subject: [PATCH] Add basic UFP writer plug-in This already implements most of it. Just the thumbnail must still be gotten and put inside the container. Contributes to issue CURA-4872. --- plugins/UFPWriter/UFPWriter.py | 21 +++++++++++++++++++++ plugins/UFPWriter/__init__.py | 25 +++++++++++++++++++++++++ plugins/UFPWriter/plugin.json | 8 ++++++++ 3 files changed, 54 insertions(+) create mode 100644 plugins/UFPWriter/UFPWriter.py create mode 100644 plugins/UFPWriter/__init__.py create mode 100644 plugins/UFPWriter/plugin.json diff --git a/plugins/UFPWriter/UFPWriter.py b/plugins/UFPWriter/UFPWriter.py new file mode 100644 index 0000000000..fd51d7645c --- /dev/null +++ b/plugins/UFPWriter/UFPWriter.py @@ -0,0 +1,21 @@ +#Copyright (c) 2018 Ultimaker B.V. +#Cura is released under the terms of the LGPLv3 or higher. + +import charon + +from UM.Mesh.MeshWriter import MeshWriter #The writer we need to implement. +from UM.PluginRegistry import PluginRegistry #To get the g-code writer. + +class UFPWriter(MeshWriter): + def write(self, stream, nodes, mode = MeshWriter.OutputMode.BinaryMode): + archive = charon.VirtualFile() + archive.open(stream, charon.OpenMode.WriteOnly) + + #Store the g-code from the scene. + archive.addContentType(extension = "gcode", mime_type = "text/x-gcode") + gcode = archive.getStream("/3D/model.gcode") + PluginRegistry.getInstance().getPluginObject("GCodeWriter").write(gcode, None) + archive.addRelation(target = "/3D/model.gcode", file_type = "http://schemas.ultimaker.org/package/2018/relationships/gcode") + + #Store the thumbnail. + #TODO \ No newline at end of file diff --git a/plugins/UFPWriter/__init__.py b/plugins/UFPWriter/__init__.py new file mode 100644 index 0000000000..77f8e81222 --- /dev/null +++ b/plugins/UFPWriter/__init__.py @@ -0,0 +1,25 @@ +#Copyright (c) 2018 Ultimaker B.V. +#Cura is released under the terms of the LGPLv3 or higher. + +from . import UFPWriter +from UM.i18n import i18nCatalog #To translate the file format description. +from UM.Mesh.MeshWriter import MeshWriter #For the binary mode flag. + +i18n_catalog = i18nCatalog("cura") + +def getMetaData(): + return { + "mesh_writer": { + "output": [ + { + "mime_type": "application/x-ufp", + "mode": MeshWriter.OutputMode.BinaryMode, + "extension": "ufp", + "description": i18n_catalog.i18nc("@item:inlistbox", "Ultimaker Format Package") + } + ] + } + } + +def register(app): + return { "mesh_writer": UFPWriter.UFPWriter() } diff --git a/plugins/UFPWriter/plugin.json b/plugins/UFPWriter/plugin.json new file mode 100644 index 0000000000..7d10b89ad4 --- /dev/null +++ b/plugins/UFPWriter/plugin.json @@ -0,0 +1,8 @@ +{ + "name": "UFP Writer", + "author": "Ultimaker B.V.", + "version": "1.0.0", + "description": "Provides support for writing Ultimaker Format Packages.", + "api": 4, + "i18n-catalog": "cura" +} \ No newline at end of file