Skip to content

Update object properties when modifying bins created with an older version of the Gridfinity Workbench.#143

Merged
Stu142 merged 3 commits into
Stu142:masterfrom
glenn20:feature-update-object-properties-by-version
Feb 28, 2026
Merged

Update object properties when modifying bins created with an older version of the Gridfinity Workbench.#143
Stu142 merged 3 commits into
Stu142:masterfrom
glenn20:feature-update-object-properties-by-version

Conversation

@glenn20

@glenn20 glenn20 commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

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

@greg19 greg19 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM. And sorry for breaking

Comment thread freecad/gridfinity_workbench/features.py Outdated
Comment thread freecad/gridfinity_workbench/features.py Outdated
@glenn20

glenn20 commented Feb 26, 2026

Copy link
Copy Markdown
Contributor Author

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).

@glenn20

glenn20 commented Feb 26, 2026

Copy link
Copy Markdown
Contributor Author

I have added an additional commit to ensure the object is recomputed after updating the object properties. Eg. this ensures that UsableHeight is correctly recomputed if a change to the HeightUnits property triggers an object version update.

I suggest these additional commits be squashed prior to merge.

@glenn20 glenn20 force-pushed the feature-update-object-properties-by-version branch from da53f1a to 62d4082 Compare February 27, 2026 06:39
@glenn20

glenn20 commented Feb 27, 2026

Copy link
Copy Markdown
Contributor Author

I have also refactored to move the property migration code into a new check_version.py module.

I have also squashed the commits for a cleaner PR.

@glenn20 glenn20 force-pushed the feature-update-object-properties-by-version branch from 62d4082 to 2c54284 Compare February 27, 2026 06:54
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.
@glenn20 glenn20 force-pushed the feature-update-object-properties-by-version branch from 2c54284 to de2e39b Compare February 27, 2026 07:30
@Stu142

Stu142 commented Feb 28, 2026

Copy link
Copy Markdown
Owner

Great idea

@Stu142 Stu142 merged commit f406830 into Stu142:master Feb 28, 2026
4 checks passed
@glenn20 glenn20 deleted the feature-update-object-properties-by-version branch February 28, 2026 22:32
@glenn20

glenn20 commented Feb 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Stu142 for a great project and thanks for the support and guidance @greg19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants