Title: Bonsai: keep loaded classification libraries selectable without reloading by petruconduraru · Pull Request #8941 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Bonsai: keep loaded classification libraries selectable without reloading by petruconduraru · Pull Request #8941 · IfcOpenShell/IfcOpenShell
X Title: Bonsai: keep loaded classification libraries selectable without reloading by petruconduraru · Pull Request #8941 · IfcOpenShell/IfcOpenShell
Description: Fixes #4612. Root cause IfcStore.classification_file (bonsai/bim/ifc.py) is a single global that gets overwritten by every bim.load_classification_library call. The FILE-mode "Available Classifications" dropdown (available_classifications in classification/prop.py and classification/data.py) is built entirely from that one global. So once a second classification library file is loaded, the first one's entities become unreachable, even though both classifications are already added to the project (visible in the Classifications list below the dropdown). The only way to browse the first library's hierarchy again (to add more references from it) is to re-select its file from disk, exactly as reported: "Active IfcClassification (the one I can use to add reference to objects) is the one I added most recently. Other ones can't be used unless I add them again." What changed IfcStore.classification_files: a new session cache, keyed by filepath, populated by bim.load_classification_library in addition to (not instead of) the existing classification_file global. Previously loaded libraries are no longer discarded. A new "Loaded Classification Library" dropdown (only shown once more than one library has been loaded, so the common single-library case is unchanged) lets you switch IfcStore.classification_file back to a previously loaded library without re-opening it from disk. Available Classifications and reference browsing update to match. IfcStore.purge() now also resets classification_path/classification_file/classification_files on project close, which it previously omitted. This is scoped to not touch how available_classifications and reference-hierarchy browsing (bim.change_classification_level, bim.add_classification_reference) already work, since both operate on whichever file is browsed at the source-library level, and there are 12 existing .feature scenarios asserting that behavior. Design question left open The reporter's literal ask ("all IfcClassifications in the file should be listed in the dropdown") also covers project classifications whose source library was never loaded in the current session (e.g. reopening a saved .ifc that already has classifications baked in from a previous session). That's not solved here: without the original library file, there is no reference hierarchy to browse from, only the classification's name/attributes are in the project. Solving that fully would mean either bundling common libraries by name (see #8920, which adds a built-in library picker and is a natural complement to this) or a broader change to how FILE-mode reference browsing is scoped. Opening as draft so a maintainer can weigh in on whether that's in scope for this issue or a separate one. Verification Reproduced and verified live in headless Blender 4.5.8 LTS, loading Bonsai from source (not the real profile, BLENDER_USER_RESOURCES isolated). Before the fix (confirmed by stashing the change and rerunning): === loading lib1 (Foobar) === project classifications after adding lib1's: ['Foobar'] === loading lib2 (Uniclass 2015) === project classifications after adding lib2's: ['Foobar', 'Uniclass 2015'] has classification_files attr: False current IfcStore.classification_file entities (should be lib2's only, this is the reported bug): ['Uniclass 2015'] Both classifications are in the project, but only the last-loaded library's entities are reachable, matching the two screenshots in the issue. After the fix: classification_files keys: ['.../classification.ifc', '.../lib2.ifc'] current IfcStore.classification_file entities (should be lib2's only, this is the reported bug): ['Uniclass 2015'] === FIX CHECK: switching loaded_classification_library back to lib1 WITHOUT reloading from disk === IfcStore.classification_file entities after switching dropdown to lib1: ['Foobar'] ClassificationsData.data['available_classifications']: [('2', 'Foobar', '')] Switching the new dropdown restores lib1's entities without touching disk again. Also ran a full FILE-mode workflow regression (load library, add classification, assign an IfcWallType, browse the reference hierarchy with bim.change_classification_level, add/remove a classification reference on an object, remove the classification) end to end in the same environment, all passing, confirming the existing single-library flow the .feature scenarios cover is unaffected. Linted with the project's black + ruff config, both clean. Merge order: this is independent of #8920, the built-in library picker for #4613. Both add a dropdown in the same panel and touch the same lines, so whichever merges second needs a small keep-both rebase. Generated with the assistance of an AI coding tool.
Open Graph Description: Fixes #4612. Root cause IfcStore.classification_file (bonsai/bim/ifc.py) is a single global that gets overwritten by every bim.load_classification_library call. The FILE-mode "Available Classi...
X Description: Fixes #4612. Root cause IfcStore.classification_file (bonsai/bim/ifc.py) is a single global that gets overwritten by every bim.load_classification_library call. The FILE-mode "Available Cl...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/pull/8941
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:41896fa9-5bf3-d15b-ebfc-d97232e1e8b8 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8F82:376887:4683CE:5E2C5F:6B04F48A |
| html-safe-nonce | 4a36d80b0e761958e8de0bbe8c940c72cb6b80ab0d2296c8e16c6badf0a87b61 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjgyOjM3Njg4Nzo0NjgzQ0U6NUUyQzVGOjZCMDRGNDhBIiwidmlzaXRvcl9pZCI6IjExMTQ5MzAzNjAzMDA2NjM5NDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 60d88bf6dc20c674322557c8b6201dcb671e9b98083b9b22e55449f6eae3fabb |
| hovercard-subject-tag | pull_request:4130925094 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/IfcOpenShell/IfcOpenShell/pull/8941/files |
| twitter:image | https://avatars.githubusercontent.com/u/139251053?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/139251053?s=400&v=4 |
| og:image:alt | Fixes #4612. Root cause IfcStore.classification_file (bonsai/bim/ifc.py) is a single global that gets overwritten by every bim.load_classification_library call. The FILE-mode "Available Classi... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2c3971d6ab4be607cf9a26ac26ef0a7bfce380ec2ba14642e64028ad07a492b9 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b3f1d45dee14b3f87c64e9017a9c08d011561786 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width