Fix ci-bonsai-daily: ProjectLibraryData duplicate parent-library enum

parent_libraries_enum() adds an explicit entry for get_root_context(),
then loops over cls.data["project_libraries"] (all IfcProjectLibrary
entities) and appends each. For a library-only file (no IfcProject),
get_root_context falls back to the top-level IfcProjectLibrary itself,
so the root is appended twice with the same enum key (its STEP id),
which Blender EnumProperty requires to be unique -> the data load
asserts. Normal project files are unaffected (root is an IfcProject
whose id never collides with a library id).

Skip library_id == root.id() in the loop (dedup by id, the colliding
key). Verified in headless Blender:
test_project_library_data.py::TestLibraryOnlyFile goes from 1 failed /
5 passed to 6 passed.

This change was made with the assistance of an AI tool.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Petru Conduraru
2026-07-13 06:33:43 +03:00
parent ffb867f254
commit 6c9e863546
@@ -165,6 +165,12 @@ class ProjectLibraryData:
root = tool.Project.get_root_context(library_file)
results.append((str(root.id()), f"{root.is_a()} {root.Name or 'Unnamed'}", root.Description or ""))
for library_id, data in cls.data["project_libraries"].items():
# Library-only files have an IfcProjectLibrary as their root context, and
# project_libraries() collects every IfcProjectLibrary in the file (root
# included). Skip it here since it was already added above, otherwise the
# root library is listed twice with colliding enum keys.
if library_id == root.id():
continue
results.append((str(library_id), data["Name"] or "Unnamed", data["Description"] or ""))
return results