diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 90241c6e72..ecccfc77ac 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -13,6 +13,7 @@ from UM.Workspace.WorkspaceReader import WorkspaceReader from UM.Application import Application from UM.Logger import Logger +from UM.Message import Message from UM.i18n import i18nCatalog from UM.Signal import postponeSignals, CompressTechnique from UM.Settings.ContainerFormatError import ContainerFormatError @@ -470,6 +471,20 @@ class ThreeMFWorkspaceReader(WorkspaceReader): Logger.log("w", "File %s is not a valid workspace.", file_name) return WorkspaceReader.PreReadResult.failed + # Check if the machine definition exists. If not, indicate failure because we do not import definition files. + def_results = self._container_registry.findDefinitionContainersMetadata(id = machine_definition_id) + if not def_results: + message = Message(i18n_catalog.i18nc("@info:status Don't translate the XML tags or !", + "Project file {0} contains an unknown machine type" + " {1}. Cannot import the machine." + " Models will be imported instead.", file_name, machine_definition_id), + title = i18n_catalog.i18nc("@info:title", "Open Project File")) + message.show() + + Logger.log("i", "Could unknown machine definition %s in project file %s, cannot import it.", + self._machine_info.definition_id, file_name) + return WorkspaceReader.PreReadResult.failed + # In case we use preRead() to check if a file is a valid project file, we don't want to show a dialog. if not show_dialog: return WorkspaceReader.PreReadResult.accepted