Skip to content

fix(bonsai): resolve TypeError when importing Quick Favorites with Enum values (Resolves #7773)#7933

Open
dipayansardar73-decode wants to merge 4 commits intoIfcOpenShell:v0.8.0from
dipayansardar73-decode:fix/issue-7773-quick-favorites-typeerror
Open

fix(bonsai): resolve TypeError when importing Quick Favorites with Enum values (Resolves #7773)#7933
dipayansardar73-decode wants to merge 4 commits intoIfcOpenShell:v0.8.0from
dipayansardar73-decode:fix/issue-7773-quick-favorites-typeerror

Conversation

@dipayansardar73-decode
Copy link
Copy Markdown

Fixes #7773

Description

This PR resolves a TypeError that occurred when running bim.import_quick_favorites in Bonsai.

The Bug:
Blender's internal metadata for the Quick Favorites menu sometimes stores property values as integer indices for EnumProperty fields. However, when Bonsai attempts to synchronize these values into its own internal PropertyGroup representations, it uses setattr on EnumProperty fields which expects a string identifier, not an integer. This caused a fatal TypeError: expected a string enum, not int, preventing the import from completing successfully.

The Fix:
I've added a robust guard in QuickFavoriteProperty.set_value. It now checks if a value is being assigned to an enum_value field. If the value provided is an integer, it automatically looks up the corresponding string identifier from the enum_items collection before performing the assignment.

This ensures a seamless import of user settings from Blender into Bonsai without traceback errors.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

when i tried bim.import_quick_favorites() i got the following error, but they did seem to import, however.

1 participant