From 0543961ea2a1ba1878f56c54adee247ec33debe1 Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Mon, 26 Oct 2015 01:53:59 +0300 Subject: [PATCH] Semi-fix for errors during loading projects that contain lattice objects --- latticeBaseFeature.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/latticeBaseFeature.py b/latticeBaseFeature.py index 39f068b..cbb98ae 100644 --- a/latticeBaseFeature.py +++ b/latticeBaseFeature.py @@ -163,12 +163,22 @@ class LatticeFeature(): def onChanged(self, obj, prop): #prop is a string - name of the property if prop == 'isLattice': if obj.ViewObject is not None: - if isObjectLattice(obj): - obj.ViewObject.DisplayMode = 'Shaded' - obj.ViewObject.ShapeColor = getDefLatticeFaceColor() - else: - obj.ViewObject.DisplayMode = 'Flat Lines' - obj.ViewObject.ShapeColor = getDefShapeColor() + try: + if isObjectLattice(obj): + obj.ViewObject.DisplayMode = 'Shaded' + obj.ViewObject.ShapeColor = getDefLatticeFaceColor() + else: + obj.ViewObject.DisplayMode = 'Flat Lines' + obj.ViewObject.ShapeColor = getDefShapeColor() + except App.Base.FreeCADError as err: + #these errors pop up while loading project file, apparently because + # viewprovider is up already, but the shape vis mesh wasn't yet + # created. It is safe to ignore them, as DisplayMode is eventually + # restored to the correct values. + #Proper way of dealing with it would have been by testing for + # isRestoring(??), but I failed to find the way to do it. + #--DeepSOIC + pass class ViewProviderLatticeFeature: