Title: regenerate_wall_representation raises TypeError when IfcRelConnectsPathElements has RelatingPriorities/RelatedPriorities · Issue #10054 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: regenerate_wall_representation raises TypeError when IfcRelConnectsPathElements has RelatingPriorities/RelatedPriorities · Issue #10054 · IfcOpenShell/IfcOpenShell
X Title: regenerate_wall_representation raises TypeError when IfcRelConnectsPathElements has RelatingPriorities/RelatedPriorities · Issue #10054 · IfcOpenShell/IfcOpenShell
Description: Bug Description ifcopenshell.api.geometry.regenerate_wall_representation raises TypeError when the wall's IfcRelConnectsPathElements carries per-connection priorities (RelatingPriorities / RelatedPriorities): TypeError: 'PrioritisedLayer...
Open Graph Description: Bug Description ifcopenshell.api.geometry.regenerate_wall_representation raises TypeError when the wall's IfcRelConnectsPathElements carries per-connection priorities (RelatingPriorities / RelatedP...
X Description: Bug Description ifcopenshell.api.geometry.regenerate_wall_representation raises TypeError when the wall's IfcRelConnectsPathElements carries per-connection priorities (RelatingPriorities / Rela...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/10054
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"regenerate_wall_representation raises TypeError when IfcRelConnectsPathElements has RelatingPriorities/RelatedPriorities","articleBody":"### Bug Description\n\n`ifcopenshell.api.geometry.regenerate_wall_representation` raises `TypeError` when the wall's `IfcRelConnectsPathElements` carries per-connection priorities (`RelatingPriorities` / `RelatedPriorities`):\n\n```\nTypeError: 'PrioritisedLayer' object does not support item assignment\n```\n\n**Versions:** IfcOpenShell 0.9.0 (Python 3.11.14, macOS arm64). The same lines are on the current `v0.9.0` branch (`src/ifcopenshell-python/ifcopenshell/api/geometry/regenerate_wall_representation.py` L573–575) and in the 0.8.5 copy bundled with Bonsai 0.8.5.\n\n**Steps to reproduce** (script below; only IfcOpenShell + NumPy):\n\n1. IFC4 file with Model/Body and Plan/Axis contexts and one `IfcMaterialLayerSet` (one 230 mm layer, priority 50).\n2. Two `IfcWall`s with `IfcMaterialLayerSetUsage` and an axis, meeting in an L.\n3. `ifcopenshell.api.geometry.connect_path(..., \"ATEND\", \"ATSTART\")`, then `rel.RelatingPriorities = [51]`, `rel.RelatedPriorities = [50]` (a butt: the first wall runs through).\n4. `ifcopenshell.api.geometry.regenerate_wall_representation(f, wall, height=3.0)` → `TypeError`.\n\n**Cause:** `Regenerator.combine_layers`:\n\n```python\nif override_priorities:\n for i, priority in enumerate(override_priorities[: len(layers)]):\n layers[i][0] = priority # layers[i] is a PrioritisedLayer namedtuple\n```\n\n**Expected:** the per-connection priorities replace the layer priorities for this connection, as IFC4 documents for `IfcRelConnectsPathElements.RelatingPriorities` / `RelatedPriorities`.\n\n**Suggested fix:**\n\n```diff\n- for i, priority in enumerate(override_priorities[: len(layers)]):\n- layers[i][0] = priority\n+ for i, priority in enumerate(override_priorities[: len(layers)]):\n+ layers[i] = layers[i]._replace(priority=priority)\n```\n\nWith that change (applied in the script as a subclass override, `--fixed`) the reproduction gives wall A 4.21935 m³ and wall B 2.68065 m³: A runs through to B's far face, total 6.9 m³ (= 2.3 m² × 3 m), as expected.\n\n**Why it matters:** `connect_path` writes `RelatingPriorities=[]`, so the default path never reaches this line. But per-connection priorities are the standard way to express a butt join between layered walls, and any file that carries them (from another authoring tool, or written by hand) cannot be regenerated.\n\n### Attachments\n\n\u003cdetails>\u003csummary>repro_priorities_typeerror.py — run with \u003ccode>python repro_priorities_typeerror.py\u003c/code> (TypeError) and \u003ccode>--fixed\u003c/code> (workaround)\u003c/summary>\n\n```python\n\"\"\"Minimal reproduction: IfcOpenShell 0.9.0 regenerate_wall_representation\nraises TypeError when an IfcRelConnectsPathElements carries per-connection\npriorities (RelatingPriorities / RelatedPriorities).\n\nRun (only IfcOpenShell + NumPy needed):\n\n python -I -B repro_priorities_typeerror.py # shows the TypeError\n python -I -B repro_priorities_typeerror.py --fixed # same model, workaround\n\nCause: ``Regenerator.combine_layers`` does ``layers[i][0] = priority`` on a\nlist of ``PrioritisedLayer`` namedtuples (regenerate_wall_representation.py,\naround L571-575 in 0.9.0); tuples are immutable.\n\"\"\"\nimport sys\n\nimport numpy as np\nimport ifcopenshell\nimport ifcopenshell.api.context\nimport ifcopenshell.api.geometry\nimport ifcopenshell.api.material\nimport ifcopenshell.api.project\nimport ifcopenshell.api.root\nimport ifcopenshell.api.unit\nimport ifcopenshell.geom\nimport ifcopenshell.util.element\nimport ifcopenshell.util.shape\nimport ifcopenshell.util.shape_builder\nfrom ifcopenshell.api.geometry.regenerate_wall_representation import PrioritisedLayer, Regenerator\n\n\nclass FixedRegenerator(Regenerator):\n \"\"\"Workaround: replace the tuple instead of assigning into it.\"\"\"\n\n def combine_layers(self, layers, override_priorities):\n layers = [PrioritisedLayer(*layer) for layer in layers]\n for i, priority in enumerate((override_priorities or [])[: len(layers)]):\n layers[i] = layers[i]._replace(priority=priority)\n results = []\n for layer in layers:\n if results and not layer.thickness:\n continue\n if results and layer.priority == results[-1].priority:\n results[-1] = PrioritisedLayer(layer.priority, results[-1].thickness + layer.thickness)\n else:\n results.append(layer)\n return results\n\n\ndef main(fixed: bool) -> int:\n f = ifcopenshell.api.project.create_file(version=\"IFC4\")\n ifcopenshell.api.root.create_entity(f, ifc_class=\"IfcProject\")\n ifcopenshell.api.unit.assign_unit(f, length={\"is_metric\": True, \"raw\": \"METERS\"})\n model = ifcopenshell.api.context.add_context(f, context_type=\"Model\")\n ifcopenshell.api.context.add_context(f, context_type=\"Model\", context_identifier=\"Body\",\n target_view=\"MODEL_VIEW\", parent=model)\n plan = ifcopenshell.api.context.add_context(f, context_type=\"Plan\")\n axis = ifcopenshell.api.context.add_context(f, context_type=\"Plan\", context_identifier=\"Axis\",\n target_view=\"GRAPH_VIEW\", parent=plan)\n layer_set = ifcopenshell.api.material.add_material_set(f, name=\"Brick 230\", set_type=\"IfcMaterialLayerSet\")\n layer = ifcopenshell.api.material.add_layer(f, layer_set=layer_set,\n material=ifcopenshell.api.material.add_material(f, name=\"Brick\"))\n ifcopenshell.api.material.edit_layer(f, layer=layer, attributes={\"LayerThickness\": 0.23, \"Priority\": 50})\n builder = ifcopenshell.util.shape_builder.ShapeBuilder(f)\n walls = []\n for name, origin, direction in ((\"A\", (0.0, 0.0), (1.0, 0.0)), (\"B\", (6.0, 0.0), (0.0, 1.0))):\n wall = ifcopenshell.api.root.create_entity(f, ifc_class=\"IfcWall\", name=name)\n ifcopenshell.api.material.assign_material(f, products=[wall], type=\"IfcMaterialLayerSetUsage\",\n material=layer_set)\n ifcopenshell.util.element.get_material(wall).OffsetFromReferenceLine = 0.115\n ifcopenshell.util.element.get_material(wall).DirectionSense = \"NEGATIVE\"\n ux, uy = direction\n ifcopenshell.api.geometry.edit_object_placement(f, product=wall, matrix=np.array(\n [[ux, -uy, 0, origin[0]], [uy, ux, 0, origin[1]], [0, 0, 1, 0], [0, 0, 0, 1]], dtype=float))\n ifcopenshell.api.geometry.assign_representation(f, product=wall, representation=builder.get_representation(\n axis, items=[builder.polyline([(0.0, 0.0), (6.0 if name == \"A\" else 4.0, 0.0)])]))\n walls.append(wall)\n rel = ifcopenshell.api.geometry.connect_path(f, relating_element=walls[0], related_element=walls[1],\n relating_connection=\"ATEND\", related_connection=\"ATSTART\")\n # A butt join: A's layer runs through B (IFC4 IfcRelConnectsPathElements.Relating/RelatedPriorities).\n rel.RelatingPriorities = [51]\n rel.RelatedPriorities = [50]\n print(f\"ifcopenshell {ifcopenshell.version}, Python {sys.version.split()[0]}\")\n try:\n for wall in walls:\n if fixed:\n FixedRegenerator(f).regenerate(wall, height=3.0)\n else:\n ifcopenshell.api.geometry.regenerate_wall_representation(f, wall, height=3.0)\n except TypeError as exc:\n print(f\"TypeError: {exc}\")\n return 1\n settings = ifcopenshell.geom.settings()\n volumes = [ifcopenshell.util.shape.get_volume(ifcopenshell.geom.create_shape(settings, w).geometry)\n for w in walls]\n print(\"volumes (A runs through B):\", [round(v, 6) for v in volumes], \"total\", round(sum(volumes), 6))\n return 0\n\n\nif __name__ == \"__main__\":\n raise SystemExit(main(\"--fixed\" in sys.argv))\n```\n\nThe workaround class is a copy of `combine_layers` with the one-line change; feel free to use it under IfcOpenShell's licence (LGPL-3.0-or-later).\n\u003c/details>\n\n### Debug and Error Output\n\n```\n$ python -I -B repro_priorities_typeerror.py\nifcopenshell 0.9.0, Python 3.11.14\nTypeError: 'PrioritisedLayer' object does not support item assignment\n$ python -I -B repro_priorities_typeerror.py --fixed\nifcopenshell 0.9.0, Python 3.11.14\nvolumes (A runs through B): [4.21935, 2.68065] total 6.9\n```\n\nA possibly related but separate observation, not part of this report: `connect_path` removes any existing `ATSTART`/`ATEND` relation at the same wall end, so with three or more walls meeting at one point only one relation survives and the regenerated solids overlap without an error. Happy to open a separate issue if that is not intended.\n","author":{"url":"https://github.com/konevenkatesh","@type":"Person","name":"konevenkatesh"},"datePublished":"2026-10-24T13:57:41Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/10054"}
| 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:5efe481d-2bc0-ad38-1bb9-4ddf4acb8372 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E3F2:15EB96:169DC1:1F6FF0:6B04658B |
| html-safe-nonce | 02b50b8d19c8d853bf25bb25eb940e9ee59e103a1285a8cc86595481c8a68758 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0YyOjE1RUI5NjoxNjlEQzE6MUY2RkYwOjZCMDQ2NThCIiwidmlzaXRvcl9pZCI6IjEwMzc5ODI3NTI3MjI2NzUwODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3bd77d541e3724dc8b789ef22ff777422d58173cfa4cc89315aa375e21410251 |
| hovercard-subject-tag | issue:6013694357 |
| 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/10054/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d2bb83cf9d446f9fbb11e4002e9c971dc73f98514b78cec7e569da8f27864e1/IfcOpenShell/IfcOpenShell/issues/10054 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d2bb83cf9d446f9fbb11e4002e9c971dc73f98514b78cec7e569da8f27864e1/IfcOpenShell/IfcOpenShell/issues/10054 |
| og:image:alt | Bug Description ifcopenshell.api.geometry.regenerate_wall_representation raises TypeError when the wall's IfcRelConnectsPathElements carries per-connection priorities (RelatingPriorities / RelatedP... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | konevenkatesh |
| 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