Title: Update entity_instance.get_info() to have more control over error handling · Issue #2811 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Update entity_instance.get_info() to have more control over error handling · Issue #2811 · IfcOpenShell/IfcOpenShell
X Title: Update entity_instance.get_info() to have more control over error handling · Issue #2811 · IfcOpenShell/IfcOpenShell
Description: I received a huge ifc with some small errors. A few products where missing the ObjectPlacement entity. The file is huge and I am not the author, thus sharing is difficault but I created a simple ifc and commented the entity to show the p...
Open Graph Description: I received a huge ifc with some small errors. A few products where missing the ObjectPlacement entity. The file is huge and I am not the author, thus sharing is difficault but I created a simple if...
X Description: I received a huge ifc with some small errors. A few products where missing the ObjectPlacement entity. The file is huge and I am not the author, thus sharing is difficault but I created a simple if...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/2811
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Update entity_instance.get_info() to have more control over error handling","articleBody":"I received a huge ifc with some small errors. A few products where missing the ObjectPlacement entity. The file is huge and I am not the author, thus sharing is difficault but I created a simple ifc and commented the entity to show the problem. It can be downloaded in this post: https://github.com/yorikvanhavre/FreeCAD-NativeIFC/issues/23#issuecomment-1443364204\r\n\r\nthe following code is handled in IfcOS, if it is put in a try: except everything is fine ... \r\n\r\n```\r\ns = ifcfile[80]\r\ns.ObjectPlacement\r\n\r\ntry:\r\n s.ObjectPlacement\r\nexcept Exception:\r\n print(False)\r\n```\r\n\r\n\r\n```\r\n>>> \r\n>>> s = ifcfile[80]\r\n>>> s.ObjectPlacement\r\nTraceback (most recent call last):\r\n File \"\u003cinput>\", line 1, in \u003cmodule>\r\n File \"C:\\0_BHA_privat\\progr\\FreeCAD\\FreeCAD_0.21.xxxxx\\bin\\lib\\site-packages\\ifcopenshell\\entity_instance.py\", line 136, in __getattr__\r\n self.wrapped_data.get_argument(idx), self.wrapped_data.file\r\n File \"C:\\0_BHA_privat\\progr\\FreeCAD\\FreeCAD_0.21.xxxxx\\bin\\lib\\site-packages\\ifcopenshell\\ifcopenshell_wrapper.py\", line 4833, in get_argument\r\n return _ifcopenshell_wrapper.entity_instance_get_argument(self, *args)\r\nRuntimeError: Instance #77 not found\r\n>>> \r\n>>> try:\r\n... s.ObjectPlacement\r\n... except Exception:\r\n... print(False)\r\n... \r\nFalse\r\n>>> \r\n```\r\n\r\nBUT get.info() raises a unhandled Exception in IfcOpenShell, thus it does not help to put it in a try: except: the unhandled exception is raised anyway ...\r\n\r\n\r\n```\r\ns = ifcfile[80]\r\ns.get_info()\r\n\r\ntry:\r\n s.get_info()\r\nexcept Exception:\r\n print(False)\r\n```\r\n\r\n```\r\n>>> s = ifcfile[80]\r\n>>> s.get_info()\r\n{'id': 80, 'type': 'IfcSlab', 'GlobalId': '2JwE5lcKXFKvWOrg3uyxKD', 'OwnerHistory': #5=IfcOwnerHistory(#3,#4,$,.ADDED.,1677231549,#3,#4,1677231549), 'Name': 'Structure', 'Description': '', 'ObjectType': None, 'Representation': #79=IfcProductDefinitionShape($,$,(#78)), 'Tag': None, 'PredefinedType': 'NOTDEFINED'}\r\n>>> \r\n>>> try:\r\n... s.get_info()\r\n... except Exception:\r\n... print(False)\r\n... \r\n{'id': 80, 'type': 'IfcSlab', 'GlobalId': '2JwE5lcKXFKvWOrg3uyxKD', 'OwnerHistory': #5=IfcOwnerHistory(#3,#4,$,.ADDED.,1677231549,#3,#4,1677231549), 'Name': 'Structure', 'Description': '', 'ObjectType': None, 'Representation': #79=IfcProductDefinitionShape($,$,(#78)), 'Tag': None, 'PredefinedType': 'NOTDEFINED'}\r\n>>> \r\n```\r\n\r\nas said in both cases the following unhandled exception is raised ... \r\n\r\n```\r\n21:51:26 ERROR:root:unhandled exception occurred setting attribute name for #80=IfcSlab('2JwE5lcKXFKvWOrg3uyxKD',#5,'Structure','',$,#77,#79,$,.NOTDEFINED.)\r\nTraceback (most recent call last):\r\n File \"C:\\0_BHA_privat\\progr\\FreeCAD\\FreeCAD_0.21.xxxxx\\bin\\lib\\site-packages\\ifcopenshell\\entity_instance.py\", line 477, in _\r\n attr_value = self[i]\r\n File \"C:\\0_BHA_privat\\progr\\FreeCAD\\FreeCAD_0.21.xxxxx\\bin\\lib\\site-packages\\ifcopenshell\\entity_instance.py\", line 242, in __getitem__\r\n self.wrapped_data.get_argument(key), self.wrapped_data.file\r\n File \"C:\\0_BHA_privat\\progr\\FreeCAD\\FreeCAD_0.21.xxxxx\\bin\\lib\\site-packages\\ifcopenshell\\ifcopenshell_wrapper.py\", line 4833, in get_argument\r\n return _ifcopenshell_wrapper.entity_instance_get_argument(self, *args)\r\nRuntimeError: Instance #77 not found\r\n```\r\n\r\nIMHO this should not happen, or am I wrong?","author":{"url":"https://github.com/berndhahnebach","@type":"Person","name":"berndhahnebach"},"datePublished":"2023-02-26T20:51:58Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/2811"}
| 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:e564d489-b2c4-d3ce-7429-91d10e4b6b55 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B22A:20D380:6D63B1:95CEDD:6B047687 |
| html-safe-nonce | e15db846c874f8f4083861a156936b87242c045febb49fa0f2bc8e6811d67feb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjJBOjIwRDM4MDo2RDYzQjE6OTVDRUREOjZCMDQ3Njg3IiwidmlzaXRvcl9pZCI6IjE3OTczNTA4Njc3ODQyMDE4NjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d8d9277a9e7eefdaa32a3d719b0ff5da1c8964c76a76e2b13cd1f4c023303b21 |
| hovercard-subject-tag | issue:1600196962 |
| 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/2811/issue_layout |
| twitter:image | https://opengraph.githubassets.com/73843981fcfc7b273def96e8926d691f18aebdd5d5eca276003a88d225ea4853/IfcOpenShell/IfcOpenShell/issues/2811 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/73843981fcfc7b273def96e8926d691f18aebdd5d5eca276003a88d225ea4853/IfcOpenShell/IfcOpenShell/issues/2811 |
| og:image:alt | I received a huge ifc with some small errors. A few products where missing the ObjectPlacement entity. The file is huge and I am not the author, thus sharing is difficault but I created a simple if... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | berndhahnebach |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9c099f1b85def81ca352464c276510dfef32deaf3c305404e65b8d270284a58b |
| 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 | cf73f57448d52b3a7b619195e182b33d3b3454ca |
| 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