From 13ff930e09cf246545ff0b63d7e46d57d0c44463 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Sat, 16 May 2020 07:39:02 +0200 Subject: [PATCH] FEM: python base view provider, improve error handling --- src/Mod/Fem/femguiobjects/ViewProviderBaseObject.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Mod/Fem/femguiobjects/ViewProviderBaseObject.py b/src/Mod/Fem/femguiobjects/ViewProviderBaseObject.py index 200de13424..0cf9fa0f5f 100644 --- a/src/Mod/Fem/femguiobjects/ViewProviderBaseObject.py +++ b/src/Mod/Fem/femguiobjects/ViewProviderBaseObject.py @@ -51,9 +51,17 @@ class ViewProxy(object): def getIcon(self): """after load from FCStd file, self.icon does not exist, return constant path instead""" # https://forum.freecadweb.org/viewtopic.php?f=18&t=44009 + if not hasattr(self.Object, "Proxy"): + FreeCAD.Console.PrintMessage("{}, has no Proxy.\n".format(self.Object.Name)) + return "" + if not hasattr(self.Object.Proxy, "Type"): + FreeCAD.Console.PrintMessage( + "{}: Proxy does has not have attribte Type.\n" + .format(self.Object.Name) + ) + return "" if ( - hasattr(self.Object.Proxy, "Type") - and isinstance(self.Object.Proxy.Type, string_types) + isinstance(self.Object.Proxy.Type, string_types) and self.Object.Proxy.Type.startswith("Fem::") ): icon_path = "/icons/{}.svg".format(self.Object.Proxy.Type.replace("Fem::", "FEM_"))