Title: Geometry iterator ignores a material's IfcSurfaceStyle when its IfcMaterialDefinitionRepresentation has more than one IfcStyledItem · Issue #10111 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Geometry iterator ignores a material's IfcSurfaceStyle when its IfcMaterialDefinitionRepresentation has more than one IfcStyledItem · Issue #10111 · IfcOpenShell/IfcOpenShell
X Title: Geometry iterator ignores a material's IfcSurfaceStyle when its IfcMaterialDefinitionRepresentation has more than one IfcStyledItem · Issue #10111 · IfcOpenShell/IfcOpenShell
Description: Bug Description When an IfcMaterial has a surface style, the geometry iterator uses that style's colour for the shapes. This stops working as soon as the material's IfcMaterialDefinitionRepresentation carries more than one IfcStyledItem....
Open Graph Description: Bug Description When an IfcMaterial has a surface style, the geometry iterator uses that style's colour for the shapes. This stops working as soon as the material's IfcMaterialDefinitionRepresentat...
X Description: Bug Description When an IfcMaterial has a surface style, the geometry iterator uses that style's colour for the shapes. This stops working as soon as the material's IfcMaterialDefinitionRep...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/10111
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Geometry iterator ignores a material's IfcSurfaceStyle when its IfcMaterialDefinitionRepresentation has more than one IfcStyledItem","articleBody":"### Bug Description\n\nWhen an `IfcMaterial` has a surface style, the geometry iterator uses that style's colour for the shapes. This stops working as soon as the material's `IfcMaterialDefinitionRepresentation` carries more than one `IfcStyledItem`. One example is a Body/MODEL_VIEW `IfcSurfaceStyleShading` together with an Annotation/Plan SECTION_VIEW `IfcFillAreaStyle`. In that case the element falls back to the default 0.9 grey, and I could not find any warning.\n\nThe result is the same:\n- whatever the order of the representations,\n- whether the representation identifier is 'Body' or 'Style',\n- and when the file is written entirely with `ifcopenshell.api.style.assign_material_style`.\n\nA section-view fill and a body shading in one material are both legitimate. `IfcMaterialDefinitionRepresentation.Representations` is a list, and a different context per view is how IFC4 expects a material to be styled for different views.\n\n**Repro** (IfcOpenShell 0.9.0.post1 from PyPI, Python 3, Linux; IFC4 and IFC4X3 behave the same):\n\n```python\nimport ifcopenshell, ifcopenshell.api, ifcopenshell.geom\n\ndef build(second_rep, schema=\"IFC4\"):\n f = ifcopenshell.api.run(\"project.create_file\", version=schema)\n ifcopenshell.api.run(\"root.create_entity\", f, ifc_class=\"IfcProject\", name=\"P\")\n ifcopenshell.api.run(\"unit.assign_unit\", f)\n model = ifcopenshell.api.run(\"context.add_context\", f, context_type=\"Model\")\n body = ifcopenshell.api.run(\"context.add_context\", f, context_type=\"Model\",\n context_identifier=\"Body\", target_view=\"MODEL_VIEW\", parent=model)\n wall = ifcopenshell.api.run(\"root.create_entity\", f, ifc_class=\"IfcWall\")\n rep = ifcopenshell.api.run(\"geometry.add_wall_representation\", f, context=body, length=5, height=3, thickness=0.2)\n ifcopenshell.api.run(\"geometry.assign_representation\", f, product=wall, representation=rep)\n mat = ifcopenshell.api.run(\"material.add_material\", f, name=\"M\")\n ifcopenshell.api.run(\"material.assign_material\", f, products=[wall], type=\"IfcMaterial\", material=mat)\n red = ifcopenshell.api.run(\"style.add_style\", f)\n ifcopenshell.api.run(\"style.add_surface_style\", f, style=red, ifc_class=\"IfcSurfaceStyleShading\",\n attributes={\"SurfaceColour\": {\"Name\": None, \"Red\": 1.0, \"Green\": 0.0, \"Blue\": 0.0}, \"Transparency\": 0.0})\n ifcopenshell.api.run(\"style.assign_material_style\", f, material=mat, style=red, context=body)\n if second_rep:\n plan = ifcopenshell.api.run(\"context.add_context\", f, context_type=\"Plan\")\n sec = ifcopenshell.api.run(\"context.add_context\", f, context_type=\"Plan\",\n context_identifier=\"Annotation\", target_view=\"SECTION_VIEW\", parent=plan)\n fill = f.createIfcFillAreaStyle(\"Hatch\", [f.createIfcColourRgb(None, 0.0, 1.0, 0.0)], False)\n ifcopenshell.api.run(\"style.assign_material_style\", f, material=mat, style=fill, context=sec)\n return f, wall, mat\n\nfor second in (False, True):\n f, wall, mat = build(second)\n n = len(mat.HasRepresentation[0].Representations)\n shape = ifcopenshell.geom.create_shape(ifcopenshell.geom.settings(), wall)\n print(\"representations:\", n,\n [(m.name, round(m.diffuse.r(), 2)) for m in shape.geometry.materials])\n```\n\n**Expected:** the second case also gives the red body shading (`r = 1.0`). The fill style belongs to a different context and is not a surface style.\n\n**Actual:**\n```\nrepresentations: 1 [('IfcSurfaceStyleShading-27', 1.0)]\nrepresentations: 2 [('IfcWall', 0.9)]\n```\n`ifcopenshell.geom.iterator` gives the same result.\n\n### Cause\n\n`mapping::map_impl(const IfcMaterial&)` gathers every `IfcStyledItem` from every `Representations` entry. It maps a style only when there is exactly one:\n\nhttps://github.com/IfcOpenShell/IfcOpenShell/blob/28bae192780ebd34936441f1f7bc1ffb9d282be9/src/ifcgeom/mapping/mapping.cpp#L594-L631\n\nThe condition is at L612:\nhttps://github.com/IfcOpenShell/IfcOpenShell/blob/28bae192780ebd34936441f1f7bc1ffb9d282be9/src/ifcgeom/mapping/mapping.cpp#L612\n\nWith two or more styled items, nothing is mapped and the function ends in `failed_on_purpose_.insert(material); return nullptr;`.\n\nRemoving that count check alone would not be enough. `map_impl(const IfcStyledItem&)` (L649) would warn \"Only IfcSurfaceStyle is supported\" and give up on the `IfcFillAreaStyle` item. A fix has to choose among the items rather than fail on the first.\n\nPossible directions; a maintainer may prefer another:\n- prefer styled items whose representation context is a MODEL_VIEW, 'Body' or 'Style' one, or\n- iterate over all styled items and use the first one that maps to a surface style, skipping curve, fill-area and text styles.\n\n### Related\n\n- #8662 and #8663 (material surface styles dropped by `append_asset`) touch the same data but a different code path.\n\n### Environment\n\nIfcOpenShell 0.9.0.post1 (PyPI wheel, CPython 3, Debian Linux x86_64). I checked the source at `28bae192780ebd34936441f1f7bc1ffb9d282be9` (2026-10-29, `main`), and the condition is unchanged there.\n","author":{"url":"https://github.com/GeneralPawz","@type":"Person","name":"GeneralPawz"},"datePublished":"2026-10-31T23:51:53Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/10111"}
| 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:fc0777fd-3072-5cb6-f35d-9dc28b8d6cac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E15E:208411:18EADE:2249D1:6B0465B4 |
| html-safe-nonce | f3049d2302eb3045380ac5d83f9ad6daea163abd56fbfa7646daba2cb4063c7f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTVFOjIwODQxMToxOEVBREU6MjI0OUQxOjZCMDQ2NUI0IiwidmlzaXRvcl9pZCI6IjU0OTYwNDY1MDExNjU4MTkzMTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 74768ad6c5edaa574c40dee74589d16de1cce7b52beda161cbd68adc33bfce36 |
| hovercard-subject-tag | issue:6141145225 |
| 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/10111/issue_layout |
| twitter:image | https://opengraph.githubassets.com/99527695330aa1a4928cc4e16bc45d6ced687b2b5b1a39e7fbe8338dd4a17cfb/IfcOpenShell/IfcOpenShell/issues/10111 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/99527695330aa1a4928cc4e16bc45d6ced687b2b5b1a39e7fbe8338dd4a17cfb/IfcOpenShell/IfcOpenShell/issues/10111 |
| og:image:alt | Bug Description When an IfcMaterial has a surface style, the geometry iterator uses that style's colour for the shapes. This stops working as soon as the material's IfcMaterialDefinitionRepresentat... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | GeneralPawz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| 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 | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| 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