diff --git a/ImportExport/ObjectsToPython.FCMacro b/ImportExport/ObjectsToPython.FCMacro index 9e355b6..4655d09 100644 --- a/ImportExport/ObjectsToPython.FCMacro +++ b/ImportExport/ObjectsToPython.FCMacro @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -__Version__ = '0.7.5' -__Date__ = '2025-01-08' +__Version__ = '0.7.7' +__Date__ = '2025-01-11' __License__ = 'LGPL-3.0-or-later' __Web__ = '' __Wiki__ = 'README.md' @@ -165,22 +165,17 @@ def addProperties(obj, objname, refobj, objectlist): ] # Cf. https://github.com/FreeCAD/FreeCAD/blob/278ce803907ef72548d7ac761613038ac435c481/src/App/Property.h#L60 - statusdict = { - 'PropStaticBegin': 21, - 'PropDynamic': 21, - 'PropNoPersist': 22, - 'PropNoRecompute': 23, - 'PropReadOnly': 24, - 'PropTransient': 25, - 'PropHidden': 26, - 'PropOutput': 27, - 'PropStaticEnd': 28, - } - - def dontWriteProperty(obj, propname, statuslist): + statuslist = [ + 'Immutable', 1, + 'ReadOnly', 2, + 'PropReadOnly', 24, + 'PropOutput', 27, + ] + + def propIsReadonly(obj, propname): statusnums = obj.getPropertyStatus(propname) for status in statuslist: - if statusdict[status] in statusnums: + if status in statusnums: return True return False @@ -192,9 +187,9 @@ def addProperties(obj, objname, refobj, objectlist): addSketch(obj, objname) for propname in obj.PropertiesList: - if ((propname not in skipProperties) - and ((obj.TypeId, propname) not in skipObjProp) - and (not dontWriteProperty(obj, propname, ["PropReadOnly", "PropOutput"]))): + if ((propname not in skipProperties) + and ((obj.TypeId, propname) not in skipObjProp) + and not propIsReadonly(obj, propname)): prop = obj.getPropertyByName(propname) val = objectToText(prop, objectlist)