mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-16 09:35:56 +08:00
Merge pull request #8023 from Ultimaker/CURA-6915_identify_objects_on_buildplate
CURA-6915_remaining_issues
This commit is contained in:
commit
f0456526b3
@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) 2020 Ultimaker B.V.
|
# Copyright (c) 2020 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from typing import cast
|
from typing import cast, List, Dict
|
||||||
|
|
||||||
from Charon.VirtualFile import VirtualFile # To open UFP files.
|
from Charon.VirtualFile import VirtualFile # To open UFP files.
|
||||||
from Charon.OpenMode import OpenMode # To indicate that we want to write to UFP files.
|
from Charon.OpenMode import OpenMode # To indicate that we want to write to UFP files.
|
||||||
@ -13,6 +13,8 @@ from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType
|
|||||||
from UM.PluginRegistry import PluginRegistry # To get the g-code writer.
|
from UM.PluginRegistry import PluginRegistry # To get the g-code writer.
|
||||||
from PyQt5.QtCore import QBuffer
|
from PyQt5.QtCore import QBuffer
|
||||||
|
|
||||||
|
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||||
|
from UM.Scene.SceneNode import SceneNode
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
from cura.Snapshot import Snapshot
|
from cura.Snapshot import Snapshot
|
||||||
from cura.Utils.Threading import call_on_qt_thread
|
from cura.Utils.Threading import call_on_qt_thread
|
||||||
@ -83,7 +85,9 @@ class UFPWriter(MeshWriter):
|
|||||||
thumbnail_image.save(thumbnail_buffer, "PNG")
|
thumbnail_image.save(thumbnail_buffer, "PNG")
|
||||||
|
|
||||||
thumbnail.write(thumbnail_buffer.data())
|
thumbnail.write(thumbnail_buffer.data())
|
||||||
archive.addRelation(virtual_path = "/Metadata/thumbnail.png", relation_type = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail", origin = "/3D/model.gcode")
|
archive.addRelation(virtual_path = "/Metadata/thumbnail.png",
|
||||||
|
relation_type = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail",
|
||||||
|
origin = "/3D/model.gcode")
|
||||||
else:
|
else:
|
||||||
Logger.log("d", "Thumbnail not created, cannot save it")
|
Logger.log("d", "Thumbnail not created, cannot save it")
|
||||||
|
|
||||||
@ -151,8 +155,25 @@ class UFPWriter(MeshWriter):
|
|||||||
|
|
||||||
To retrieve, use: `archive.getMetadata(METADATA_OBJECTS_PATH)`
|
To retrieve, use: `archive.getMetadata(METADATA_OBJECTS_PATH)`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
objects_model = CuraApplication.getInstance().getObjectsModel()
|
objects_model = CuraApplication.getInstance().getObjectsModel()
|
||||||
object_metas = [{"name": item["name"]} for item in objects_model.items]
|
object_metas = []
|
||||||
|
|
||||||
|
for item in objects_model.items:
|
||||||
|
object_metas.extend(UFPWriter._getObjectMetadata(item["node"]))
|
||||||
|
|
||||||
data = {METADATA_OBJECTS_PATH: object_metas}
|
data = {METADATA_OBJECTS_PATH: object_metas}
|
||||||
archive.setMetadata(data)
|
archive.setMetadata(data)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _getObjectMetadata(node: SceneNode) -> List[Dict[str, str]]:
|
||||||
|
"""Get object metadata to write for a Node.
|
||||||
|
|
||||||
|
:return: List of object metadata dictionaries.
|
||||||
|
Might contain > 1 element in case of a group node.
|
||||||
|
Might be empty in case of nonPrintingMesh
|
||||||
|
"""
|
||||||
|
|
||||||
|
return [{"name": item.getName()}
|
||||||
|
for item in DepthFirstIterator(node)
|
||||||
|
if item.getMeshData() is not None and not item.callDecoration("isNonPrintingMesh")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user