Title: [Bonsai][5D] Incorrect Total Cost when multiple IfcCostValue entries use different UnitBasis values · Issue #8625 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: [Bonsai][5D] Incorrect Total Cost when multiple IfcCostValue entries use different UnitBasis values · Issue #8625 · IfcOpenShell/IfcOpenShell
X Title: [Bonsai][5D] Incorrect Total Cost when multiple IfcCostValue entries use different UnitBasis values · Issue #8625 · IfcOpenShell/IfcOpenShell
Description: Bug Description [Bonsai][5D] Incorrect Total Cost when multiple IfcCostValue entries use different UnitBasis values Summary Bonsai displays an incorrect Total Cost when one IfcCostItem has multiple IfcCostValue records and those cost val...
Open Graph Description: Bug Description [Bonsai][5D] Incorrect Total Cost when multiple IfcCostValue entries use different UnitBasis values Summary Bonsai displays an incorrect Total Cost when one IfcCostItem has multiple...
X Description: Bug Description [Bonsai][5D] Incorrect Total Cost when multiple IfcCostValue entries use different UnitBasis values Summary Bonsai displays an incorrect Total Cost when one IfcCostItem has multiple...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/8625
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bonsai][5D] Incorrect Total Cost when multiple IfcCostValue entries use different UnitBasis values","articleBody":"### Bug Description\n\n# [Bonsai][5D] Incorrect Total Cost when multiple IfcCostValue entries use different UnitBasis values\n\n## Summary\n\nBonsai displays an incorrect **Total Cost** when one `IfcCostItem` has multiple `IfcCostValue` records and those cost values use different `UnitBasis` values.\n\nThis should be treated as a **high-priority 5D correctness bug** because the UI presents a plausible but wrong monetary total, and the wrong result remains after closing and reopening the cost schedule.\n\n## Environment\n\n- Bonsai: `0.8.6-alpha260628`\n- IfcOpenShell: `0.8.6-alpha260628`\n- IFC schema: `IFC4X3_ADD2`\n- Blender: `5.1.2`\n\n## Minimal reproduction\n\nCreate:\n\n- one `IfcCostSchedule`\n- one `IfcCostItem`\n- one `IfcQuantityArea` of `10 m²`\n- cost value A:\n - `AppliedValue = 5`\n - `UnitBasis = 2 m²`\n- cost value B:\n - `AppliedValue = 3`\n - `UnitBasis = 1 m²`\n - `Category = Labor`\n\nRelevant IFC lines from the minimal file:\n\n```ifc\n#70=IFCCOSTSCHEDULE('2wMdS_eYv8tuyUSBFKxMhv',$,'5D Sandbox',$,$,$,.BUDGET.,$,$,'2026-07-16T11:29:56.010383');\n#71=IFCCOSTITEM('2L$doydbv518v51M84kxXv',$,'Test Item',$,$,'1',$,(#77,#81),(#76));\n#76=IFCQUANTITYAREA('Test Area',$,$,10.,$);\n#77=IFCCOSTVALUE($,$,IFCMONETARYMEASURE(5.),#78,$,$,$,$,$,$);\n#78=IFCMEASUREWITHUNIT(IFCAREAMEASURE(2.),#3);\n#81=IFCCOSTVALUE('Labour - name',$,IFCMONETARYMEASURE(3.),#84,$,$,'Labor',$,$,$);\n#84=IFCMEASUREWITHUNIT(IFCAREAMEASURE(1.),#3);\n```\n\n## Expected result\n\nEach cost value should be calculated using its own `UnitBasis`:\n\n```text\n(10 / 2 × 5) + (10 / 1 × 3)\n= 25 + 30\n= 55\n```\n\n## Actual result\n\nBonsai displays:\n\n```text\nQuantity: 10.00 m²\nValue: 8.00\nTotal Cost: 80.00\n```\n\nClosing and reopening the cost schedule still shows `80.00`, so this is not a stale UI cache.\n\nIndependent calculation through `ifcopenshell.util.cost.calculate_applied_value` gives the correct result of `55.00`.\n\n## Likely cause\n\nIn `src/bonsai/bonsai/bim/module/cost/data.py`, `_load_cost_values()`:\n\n1. sums all `AppliedValue` values into one `TotalAppliedValue`;\n2. overwrites `UnitBasisValueComponent` while iterating;\n3. applies only the last encountered unit basis to the combined applied value.\n\nConceptually, the current result becomes:\n\n```text\n(5 + 3) × 10 / 1 = 80\n```\n\nwhereas each `IfcCostValue` needs to be extended separately by the cost quantity and its own `UnitBasis`, then summed.\n\n## Suggested correction\n\nCalculate the extended cost per `IfcCostValue`:\n\n```text\nsum(\n quantity / unit_basis_value * applied_value\n for each cost value\n)\n```\n\nwith the existing no-unit-basis behaviour preserved per value.\n\n## Attachments\n\n- Minimal IFC regression fixture: `5D_Sandbox_01(4).ifc`\n- Screenshot showing Bonsai total of `80.00`\n\n\n### Attachments\n\n\u003cimg width=\"1362\" height=\"940\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/95c89500-4e83-43e9-8c81-713cd051fb14\" />\n\n[5D_Sandbox_Mixed_UnitBasis.ifc.txt](https://github.com/user-attachments/files/30080368/5D_Sandbox_Mixed_UnitBasis.ifc.txt)\n\n### Debug and Error Output\n\n```true\n\n```","author":{"url":"https://github.com/john-rogers","@type":"Person","name":"john-rogers"},"datePublished":"2026-07-16T08:21:26Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/8625"}
| 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:cf0ea2a5-ca46-1604-a8b3-a71dbcab95b3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A938:22E53E:6DE5A2:937543:6B04AA5A |
| html-safe-nonce | 7fbf84631ceb76a8587379adf4e53d5dd600b4a72cb86322c55823a0d35a6c17 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTM4OjIyRTUzRTo2REU1QTI6OTM3NTQzOjZCMDRBQTVBIiwidmlzaXRvcl9pZCI6IjE2MTQ0NTk3OTU4MzcwNjk5MTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 49d70b32cf2b266f9b865c88840567e923efe412ae73292917c8948600a9e27d |
| hovercard-subject-tag | issue:4900122009 |
| 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/8625/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fd9e984a3315cb6cf9aa67314fd17c86df73c4e1cdd4ed7f5bee8c6680497936/IfcOpenShell/IfcOpenShell/issues/8625 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fd9e984a3315cb6cf9aa67314fd17c86df73c4e1cdd4ed7f5bee8c6680497936/IfcOpenShell/IfcOpenShell/issues/8625 |
| og:image:alt | Bug Description [Bonsai][5D] Incorrect Total Cost when multiple IfcCostValue entries use different UnitBasis values Summary Bonsai displays an incorrect Total Cost when one IfcCostItem has multiple... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | john-rogers |
| hostname | github.com |
| expected-hostname | github.com |
| None | 188497a0f45a7aa8f7c866faa1950d1a7f8d82b59416adf549b222ad1d1dd19b |
| 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 | 557cfbac6cdb532730c95c90f2cefdc0c4128029 |
| 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