Title: Inconsistency between get_element_value and set_element_value queries using indices · Issue #4687 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Inconsistency between get_element_value and set_element_value queries using indices · Issue #4687 · IfcOpenShell/IfcOpenShell
X Title: Inconsistency between get_element_value and set_element_value queries using indices · Issue #4687 · IfcOpenShell/IfcOpenShell
Description: It seems that queries used in selector's get_element_value should be fully supported by set_element_value and should set exactly the same attributes (e.g. it's important when someone want to export data to csv and them import it back, wi...
Open Graph Description: It seems that queries used in selector's get_element_value should be fully supported by set_element_value and should set exactly the same attributes (e.g. it's important when someone want to export...
X Description: It seems that queries used in selector's get_element_value should be fully supported by set_element_value and should set exactly the same attributes (e.g. it's important when someone want t...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/4687
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistency between get_element_value and set_element_value queries using indices","articleBody":"It seems that queries used in selector's `get_element_value` should be fully supported by `set_element_value` and should set exactly the same attributes (e.g. it's important when someone want to export data to csv and them import it back, without removing columns).\r\n \r\nCurrently, there is an inconsistency with use of indices - with `get_element_value` it's possible to use them at the end of the query but in `set_element_value` it's not possible.\r\n \r\n Example:\r\n \r\n```python\r\nimport ifcopenshell\r\nimport ifcopenshell.util.selector\r\n\r\nifc_file = ifcopenshell.file()\r\n\r\nlayer_set = ifc_file.create_entity(\"IfcMaterialLayerSet\")\r\n\r\nmaterial = ifc_file.create_entity(\"IfcMaterial\")\r\nmaterial.Name = \"1\"\r\nlayer = ifc_file.create_entity(\"IfcMaterialLayer\")\r\nlayer.Material = material\r\nlayer_set.MaterialLayers = [layer]\r\n\r\n# works consistently\r\nquery = \"item.0.Material.Name\"\r\nprint(ifcopenshell.util.selector.get_element_value(layer_set, query)) # 1\r\nifcopenshell.util.selector.set_element_value(ifc_file, layer_set, query, \"2\")\r\nprint(material.Name) # 2\r\n\r\n# inconsistency\r\nquery = \"item.Material.Name.0\"\r\nprint(ifcopenshell.util.selector.get_element_value(layer_set, query)) # 2\r\nifcopenshell.util.selector.set_element_value(ifc_file, layer_set, query, \"3\")\r\n# error:\r\n# SetElementValueException:\r\n# Failed to set value for element '#3=IfcMaterialLayer(#2,$,$,$,$,$,$)' \r\n# with query '['Material', 'Name', '0']' (invalid or unsupported query).\r\nprint(material.Name)\r\n```\r\n\r\nAlso, to catch more errors like these I've added an exception during `set_element_value` in 39f5505, example error message - `# Failed to set value for element '# 3=IfcMaterialLayer(# 2,$,$,$,$,$,$)' with query '['Material', 'Name', '0']' (invalid or unsupported query).`.","author":{"url":"https://github.com/Andrej730","@type":"Person","name":"Andrej730"},"datePublished":"2024-05-17T13:27:17Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/4687"}
| 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:3a3fa7a6-d43a-db06-1f1b-7768d9d7dd7a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B524:399206:5EB389:7F7048:6B04A6FD |
| html-safe-nonce | 5500272ad52166feff532fd4d1326f75221e25206237907c9bad41e95e74d640 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTI0OjM5OTIwNjo1RUIzODk6N0Y3MDQ4OjZCMDRBNkZEIiwidmlzaXRvcl9pZCI6IjgwODM3MTUzMjU3ODg3MjcwMzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a4f292939e5d9e30b7b5674dda2012b09a40853d9eb3abd79b790ee85b8ed408 |
| hovercard-subject-tag | issue:2302756095 |
| 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/4687/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1e1a25047e6d9ca509205ba56203de8fa7fc3c2be50e1bb3f64d63645e21f35a/IfcOpenShell/IfcOpenShell/issues/4687 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1e1a25047e6d9ca509205ba56203de8fa7fc3c2be50e1bb3f64d63645e21f35a/IfcOpenShell/IfcOpenShell/issues/4687 |
| og:image:alt | It seems that queries used in selector's get_element_value should be fully supported by set_element_value and should set exactly the same attributes (e.g. it's important when someone want to export... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Andrej730 |
| 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