Title: IfcPatch: add MergeDuplicateContexts recipe to consolidate duplicate representation contexts · Issue #8701 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: IfcPatch: add MergeDuplicateContexts recipe to consolidate duplicate representation contexts · Issue #8701 · IfcOpenShell/IfcOpenShell
X Title: IfcPatch: add MergeDuplicateContexts recipe to consolidate duplicate representation contexts · Issue #8701 · IfcOpenShell/IfcOpenShell
Description: Feature Description Add a MergeDuplicateContexts ifcpatch recipe (and expose it in Bonsai's IFC Patch UI) that consolidates duplicate IfcGeometricRepresentationContext / IfcGeometricRepresentationSubContext entities. Problem it solves. A...
Open Graph Description: Feature Description Add a MergeDuplicateContexts ifcpatch recipe (and expose it in Bonsai's IFC Patch UI) that consolidates duplicate IfcGeometricRepresentationContext / IfcGeometricRepresentationS...
X Description: Feature Description Add a MergeDuplicateContexts ifcpatch recipe (and expose it in Bonsai's IFC Patch UI) that consolidates duplicate IfcGeometricRepresentationContext / IfcGeometricRepresentat...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/8701
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"IfcPatch: add MergeDuplicateContexts recipe to consolidate duplicate representation contexts","articleBody":"### Feature Description\n\nAdd a `MergeDuplicateContexts` ifcpatch recipe (and expose it in Bonsai's IFC Patch UI) that consolidates duplicate `IfcGeometricRepresentationContext` / `IfcGeometricRepresentationSubContext` entities.\n\n**Problem it solves.** A well-formed IFC has a single geometric representation context per `(ContextType, ContextIdentifier, TargetView)` combination (e.g. one `Model/Body/MODEL_VIEW`). Some authoring tools, merges, round-trips, and Bonsai's own clipboard paste (see the related bug report #8700) leave a model with two or more contexts that are identical in all three. This is non-conformant and breaks code that looks a context up by attributes: `ifcopenshell.util.representation.get_context()` returns only the first match, so geometry, material styles, or annotations attached to the others are silently orphaned. A common visible symptom is a layered wall rendering with a single material style because each layer's style hangs off a second, never-matched, Body context.\n\nToday there is no user-facing tool to repair such a file — a user has to hand-edit the IFC or run a bespoke script.\n\n**Proposed behaviour.** For each `(ContextType, ContextIdentifier, TargetView)` key, keep the first context, repoint every reference off the duplicates onto that survivor (via `ifcopenshell.util.element.replace_element`), remove the duplicates, and dedupe any SET-typed aggregate (e.g. `IfcProject.RepresentationContexts`) that would otherwise list the survivor twice. Top-level contexts and subcontexts are handled in separate passes so a subcontext is never merged into a parent context.\n\nUsage:\n\n```python\nifcpatch.execute({\"file\": model, \"recipe\": \"MergeDuplicateContexts\", \"arguments\": []})\n```\n\nIt takes no arguments, so it appears in the Bonsai IFC Patch dropdown with no parameters to configure. This mirrors the shape of the existing `MergeDuplicateTypes` / `MergeStyles` recipes.\n\nI have a working implementation and tests, and can open a PR.\n","author":{"url":"https://github.com/theoryshaw","@type":"Person","name":"theoryshaw"},"datePublished":"2026-07-17T13:16:33Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/8701"}
| 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:a877cfd4-7fea-4058-881f-c96ee4658002 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE4E:19AD56:165621:1DD9D4:6B04AE1D |
| html-safe-nonce | af202a2475cd214bfc3ccd1f1a4c54e55cd91c1ba77034252e66e5fa17f9e711 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTRFOjE5QUQ1NjoxNjU2MjE6MUREOUQ0OjZCMDRBRTFEIiwidmlzaXRvcl9pZCI6IjMyNzEzMjQzOTA0MDI2MDA0NzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9cc078f662190077cd28162f1fb3f65943ba444672537bc5a250739aa4eee5a0 |
| hovercard-subject-tag | issue:4911663099 |
| 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/8701/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3002ae8c4650b6ff1578217d1ff6a76477b69a0130b5cdceff7fc74405083bc6/IfcOpenShell/IfcOpenShell/issues/8701 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3002ae8c4650b6ff1578217d1ff6a76477b69a0130b5cdceff7fc74405083bc6/IfcOpenShell/IfcOpenShell/issues/8701 |
| og:image:alt | Feature Description Add a MergeDuplicateContexts ifcpatch recipe (and expose it in Bonsai's IFC Patch UI) that consolidates duplicate IfcGeometricRepresentationContext / IfcGeometricRepresentationS... |
| 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 | f1d110ea058a0915c1d8aa3fc2069fa15801e128f591e5762525abe77490ecb1 |
| 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 | ffa22a65e4c46d376940fe34b05e6a7e9c7fdb9b |
| 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