Title: Bonsai: change_data crashes with "'NoneType' object has no attribute 'users'" when reloading an object that has no mesh data · Issue #8655 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Bonsai: change_data crashes with "'NoneType' object has no attribute 'users'" when reloading an object that has no mesh data · Issue #8655 · IfcOpenShell/IfcOpenShell
X Title: Bonsai: change_data crashes with "'NoneType' object has no attribute 'users'" when reloading an object that has no mesh data · Issue #8655 · IfcOpenShell/IfcOpenShell
Description: Bug Description Geometry.change_data (in bonsai/tool/geometry.py, a nested helper inside reimport_element_representations) crashes when it reloads an object that currently has no mesh data (obj.data is None, e.g. a Blender EMPTY being gi...
Open Graph Description: Bug Description Geometry.change_data (in bonsai/tool/geometry.py, a nested helper inside reimport_element_representations) crashes when it reloads an object that currently has no mesh data (obj.dat...
X Description: Bug Description Geometry.change_data (in bonsai/tool/geometry.py, a nested helper inside reimport_element_representations) crashes when it reloads an object that currently has no mesh data (obj.dat...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/8655
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bonsai: change_data crashes with \"'NoneType' object has no attribute 'users'\" when reloading an object that has no mesh data","articleBody":"### Bug Description\n\n`Geometry.change_data` (in `bonsai/tool/geometry.py`, a nested helper inside `reimport_element_representations`) crashes when it reloads an object that currently has **no mesh data** (`obj.data is None`, e.g. a Blender EMPTY being given geometry).\n\n`change_data` already handles the datatype change — it calls `recreate_object_with_data` when `type(old_data) != type(data)` — but the subsequent cleanup then calls `has_data_users(old_data)` with `old_data = None`, and `has_data_users` does `return data.users != 0`.\n\nThis is reached via `bonsai.core.geometry.switch_representation` → `Geometry.reimport_element_representations` → `change_data` whenever the target object has no prior mesh (an empty → mesh transition).\n\n### Traceback\n\n```\nFile \".../bonsai/tool/geometry.py\", line ..., in reimport_element_representations\n change_data(obj, element, mesh)\nFile \".../bonsai/tool/geometry.py\", line ..., in change_data\n if not cls.has_data_users(old_data):\nFile \".../bonsai/tool/geometry.py\", line ..., in has_data_users\n return data.users != 0\nAttributeError: 'NoneType' object has no attribute 'users'\n```\n\n### Expected\n\nReloading/reimporting the representation of an object that had no mesh data should succeed — the empty → mesh transition is already handled by `recreate_object_with_data`; only the leftover-data cleanup is unguarded.\n\n### Suggested fix\n\nGuard the cleanup against a `None` `old_data` (both `has_data_users` and `delete_data` assume a non-None datablock):\n\n```python\nif old_data is not None and not cls.has_data_users(old_data):\n cls.delete_data(old_data)\n```\n\n### Environment\n\n- Blender 4.5.7 LTS, Bonsai 0.8.6-alpha, Windows 10.\n","author":{"url":"https://github.com/theoryshaw","@type":"Person","name":"theoryshaw"},"datePublished":"2026-07-16T17:24:39Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/8655"}
| 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:f29eeebf-24aa-1064-0f53-cdd8688be8f0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D56:3A0E8F:1561D9:1D9A48:6B046556 |
| html-safe-nonce | 9108d40d8c5a687211d491c9c3ad2a61980258d5d509d9f9e2e8adc0471e8442 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDU2OjNBMEU4RjoxNTYxRDk6MUQ5QTQ4OjZCMDQ2NTU2IiwidmlzaXRvcl9pZCI6IjExOTczNDEyMzQ5OTg1NjgyNzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 57690723cf1361e3547ba65f3f1b0574c506ed5737c44c0f96213b730de6ec20 |
| hovercard-subject-tag | issue:4904444970 |
| 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/8655/issue_layout |
| twitter:image | https://opengraph.githubassets.com/35dac9be10ceb85a9e790213c0e0482d5a14551a606944114d726a5b35c11320/IfcOpenShell/IfcOpenShell/issues/8655 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/35dac9be10ceb85a9e790213c0e0482d5a14551a606944114d726a5b35c11320/IfcOpenShell/IfcOpenShell/issues/8655 |
| og:image:alt | Bug Description Geometry.change_data (in bonsai/tool/geometry.py, a nested helper inside reimport_element_representations) crashes when it reloads an object that currently has no mesh data (obj.dat... |
| 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 | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| 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 | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| 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