From d96ce760f8828c14ece3b42ad6668f6f55c94905 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Tue, 26 Jul 2016 20:21:00 +0200 Subject: [PATCH] CURA-1223: 3MFReader: Doing selftest and fail on broken files This commit adds a selftest before the "result" gets returned. It should break on this/these functions and popup a message about using the online repair tool. I compared the content of both files for a long time, googled about the format, but wasn't able to find a proper fix. More routines will likely need to be added here, but with those I have it is working so far very well. Sadly it is not possible to override the default message, so two messages will appear. Additionally, the URL of the link is not clickable/executable from the UX. Just acting like normal text. Contributes to CURA-1223 --- plugins/3MFReader/ThreeMFReader.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/3MFReader/ThreeMFReader.py b/plugins/3MFReader/ThreeMFReader.py index 57d76b2783..bf25ccd440 100644 --- a/plugins/3MFReader/ThreeMFReader.py +++ b/plugins/3MFReader/ThreeMFReader.py @@ -9,9 +9,13 @@ from UM.Math.Vector import Vector from UM.Scene.SceneNode import SceneNode from UM.Scene.GroupDecorator import GroupDecorator from UM.Math.Quaternion import Quaternion - from UM.Job import Job +from UM.Message import Message +from UM.i18n import i18nCatalog +catalog = i18nCatalog("cura") + + import math import zipfile @@ -116,4 +120,11 @@ class ThreeMFReader(MeshReader): except Exception as e: Logger.log("e", "exception occured in 3mf reader: %s", e) + try: # Selftest - There might be more functions that should fail + result.getBoundingBox() + except: + message = Message(catalog.i18nc("@info:status", "Your 3MF file seems to be broken. Please visit https://modelrepair.azurewebsites.net/ and try to repair your model!"), lifetime = 0) + message.show() + return None + return result