René's URL Explorer Experiment


Title: calculate_unit_scale applies SI prefix linearly for SQUARE_METRE/CUBIC_METRE (DECI CUBIC_METRE = litre → volumes ×100) · Issue #9278 · IfcOpenShell/IfcOpenShell · GitHub

Open Graph Title: calculate_unit_scale applies SI prefix linearly for SQUARE_METRE/CUBIC_METRE (DECI CUBIC_METRE = litre → volumes ×100) · Issue #9278 · IfcOpenShell/IfcOpenShell

X Title: calculate_unit_scale applies SI prefix linearly for SQUARE_METRE/CUBIC_METRE (DECI CUBIC_METRE = litre → volumes ×100) · Issue #9278 · IfcOpenShell/IfcOpenShell

Description: Bug Description ifcopenshell.util.unit.calculate_unit_scale(model, unit_type) applies the SI prefix linearly, ignoring that for SQUARE_METRE / CUBIC_METRE the prefix attaches to the metre and is therefore raised to the power of the dimen...

Open Graph Description: Bug Description ifcopenshell.util.unit.calculate_unit_scale(model, unit_type) applies the SI prefix linearly, ignoring that for SQUARE_METRE / CUBIC_METRE the prefix attaches to the metre and is th...

X Description: Bug Description ifcopenshell.util.unit.calculate_unit_scale(model, unit_type) applies the SI prefix linearly, ignoring that for SQUARE_METRE / CUBIC_METRE the prefix attaches to the metre and is th...

Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/9278

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"calculate_unit_scale applies SI prefix linearly for SQUARE_METRE/CUBIC_METRE (DECI CUBIC_METRE = litre → volumes ×100)","articleBody":"### Bug Description\n\n`ifcopenshell.util.unit.calculate_unit_scale(model, unit_type)` applies the SI prefix\n**linearly**, ignoring that for `SQUARE_METRE` / `CUBIC_METRE` the prefix attaches to the\n*metre* and is therefore raised to the power of the dimension.\n\nFor `IFCSIUNIT(*,.VOLUMEUNIT.,.DECI.,.CUBIC_METRE.);` — a cubic decimetre, i.e. a **litre**,\nwhich real-world MEP exports declare as the project volume unit — it returns `0.1` instead of\n`0.1**3 = 0.001`, so every volume read through this scale factor is inflated **×100**.\n`AREAUNIT` is affected the same way (the error factor is 1/prefix: ×10 for DECI, ×100 for CENTI).\n\nIn SI, a prefix attached to a unit symbol forms a new inseparable symbol which is raised to\nthe power as a whole: dm³ means (dm)³ = 10⁻³ m³, not 0.1 m³. There is no SI construct meaning\n\"0.1 m³\", so the linear interpretation maps `DECI CUBIC_METRE` to a unit that does not exist.\n\nThe rest of `util/unit.py` already follows the exponent interpretation, so the module is\ninternally inconsistent:\n\n- `named_dimensions[\"VOLUMEUNIT\"] == (3, 0, 0, 0, 0, 0, 0)` ([unit.py#L178](https://github.com/IfcOpenShell/IfcOpenShell/blob/048242783eafe097eb9733eee9c99a4ded235682/src/ifcopenshell-python/ifcopenshell/util/unit.py#L178))\n- `convert()` multiplies the prefix multiplier twice for `SQUARE` and three times for `CUBIC`\n  unit names ([unit.py#L666-L684](https://github.com/IfcOpenShell/IfcOpenShell/blob/048242783eafe097eb9733eee9c99a4ded235682/src/ifcopenshell-python/ifcopenshell/util/unit.py#L666-L684))\n- `get_unit_symbol()` renders this exact unit as `dm3` ([unit.py#L624](https://github.com/IfcOpenShell/IfcOpenShell/blob/048242783eafe097eb9733eee9c99a4ded235682/src/ifcopenshell-python/ifcopenshell/util/unit.py#L624))\n\ni.e. the library *displays* the unit as dm³ (one litre) but *scales* it as 0.1 m³ (100 litres).\n\n### Minimal reproduction\n\n`minimal.ifc`:\n\n```\nISO-10303-21;\nHEADER;\nFILE_DESCRIPTION((''),'2;1');\nFILE_NAME('minimal.ifc','2026-08-07T00:00:00',(''),(''),'','','');\nFILE_SCHEMA(('IFC4'));\nENDSEC;\nDATA;\n#1=IFCPROJECT('0000000000000000000000',$,'UnitScaleRepro',$,$,$,$,$,#2);\n#2=IFCUNITASSIGNMENT((#3,#4,#5));\n#3=IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);\n#4=IFCSIUNIT(*,.AREAUNIT.,.DECI.,.SQUARE_METRE.);\n#5=IFCSIUNIT(*,.VOLUMEUNIT.,.DECI.,.CUBIC_METRE.);\nENDSEC;\nEND-ISO-10303-21;\n```\n\n```python\nimport ifcopenshell\nimport ifcopenshell.util.unit as uu\n\nmodel = ifcopenshell.open(\"minimal.ifc\")\nfor unit_type in (\"LENGTHUNIT\", \"AREAUNIT\", \"VOLUMEUNIT\"):\n    print(unit_type, uu.calculate_unit_scale(model, unit_type))\n```\n\n### Expected vs actual (ifcopenshell 0.8.5)\n\n| unit_type  | declaration       | meaning     | expected scale     | actual scale | error |\n| ---------- | ----------------- | ----------- | ------------------ | ------------ | ----- |\n| LENGTHUNIT | MILLI METRE       | mm          | 1e-3               | 1e-3         | OK    |\n| AREAUNIT   | DECI SQUARE_METRE | dm²         | (1e-1)² = **1e-2** | 1e-1         | ×10   |\n| VOLUMEUNIT | DECI CUBIC_METRE  | dm³ = litre | (1e-1)³ = **1e-3** | 1e-1         | ×100  |\n\n### Root cause\n\n[`calculate_unit_scale`, unit.py#L723 on current master](https://github.com/IfcOpenShell/IfcOpenShell/blob/048242783eafe097eb9733eee9c99a4ded235682/src/ifcopenshell-python/ifcopenshell/util/unit.py#L723)\n(line 718 in the 0.8.5 wheel):\n\n```python\nif unit.is_a(\"IfcSIUnit\"):\n    unit_scale *= get_prefix_multiplier(unit.Prefix)\n```\n\nThe prefix multiplier is applied to the first power regardless of `unit_type` / unit name.\n(The `IfcConversionBasedUnit` part of the chain is fine — the conversion factor carries the\nfull multiplier; a prefixed SI unit terminating the chain hits the same line above.)\n\n### Suggested fix\n\nMirror the logic `convert()` in the same module already uses:\n\n```python\nif unit.is_a(\"IfcSIUnit\"):\n    multiplier = get_prefix_multiplier(unit.Prefix)  # 1 when Prefix is None\n    if \"CUBIC\" in unit.Name:\n        multiplier **= 3\n    elif \"SQUARE\" in unit.Name:\n        multiplier **= 2\n    unit_scale *= multiplier\n```\n\nKeying on the unit *Name* (rather than on `named_dimensions[unit_type]`) keeps prefixed\nderived units such as KILO PASCAL or MEGA NEWTON linear, which is correct — there the prefix\nattaches to the derived unit itself, not to the metre.\n\n### Real-world impact\n\nIFC4 MEP exports (e.g. MagiCAD for Revit) declare\n`IFCSIUNIT(*,.VOLUMEUNIT.,.DECI.,.CUBIC_METRE.);` with quantity values in litres. Reading any\n`IfcQuantityVolume` through `calculate_unit_scale(model, \"VOLUMEUNIT\")` then inflates every\nvolume ×100 (confirmed on production files; caught by cross-validating quantities against an\nindependent source).\n\n### Environment\n\n- ifcopenshell 0.8.5 (PyPI wheel), Python 3.12, Linux\n- The same code is present on current master (`0482427`, permalink above)\n\n---\n\nI'm happy to submit a PR with the fix above plus a regression test for\n`calculate_unit_scale` with prefixed `SQUARE_METRE`/`CUBIC_METRE` units, if the\napproach looks right.","author":{"url":"https://github.com/RobertSigmundsson","@type":"Person","name":"RobertSigmundsson"},"datePublished":"2026-08-07T17:29:21Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/9278"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f26dd436-2734-e6a9-01ef-148af9516379
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE9D4:1CF439:37E00C:4A0F62:6B04B9E3
html-safe-nonce44b7af4de7e7c2905f8e2963e69f393c2fa1ecdaaf4bea553cff0687843bba99
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUQ0OjFDRjQzOTozN0UwMEM6NEEwRjYyOjZCMDRCOUUzIiwidmlzaXRvcl9pZCI6IjIwMTc4NjMxNDMxMTk5NjA1NDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacdac687b21bedd100293dac25a22e7b7c563d8b7946457cc93c8e18da400fa12e
hovercard-subject-tagissue:5092525623
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/9278/issue_layout
twitter:imagehttps://opengraph.githubassets.com/1d61899cab374767fe3dd9612f397974ac86ab65d5cf9c9951b2797a51b3b230/IfcOpenShell/IfcOpenShell/issues/9278
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/1d61899cab374767fe3dd9612f397974ac86ab65d5cf9c9951b2797a51b3b230/IfcOpenShell/IfcOpenShell/issues/9278
og:image:altBug Description ifcopenshell.util.unit.calculate_unit_scale(model, unit_type) applies the SI prefix linearly, ignoring that for SQUARE_METRE / CUBIC_METRE the prefix attaches to the metre and is th...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameRobertSigmundsson
hostnamegithub.com
expected-hostnamegithub.com
None378bd702ac792b3550e484ad39d9a898fcd25bb52ba6962b0c9cc457c1ea71c7
turbo-cache-controlno-preview
go-importgithub.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git
octolytics-dimension-user_id13692563
octolytics-dimension-user_loginIfcOpenShell
octolytics-dimension-repository_id40473201
octolytics-dimension-repository_nwoIfcOpenShell/IfcOpenShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id40473201
octolytics-dimension-repository_network_root_nwoIfcOpenShell/IfcOpenShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseb032e77f1ea437ede6c115446a0a467709b468e7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/IfcOpenShell/IfcOpenShell/issues/9278#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2F9278
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2F9278
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=IfcOpenShell%2FIfcOpenShell
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/9278
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/9278
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/9278
IfcOpenShellhttps://github.com/IfcOpenShell
IfcOpenShellhttps://github.com/IfcOpenShell/IfcOpenShell
Codehttps://github.com/IfcOpenShell/IfcOpenShell
Issues1.2k (1.2k)https://github.com/IfcOpenShell/IfcOpenShell/issues
Pull requests939 (939)https://github.com/IfcOpenShell/IfcOpenShell/pulls
Discussionshttps://github.com/IfcOpenShell/IfcOpenShell/discussions
Actionshttps://github.com/IfcOpenShell/IfcOpenShell/actions
Projectshttps://github.com/IfcOpenShell/IfcOpenShell/projects
Wikihttps://github.com/IfcOpenShell/IfcOpenShell/wiki
Security and qualityhttps://github.com/IfcOpenShell/IfcOpenShell/security
Insightshttps://github.com/IfcOpenShell/IfcOpenShell/insights
https://github.com/IfcOpenShell/IfcOpenShell
New issuehttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/9278
New issuehttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/9278
#9281https://github.com/IfcOpenShell/IfcOpenShell/pull/9281
calculate_unit_scale applies SI prefix linearly for SQUARE_METRE/CUBIC_METRE (DECI CUBIC_METRE = litre → volumes ×100)https://github.com/IfcOpenShell/IfcOpenShell/issues/9278#top
#9281https://github.com/IfcOpenShell/IfcOpenShell/pull/9281
https://github.com/RobertSigmundsson
RobertSigmundssonhttps://github.com/RobertSigmundsson
on Aug 7, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9278#issue-5092525623
unit.py#L178https://github.com/IfcOpenShell/IfcOpenShell/blob/048242783eafe097eb9733eee9c99a4ded235682/src/ifcopenshell-python/ifcopenshell/util/unit.py#L178
unit.py#L666-L684https://github.com/IfcOpenShell/IfcOpenShell/blob/048242783eafe097eb9733eee9c99a4ded235682/src/ifcopenshell-python/ifcopenshell/util/unit.py#L666-L684
unit.py#L624https://github.com/IfcOpenShell/IfcOpenShell/blob/048242783eafe097eb9733eee9c99a4ded235682/src/ifcopenshell-python/ifcopenshell/util/unit.py#L624
calculate_unit_scale, unit.py#L723 on current masterhttps://github.com/IfcOpenShell/IfcOpenShell/blob/048242783eafe097eb9733eee9c99a4ded235682/src/ifcopenshell-python/ifcopenshell/util/unit.py#L723
https://github.com/aothms
aothmshttps://github.com/aothms
on Aug 8, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9278#issuecomment-5223766178
aothmshttps://github.com/aothms
completedhttps://github.com/IfcOpenShell/IfcOpenShell/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#9281https://github.com/IfcOpenShell/IfcOpenShell/pull/9281
on Aug 9, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9278#event-29176268786
pullhttps://github.com/apps/pull
on Aug 9, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9278#event-29176787210
Fix IfcOpenShell#9278. calculate_unit_scale raises the SI prefix to t…https://github.com/ehtick/IfcOpenShell/commit/f05dd4aea529815c49be923e325d251694d9d3f1
IfcOpenShell#9278https://github.com/IfcOpenShell/IfcOpenShell/issues/9278
https://docs.github.com/articles/closing-issues-via-commit-messages
f05dd4ahttps://github.com/ehtick/IfcOpenShell/commit/f05dd4aea529815c49be923e325d251694d9d3f1
RickBricehttps://github.com/RickBrice
on Aug 10, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9278#event-29239113285
Fix calculate_unit_scale() crash on SQLite-linked fileshttps://github.com/IfcOpenShell/IfcOpenShell/commit/ae6eb4d18adf5b99032c994ad700e9bded054084
ae6eb4dhttps://github.com/IfcOpenShell/IfcOpenShell/commit/ae6eb4d18adf5b99032c994ad700e9bded054084
RickBricehttps://github.com/RickBrice
on Aug 28, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9278#event-30173947696
Fix calculate_unit_scale() crash on SQLite-linked fileshttps://github.com/IfcOpenShell/IfcOpenShell/commit/2bfcf8ab833837f27cb16507a49f51602d5edf54
2bfcf8ahttps://github.com/IfcOpenShell/IfcOpenShell/commit/2bfcf8ab833837f27cb16507a49f51602d5edf54
Sign up for freehttps://github.com/signup?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/9278
Sign in to commenthttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/9278
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.