From fd34891c999f20ee07c2871c93699874730d5fa6 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Tue, 14 Apr 2020 00:25:36 -0500 Subject: [PATCH] Path: Improve compatibility between file versions Verify enumerations on document reload, maintaining the existing value for the property. --- src/Mod/Path/PathScripts/PathSurface.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Mod/Path/PathScripts/PathSurface.py b/src/Mod/Path/PathScripts/PathSurface.py index 413058000a..c11ada918f 100644 --- a/src/Mod/Path/PathScripts/PathSurface.py +++ b/src/Mod/Path/PathScripts/PathSurface.py @@ -102,6 +102,9 @@ class ObjectSurface(PathOp.ObjectOp): if not hasattr(obj, nm): obj.addProperty(prtyp, nm, grp, tt) missing.append(nm) + newPropMsg = translate('PathSurface', 'New property added: ') + nm + '. ' + newPropMsg += translate('PathSurface', 'Check its default value.') + PathLog.warning(newPropMsg) # Set enumeration lists for enumeration properties if len(missing) > 0: @@ -253,6 +256,20 @@ class ObjectSurface(PathOp.ObjectOp): else: obj.setEditorMode('ShowTempObjects', 0) # show + # Repopulate enumerations in case of changes + ENUMS = self.propertyEnumerations() + for n in ENUMS: + restore = False + if hasattr(obj, n): + val = obj.getPropertyByName(n) + restore = True + cmdStr = 'obj.{}={}'.format(n, ENUMS[n]) + exec(cmdStr) + if restore: + cmdStr = 'obj.{}={}'.format(n, "'" + val + "'") + exec(cmdStr) + + self.setEditorProperties(obj) def opSetDefaultValues(self, obj, job):