Title: Opening applied to sole instance of a typed/mapped representation silently disappears in Object mode · Issue #9348 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Opening applied to sole instance of a typed/mapped representation silently disappears in Object mode · Issue #9348 · IfcOpenShell/IfcOpenShell
X Title: Opening applied to sole instance of a typed/mapped representation silently disappears in Object mode · Issue #9348 · IfcOpenShell/IfcOpenShell
Description: Summary When an IfcOpeningElement voids an element that is the sole occurrence of a shared/type representation (e.g. a MappedRepresentation from an IfcElementType), the element's Body geometry silently disappears in Bonsai's Object mode ...
Open Graph Description: Summary When an IfcOpeningElement voids an element that is the sole occurrence of a shared/type representation (e.g. a MappedRepresentation from an IfcElementType), the element's Body geometry sile...
X Description: Summary When an IfcOpeningElement voids an element that is the sole occurrence of a shared/type representation (e.g. a MappedRepresentation from an IfcElementType), the element's Body geometry ...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/9348
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Opening applied to sole instance of a typed/mapped representation silently disappears in Object mode","articleBody":"## Summary\n\nWhen an `IfcOpeningElement` voids an element that is the **sole occurrence** of a shared/type representation (e.g. a `MappedRepresentation` from an `IfcElementType`), the element's Body geometry silently disappears in Bonsai's Object mode — no exception, no warning/error logged, mesh ends up with 0 vertices. Edit mode / Item mode still show the geometry correctly, since those bypass this code path entirely.\n\nReproduced with `IfcRoofType`/`IfcRoof` and `IfcWallType`/`IfcWall` alike — this is not element-class-specific.\n\n## Root cause\n\n`IfcGeom::mapping::reuse_ok_()` in [`src/ifcgeom/mapping/mapping.cpp`](https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcgeom/mapping/mapping.cpp):\n\n```cpp\nbool mapping::reuse_ok_(const IfcSchema::IfcProduct::list::ptr& products) {\n if (settings_.get\u003csettings::UseWorldCoords>().get()) return false;\n if (products->size() == 1) return true; // \u003c-- short-circuits before the openings check below\n for (...) {\n if (!DisableOpeningSubtractions && find_openings(product)->size()) return false;\n ...\n }\n return ...;\n}\n```\n\n`reuse_ok_` is called from `mapping::get_representations()` on a product list that has already been narrowed by whatever `include=` filter the caller supplied to `ifcopenshell.geom.iterator` (e.g. Bonsai's `reimport_element_representations`, which scopes the iterator to just the occurrence(s) being reimported). Whenever that filtered list happens to contain exactly one product — the common case when editing the only instance of a type — the `products->size() == 1` fast path returns `true` **without ever reaching the `find_openings()` check**, regardless of whether that single product actually has an opening.\n\nBecause reuse is (incorrectly) reported as OK, geometry generation proceeds down the shared/reuse path instead of computing an individual cut shape for the occurrence. The resulting shape ends up attributed to a different product than the one requested (or to the type product, which typically has no consuming scene object in downstream tooling), so the actually-edited occurrence never receives updated geometry. Nothing throws or logs an error, so the failure is silent.\n\nWith **two or more** products in the filtered list, the loop's `find_openings()` check runs as intended, correctly disqualifies reuse, and each occurrence is processed individually — which is why the bug only manifests for singleton occurrences and is easy to miss in testing (any file with ≥2 instances of the affected type masks it).\n\n## Reproduction\n\n1. Create a mesh-based `IfcElementType` (e.g. `IfcRoofType` or `IfcWallType`) with a `Body`/`MappedRepresentation`.\n2. Create exactly **one** occurrence of that type in the model.\n3. Void the occurrence with an `IfcOpeningElement` (`IfcRelVoidsElement`).\n4. Regenerate/reimport the occurrence's Body representation (in Bonsai: this happens automatically after adding the opening).\n\n**Observed:** the occurrence's mesh comes back with 0 vertices/faces in Object mode. `ifcopenshell.geom.create_shape()` called directly on the element returns correct, non-empty geometry with the opening properly subtracted — confirming the boolean/CSG kernel itself is not at fault. The bug is entirely in the reuse-detection short-circuit above.\n\n**Workaround:** add a second occurrence of the same type (or unlink the occurrence from its type, converting the representation to an immediate/non-shared one) — either avoids the buggy code path.\n\n## Suggested fix\n\nDon't let the `size() == 1` fast path bypass the openings check — e.g. only take the fast path when the single product also has no openings (and no other per-product disqualifying condition), so `reuse_ok_` degrades to running the same check it would for a multi-product list.\n\n## Environment\n\n- Investigated against the `v0.8.0` branch of this repo.\n- Confirmed via direct `ifcopenshell.geom.create_shape()` calls and by instrumenting `ifcopenshell.util.element.get_elements_by_representation` / `resolve_representation` / `tool.Loader.get_representation_id_from_shape` / `tool.Geometry.change_object_data` inside a running Bonsai session, comparing a reproducing single-occurrence case against a non-reproducing multi-occurrence case.\n","author":{"url":"https://github.com/sboddy","@type":"Person","name":"sboddy"},"datePublished":"2026-08-23T14:47:20Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/9348"}
| 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:d002c581-217d-ff57-d8da-1b0c54070022 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BCB6:3D1C6E:349669:4A0622:6B046D47 |
| html-safe-nonce | bcf5e7dd39c45893df124d84d19fc352260dc54f4a12c633048a0f7da06275f9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0I2OjNEMUM2RTozNDk2Njk6NEEwNjIyOjZCMDQ2RDQ3IiwidmlzaXRvcl9pZCI6IjM3NjE4MTUxNDAyNzkwMjA4NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 30e7b44fd2258e716c16933130b2d1fa82d984e8173cd149b6704c14edc82b8e |
| hovercard-subject-tag | issue:5227444189 |
| 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/9348/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a3350b06d3abac20934972aac10cee573ba27e2ee9e6bad4b1ad4d4343377568/IfcOpenShell/IfcOpenShell/issues/9348 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a3350b06d3abac20934972aac10cee573ba27e2ee9e6bad4b1ad4d4343377568/IfcOpenShell/IfcOpenShell/issues/9348 |
| og:image:alt | Summary When an IfcOpeningElement voids an element that is the sole occurrence of a shared/type representation (e.g. a MappedRepresentation from an IfcElementType), the element's Body geometry sile... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sboddy |
| hostname | github.com |
| expected-hostname | github.com |
| None | ae8802492f12d3ba4f6b0d814054e617a2a5616b6327bf8555c10cd5b0dc2a6f |
| 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 | cfb5f24c6e01d85f70804652a5107e5cac03a161 |
| 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