From e66a3cda67fb24978831e51a16e193a8d277dc45 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Fri, 24 Nov 2023 15:40:11 +0100 Subject: [PATCH] Only extend file formats for um3 This was a mistake in the previous implementation. The relevant piece of code was adding ufp support for um3 printers. This is legacy support for this printer since the printer didn't know it supported ufp, but through the digital factory it could support ufp files. However, with the addition of method printers we should have added an additional check where we also check if the printer is an um3. Instead an additional check was added that did the same for makerbot printers. Because of this check didn't have a "is method" check support for makerbot format is also added to s-line printers and legacy um printers. (fyi @saumyaj3) CURA-11377 --- .../src/Cloud/CloudOutputDevice.py | 7 ++++++- plugins/UM3NetworkPrinting/src/ExportFileJob.py | 6 +++--- .../UM3NetworkPrinting/src/MeshFormatHandler.py | 15 ++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index 987125f128..aed38a3949 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -213,7 +213,12 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice): return # Export the scene to the correct file type. - job = ExportFileJob(file_handler=file_handler, nodes=nodes, firmware_version=self.firmwareVersion) + job = ExportFileJob( + file_handler=file_handler, + nodes=nodes, + firmware_version=self.firmwareVersion, + print_type=self.printerType, + ) job.finished.connect(self._onPrintJobCreated) job.start() diff --git a/plugins/UM3NetworkPrinting/src/ExportFileJob.py b/plugins/UM3NetworkPrinting/src/ExportFileJob.py index 953b167a6e..ac3da65719 100644 --- a/plugins/UM3NetworkPrinting/src/ExportFileJob.py +++ b/plugins/UM3NetworkPrinting/src/ExportFileJob.py @@ -16,9 +16,9 @@ from .MeshFormatHandler import MeshFormatHandler class ExportFileJob(WriteFileJob): """Job that exports the build plate to the correct file format for the target cluster.""" - def __init__(self, file_handler: Optional[FileHandler], nodes: List[SceneNode], firmware_version: str) -> None: - - self._mesh_format_handler = MeshFormatHandler(file_handler, firmware_version) + def __init__(self, file_handler: Optional[FileHandler], nodes: List[SceneNode], firmware_version: str, + print_type: str) -> None: + self._mesh_format_handler = MeshFormatHandler(file_handler, firmware_version, print_type) if not self._mesh_format_handler.is_valid: Logger.log("e", "Missing file or mesh writer!") return diff --git a/plugins/UM3NetworkPrinting/src/MeshFormatHandler.py b/plugins/UM3NetworkPrinting/src/MeshFormatHandler.py index e6054773d8..2ca8f9f3ce 100644 --- a/plugins/UM3NetworkPrinting/src/MeshFormatHandler.py +++ b/plugins/UM3NetworkPrinting/src/MeshFormatHandler.py @@ -19,10 +19,9 @@ I18N_CATALOG = i18nCatalog("cura") class MeshFormatHandler: """This class is responsible for choosing the formats used by the connected clusters.""" - - def __init__(self, file_handler: Optional[FileHandler], firmware_version: str) -> None: + def __init__(self, file_handler: Optional[FileHandler], firmware_version: str, printer_type: str) -> None: self._file_handler = file_handler or CuraApplication.getInstance().getMeshFileHandler() - self._preferred_format = self._getPreferredFormat(firmware_version) + self._preferred_format = self._getPreferredFormat(firmware_version, printer_type) self._writer = self._getWriter(self.mime_type) if self._preferred_format else None @property @@ -82,7 +81,7 @@ class MeshFormatHandler: value = value.encode() return value - def _getPreferredFormat(self, firmware_version: str) -> Dict[str, Union[str, int, bool]]: + def _getPreferredFormat(self, firmware_version: str, printer_type: str) -> Dict[str, Union[str, int, bool]]: """Chooses the preferred file format for the given file handler. :param firmware_version: The version of the firmware. @@ -103,13 +102,11 @@ class MeshFormatHandler: machine_file_formats = [file_type.strip() for file_type in machine_file_formats] # Exception for UM3 firmware version >=4.4: UFP is now supported and should be the preferred file format. - if "application/x-ufp" not in machine_file_formats and Version(firmware_version) >= Version("4.4"): + if printer_type in ( + "ultimaker3", "ultimaker3_extended") and "application/x-ufp" not in machine_file_formats and Version( + firmware_version) >= Version("4.4"): machine_file_formats = ["application/x-ufp"] + machine_file_formats - # Exception for makerbot firmware version >=2.700: makerbot is supported - elif "application/x-makerbot" not in machine_file_formats and Version(firmware_version >= Version("2.700")): - machine_file_formats = ["application/x-makerbot"] + machine_file_formats - # Take the intersection between file_formats and machine_file_formats. format_by_mimetype = {f["mime_type"]: f for f in file_formats}