From ba21ca8cc248d0f276ac2e80ea5cfa0a3a58ce22 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Mon, 16 Mar 2020 11:02:25 +0100 Subject: [PATCH] FEM: Python base VP, better check in get icon --- src/Mod/Fem/femguiobjects/ViewProviderFemConstraint.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Mod/Fem/femguiobjects/ViewProviderFemConstraint.py b/src/Mod/Fem/femguiobjects/ViewProviderFemConstraint.py index 0f33c685df..6f3f133537 100644 --- a/src/Mod/Fem/femguiobjects/ViewProviderFemConstraint.py +++ b/src/Mod/Fem/femguiobjects/ViewProviderFemConstraint.py @@ -31,6 +31,7 @@ __url__ = "http://www.freecadweb.org" # \brief FreeCAD _Base ViewProvider for FEM workbench from pivy import coin +from six import string_types import FreeCAD import FreeCADGui @@ -50,9 +51,14 @@ class ViewProxy(object): # needs to be overwritten, if no standard icon name is used # see constraint body heat source as an example def getIcon(self): + print(self.Object.Name) """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 hasattr(self.Object.Proxy, "Type") and self.Object.Proxy.Type.startswith("Fem::"): + if ( + hasattr(self.Object.Proxy, "Type") + and isinstance(self.Object.Proxy.Type, string_types) + and self.Object.Proxy.Type.startswith("Fem::") + ): return ":/icons/{}.svg".format(self.Object.Proxy.Type.replace("Fem::", "FEM_")) else: return ""