mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 23:56:03 +08:00
Merge pull request #8000 from Ultimaker/CURA-6915_identify_objects_on_buildplate
Write a list of object names to the global metadata objects to UFP file
This commit is contained in:
commit
a825e81daa
@ -18,6 +18,9 @@ from cura.Snapshot import Snapshot
|
|||||||
from cura.Utils.Threading import call_on_qt_thread
|
from cura.Utils.Threading import call_on_qt_thread
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
|
|
||||||
|
METADATA_OBJECTS_PATH = "metadata/objects"
|
||||||
|
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
||||||
@ -53,6 +56,8 @@ class UFPWriter(MeshWriter):
|
|||||||
archive = VirtualFile()
|
archive = VirtualFile()
|
||||||
archive.openStream(stream, "application/x-ufp", OpenMode.WriteOnly)
|
archive.openStream(stream, "application/x-ufp", OpenMode.WriteOnly)
|
||||||
|
|
||||||
|
self._writeObjectList(archive)
|
||||||
|
|
||||||
#Store the g-code from the scene.
|
#Store the g-code from the scene.
|
||||||
archive.addContentType(extension = "gcode", mime_type = "text/x-gcode")
|
archive.addContentType(extension = "gcode", mime_type = "text/x-gcode")
|
||||||
gcode_textio = StringIO() #We have to convert the g-code into bytes.
|
gcode_textio = StringIO() #We have to convert the g-code into bytes.
|
||||||
@ -139,3 +144,15 @@ class UFPWriter(MeshWriter):
|
|||||||
Logger.error(error_msg)
|
Logger.error(error_msg)
|
||||||
return False
|
return False
|
||||||
return True
|
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)`
|
||||||
|
"""
|
||||||
|
objects_model = CuraApplication.getInstance().getObjectsModel()
|
||||||
|
object_metas = [{"name": item["name"]} for item in objects_model.items]
|
||||||
|
|
||||||
|
data = {METADATA_OBJECTS_PATH: object_metas}
|
||||||
|
archive.setMetadata(data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user