Update object properties when modifying bins created with an older version of the Gridfinity Workbench.#143
Conversation
greg19
left a comment
There was a problem hiding this comment.
Thanks, LGTM. And sorry for breaking
No problems. I understand that for this particular project, people may not be thinking of backward compatibility as many users of the workbench just generate bins as needed and dont need to save and load older files. It affected me as I have a few designs which use modified bins (which you have pointed out previously is one of the great advantages of using a full CAD package to generate your gridfinity bins) and I use the workbench to create whole drawer layouts using freecad (which I reuse). |
|
I have added an additional commit to ensure the object is recomputed after updating the object properties. Eg. this ensures that I suggest these additional commits be squashed prior to merge. |
da53f1a to
62d4082
Compare
|
I have also refactored to move the property migration code into a new I have also squashed the commits for a cleaner PR. |
62d4082 to
2c54284
Compare
Provide the `check_version.py` module which provides the `migrate_object_version()` function, which is called from `FoundationGridfinity.onDocumentRestored()` when loading a Gridfinity object generated by an older version of the workbench. This provides a form of backward compatibilty for the Gridfinity workbench. This function will check the version of the object against the current Gridfinity Workbench version, and if they are different, it will: - update the properties in the object to match the current version, - recompute the object to ensure that any expressions are updated with the new properties and - print a warning message to the console. The initial implementation only supports migrating objects from v0.11.9 and v0.11.10 to v0.12.0.
2c54284 to
de2e39b
Compare
|
Great idea |
Provide the
check_version.migrate_object_version()function, which checks the version of the object against the current Gridfinity Workbench version, and if they are different, it will update the properties in the object to match the current version.The function is called from
FoundationGridfinity.onDocumentRestored()when loading a Gridfinity object generated by an older version of the workbench.This provides a form of backward compatibilty for newer versions of the Gridfinity workbench.
A warning message is printed to the console when an object is updated from an older version.
The initial implementation only supports migrating objects from v0.11.9 and v0.11.10 to v0.12.0. In particular, this PR fixes Issue #141 and Issue #142 by renaming the "MagnetRelief" property to "MagnetRemoveChannel" and setting the calculation of "UsableHeight" as an object Expression. It also converts the "xGridUnits" and "yGridUnits" properties from integer to float.
NOTE: Gridfinity objects are only updated when their properties are modified. If an object is not modified, it will retain its old properties and version.This is an initial and straightforward implementation to address the Issues above. It necessarily duplicates code for creating and modifying the object properties. A more considered implementation would provide a mechanism for managing object schema migration. Nonetheless, this does address the immediate issues of broken backward compatibility.
Closes #141
Closes #142