fix(bonsai): prevent NoneType assignment crash when modifying spatial structures of voided objects (Resolves #7801, Resolves #7861)#7931
Open
dipayansardar73-decode wants to merge 3 commits intoIfcOpenShell:v0.8.0from
Conversation
added 3 commits
April 11, 2026 12:21
…structure of void or symbolic nodes (Resolves IfcOpenShell#7801, Resolves IfcOpenShell#7861)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7801
Fixes #7861
Description
This PR resolves two advanced architectural bugs where modifying the structural hierarchy or relations of an IFCElement (like changing spatial containers or assembling voided geometries) instantly triggered a fatal AttributeError: 'NoneType' object has no attribute 'users_collection'.
The Bug:
Under the hood, assigning IFC instances into relationship hierarchies triggers Bonsai's core collection manager to physically migrate the underlying .blend object representations across the Blender scene layout.
If an element lacks geometrical representation (e.g. is purely symbolic or has been temporarily voided out), ifc.get_object(element) correctly evaluates to None. However, tool.collector.assign lacked a null-check, meaning it attempted to iterate over the absent users_collection arrays, dropping the entire process.
The Fix:
I have added a clean, robust lifecycle null guard (if not obj: return) directly into the Collector.assign() endpoint. If a purely structural IFC element without 3D Blender geometry needs container modification, Bonsai will now seamlessly update the hierarchy data without committing engine suicide while trying to manipulate non-existent geometry.