Title: Refresh Linked Aggregate crashes when an instance has no spatial container · Issue #10199 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Refresh Linked Aggregate crashes when an instance has no spatial container · Issue #10199 · IfcOpenShell/IfcOpenShell
X Title: Refresh Linked Aggregate crashes when an instance has no spatial container · Issue #10199 · IfcOpenShell/IfcOpenShell
Description: Bug Description bim.refresh_linked_aggregate crashes with AttributeError: 'NoneType' object has no attribute 'is_a' when a linked aggregate instance being rebuilt has no spatial container. To reproduce: Load src/bonsai/test/files/linked-...
Open Graph Description: Bug Description bim.refresh_linked_aggregate crashes with AttributeError: 'NoneType' object has no attribute 'is_a' when a linked aggregate instance being rebuilt has no spatial container. To repro...
X Description: Bug Description bim.refresh_linked_aggregate crashes with AttributeError: 'NoneType' object has no attribute 'is_a' when a linked aggregate instance being rebuilt has no spatial con...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/10199
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Refresh Linked Aggregate crashes when an instance has no spatial container","articleBody":"### Bug Description\r\n\r\n`bim.refresh_linked_aggregate` crashes with `AttributeError: 'NoneType' object has no attribute 'is_a'` when a linked aggregate instance being rebuilt has no spatial container.\r\n\r\n**To reproduce:**\r\n\r\n1. Load `src/bonsai/test/files/linked-aggregates.ifc`.\r\n2. Uncontain the assembly in IFC only:\r\n `ifcopenshell.api.spatial.unassign_container(tool.Ifc.get(), products=[tool.Ifc.get().by_type(\"IfcElementAssembly\")[0]])`\r\n (`bim.remove_container` also moves the objects to the hidden *Unsorted* collection, after which the duplicate in step 3 doesn't copy the assembly.)\r\n3. Select `IfcWall/Wall_01` and `Duplicate Linked Aggregate`.\r\n4. Select `IfcWall/Wall_01` again and `Refresh Linked Aggregate`.\r\n\r\n```\r\n File \"bonsai\\bim\\module\\geometry\\operator.py\", line 2139, in _execute\r\n set_original_data(new_obj, original_data)\r\n File \"bonsai\\bim\\module\\geometry\\operator.py\", line 1961, in set_original_data\r\n bonsai.core.spatial.assign_container(\r\n File \"bonsai\\core\\spatial.py\", line 67, in assign_container\r\n if products := [e for e in root_elements if spatial.can_contain(container, e)]:\r\n File \"bonsai\\tool\\spatial.py\", line 171, in can_contain\r\n if not container.is_a(\"IfcSpatialStructureElement\") and not container.is_a(\r\nAttributeError: 'NoneType' object has no attribute 'is_a'\r\n```\r\n\r\nIn a real model this shows up with a linked aggregate that is nested inside another aggregate (aggregated elements are not spatially contained), or one that was simply never assigned to a storey.\r\n\r\n**Root cause**\r\n\r\nSince #6883, `get_original_data` records each instance's container so refresh can put it back:\r\n\r\n```python\r\ncontainer = ifcopenshell.util.element.get_container(element)\r\noriginal_data[group][index] = {..., \"Container\": container}\r\n```\r\n\r\n`get_container` returns `None` for an uncontained element, and `set_original_data` passes that straight to `assign_container`:\r\n\r\n```python\r\nif not ifcopenshell.util.element.get_aggregate(element):\r\n bonsai.core.spatial.assign_container(..., container=original_data[matching_group_id][index][\"Container\"], ...)\r\n```\r\n\r\nThe `get_aggregate` guard doesn't help: it checks the *new* copy, which at that point has not been re-aggregated yet.\r\n\r\n**Fix**\r\n\r\nSkip the container assignment when the original instance had no container, so the rebuilt copy stays uncontained like the original.\r\n","author":{"url":"https://github.com/theoryshaw","@type":"Person","name":"theoryshaw"},"datePublished":"2026-11-11T21:26:53Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/10199"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:996d9fc2-0919-485a-b32d-7759c9515824 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB8A:2843FB:9A667:D3A1B:6B046304 |
| html-safe-nonce | ad1d64cd199f6491ef41e21840d15869f5d375b6bf212d5c91bb207f8fef31e3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjhBOjI4NDNGQjo5QTY2NzpEM0ExQjo2QjA0NjMwNCIsInZpc2l0b3JfaWQiOiI0MTk4Njc2Mzk0NDY2ODk0NTk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7f451a8f933eba272402cb9ea476a4a1fea053aff41f285a51121791c45a3d64 |
| hovercard-subject-tag | issue:6337437068 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/10199/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b9d5a3f5e024d98d7753074a5d8fb9f791e07119903277696cb5d1dcf8988314/IfcOpenShell/IfcOpenShell/issues/10199 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b9d5a3f5e024d98d7753074a5d8fb9f791e07119903277696cb5d1dcf8988314/IfcOpenShell/IfcOpenShell/issues/10199 |
| og:image:alt | Bug Description bim.refresh_linked_aggregate crashes with AttributeError: 'NoneType' object has no attribute 'is_a' when a linked aggregate instance being rebuilt has no spatial container. To repro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | theoryshaw |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6 |
| turbo-cache-control | no-preview |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 03e114520787ad27289207f153520ef97461127c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width