Title: Layered elements render as a single layer after reopening a .blend (unit scale not set on load) · Issue #9490 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Layered elements render as a single layer after reopening a .blend (unit scale not set on load) · Issue #9490 · IfcOpenShell/IfcOpenShell
X Title: Layered elements render as a single layer after reopening a .blend (unit scale not set on load) · Issue #9490 · IfcOpenShell/IfcOpenShell
Description: Open source IFC library and geometry engine. Contribute to IfcOpenShell/IfcOpenShell development by creating an account on GitHub.
Open Graph Description: Open source IFC library and geometry engine. Contribute to IfcOpenShell/IfcOpenShell development by creating an account on GitHub.
X Description: Open source IFC library and geometry engine. Contribute to IfcOpenShell/IfcOpenShell development by creating an account on GitHub.
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Layered elements render as a single layer after reopening a .blend (unit scale not set on load)","articleBody":"### Bug Description\n\nIn a project whose length unit is not metres, layered elements (walls, slabs, roofs, coverings) can render in the 3D viewport as a **single material** — the first layer's — covering the whole object, instead of showing their layers.\n\nWhat decides it is **how the session started**. It happens when Blender is launched and an existing `.blend` is opened (the everyday workflow), and it appears as soon as anything rebuilds an element's Body representation: editing the wall, joining, changing a layer thickness, Ctrl+E extend, etc. Importing the IFC instead, or creating a new project, does not reproduce it.\n\n#### Root cause\n\n`Loader.unit_scale` (`src/bonsai/bonsai/tool/loader.py`) is a class attribute defaulting to `1`. `Loader.set_unit_scale()` is called from only three places on `v0.9.0`:\n\n| Call site | Entry path |\n|---|---|\n| `import_ifc.py` | full IFC import |\n| `project/operator.py` `CreateProject` | new project (added for #7169) |\n| `project/operator.py` | large-project open path |\n\n`handler.loadIfcStore` — the `load_post` handler that restores a project when a `.blend` is opened — does not. So the whole session runs with `unit_scale == 1`.\n\nFor a project measured in metres that default is accidentally correct, which is why this is rarely seen. For any other project, every consumer of `Loader.unit_scale` is off by the unit scale factor.\n\nThe most visible victim is `Loader.slice_layerset_mesh()`, which places its bisect planes at `layer.LayerThickness * cls.unit_scale`. In a project measured in feet the planes land 1/0.3048 ≈ 3.28× too far out, so `bmesh.ops.bisect_plane()` never cuts and the first layer's band test claims every face. `has_layer_styles` is still set to `True`, so `material_creator.create()` early-returns and never repairs it. The mesh ends up with the correct material slots but every face on slot 0.\n\n#### Trace\n\nInstrumented `slice_layerset_mesh`, 3-layer wall, project in feet:\n\n```\n[layerset] === IfcWall 2OT5ZlLin7ofUjRR$T9NT1 ===\n[layerset] tool.Loader.unit_scale = 1\n[layerset] mesh extent along normal: 0.000000 .. 0.253999 m\n[layerset] layer[0] 'GM_Red Hollow Clay Blocks' raw=0.46875 -> 0.468750m band 0.000000..0.468750\n[layerset] !! CUT PLANE at 0.468750 IS OUTSIDE the mesh (0.000000..0.253999)\n[layerset] layer[1] 'AIR GAP' raw=0.0625 -> 0.062500m band 0.468750..0.531250\n[layerset] !! CUT PLANE at 0.531250 IS OUTSIDE the mesh (0.000000..0.253999)\n[layerset] layer[0] 'GM_Red Hollow Clay Blocks' -> slot 0 faces_assigned=12\n[layerset] layer[1] 'AIR GAP' -> slot 1 faces_assigned=0\n[layerset] layer[2] 'BRICK - MODULAR ...' -> slot 2 faces_assigned=0\n[layerset] RESULT faces=6 material_index distribution={0: 6}\n```\n\nReplaying the real bmesh algorithm on that wall's geometry at both values:\n\n```\nunit_scale = 0.3048 -> polys=14 {0:5, 1:4, 2:5} (correct)\nunit_scale = 1.0 -> polys=6 {0:6} (observed)\n```\n\nSame wall, same layer set — the only difference is session state. A wall that was *correct* in the saved `.blend` broke in exactly this way once it was regenerated in a `unit_scale == 1` session.\n\n#### Note on thin elements\n\nIf an element is thin enough that the first over-scaled plane still falls inside it, it *does* get cut — in the wrong place, and the remaining layers are lost. The result looks plausibly layered but is wrong: an OSB / stud / OSB wall came out with the OSB face at 3.28× its thickness and the outer OSB layer missing entirely. So \"it looks layered\" is not evidence of correctness, and the blast radius is wider than the obviously-single-material elements.\n\n#### Relationship to existing issues\n\n- #7169 (\"Layer Material Not showing in Active Model\") is the **same root cause**, closed by 0bb21fedae, which added `set_unit_scale` to `CreateProject` only. That fixed the new-project path; the `.blend`-reopen path was never covered.\n- #7537 (rotated slab, one layer fatter than designated) is a **different** cause.\n\n### Attachments\n\n_No response_\n\n### Debug and Error Output\n\n```true\nReproduced on Bonsai 0.8.6-alpha260708, Blender 5.2.1, project in feet.\nThe same gap is present on v0.9.0 HEAD (23f3874de1): loadIfcStore is unchanged there.\n```\n","author":{"url":"https://github.com/theoryshaw","@type":"Person","name":"theoryshaw"},"datePublished":"2026-09-13T13:36:06Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/9490"}
| 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/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:4e49441c-109b-7e4b-b934-df8cbfe8b204 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BF64:266CF3:6E81BF:923821:6B04C789 |
| html-safe-nonce | 5e44a395a677bdcbde203664a2721bf1641be81386d4b802297c6ff407e644ad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjY0OjI2NkNGMzo2RTgxQkY6OTIzODIxOjZCMDRDNzg5IiwidmlzaXRvcl9pZCI6IjIxNzE2NTA3NTY0NjAyMDE4NjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1e647d750a67d138c994a4f0bc4f93382d275b4a414fc4c204e8fb1be448975e |
| hovercard-subject-tag | repository:40473201 |
| 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/IfcOpenShell/IfcOpenShell/issues/9490 |
| twitter:image | https://opengraph.githubassets.com/28e4520c7d86b1b5225c8b336ba660404d70fd027548b7630a2530d57c89e9c2/IfcOpenShell/IfcOpenShell |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/28e4520c7d86b1b5225c8b336ba660404d70fd027548b7630a2530d57c89e9c2/IfcOpenShell/IfcOpenShell |
| og:image:alt | Open source IFC library and geometry engine. Contribute to IfcOpenShell/IfcOpenShell development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 85dd75377eb77313206b8fc108bcee6a3a029286d94bf32bf9b4426e4d92e0c4 |
| turbo-cache-control | no-cache |
| 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 | 0d64fa748a2bab9a5b587a967ac4da1cfa8da6dd |
| 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