mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Split-out bambu-specific elements to their own 3MF 'variant'.
part of CURA-12099
This commit is contained in:
parent
17ab7a4890
commit
254087cb45
4 changed files with 308 additions and 134 deletions
33
plugins/3MFWriter/DefaultVariant.py
Normal file
33
plugins/3MFWriter/DefaultVariant.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Copyright (c) 2025 UltiMaker
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
import zipfile
|
||||
|
||||
from PyQt6.QtCore import QBuffer
|
||||
from PyQt6.QtGui import QImage
|
||||
|
||||
from .ThreeMFVariant import ThreeMFVariant
|
||||
|
||||
# Standard 3MF paths
|
||||
METADATA_PATH = "Metadata"
|
||||
THUMBNAIL_PATH = f"{METADATA_PATH}/thumbnail.png"
|
||||
|
||||
class DefaultVariant(ThreeMFVariant):
|
||||
"""Default implementation of the 3MF format."""
|
||||
|
||||
@property
|
||||
def mime_type(self) -> str:
|
||||
return "application/vnd.ms-package.3dmanufacturing-3dmodel+xml"
|
||||
|
||||
def process_thumbnail(self, snapshot: QImage, thumbnail_buffer: QBuffer,
|
||||
archive: zipfile.ZipFile, relations_element: ET.Element) -> None:
|
||||
"""Process the thumbnail for default 3MF variant."""
|
||||
thumbnail_file = zipfile.ZipInfo(THUMBNAIL_PATH)
|
||||
# Don't try to compress snapshot file, because the PNG is pretty much as compact as it will get
|
||||
archive.writestr(thumbnail_file, thumbnail_buffer.data())
|
||||
|
||||
# Add thumbnail relation to _rels/.rels file
|
||||
ET.SubElement(relations_element, "Relationship",
|
||||
Target="/" + THUMBNAIL_PATH, Id="rel1",
|
||||
Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail")
|
Loading…
Add table
Add a link
Reference in a new issue