Title: Merge files / IfcPatch · Issue #1478 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Merge files / IfcPatch · Issue #1478 · IfcOpenShell/IfcOpenShell
X Title: Merge files / IfcPatch · Issue #1478 · IfcOpenShell/IfcOpenShell
Description: I tried to use the following script to merge multiple IFC-files into one model. These were exported from the same Revit file so the IfcProject, IfcSite, IfcBuilding and IfcBuildingStoreys are "identical" (all attributes, but not the STEP...
Open Graph Description: I tried to use the following script to merge multiple IFC-files into one model. These were exported from the same Revit file so the IfcProject, IfcSite, IfcBuilding and IfcBuildingStoreys are "iden...
X Description: I tried to use the following script to merge multiple IFC-files into one model. These were exported from the same Revit file so the IfcProject, IfcSite, IfcBuilding and IfcBuildingStoreys are "...
Mail addresses
andrej730@icloud.com
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/1478
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Merge files / IfcPatch ","articleBody":"I tried to use the following script to merge multiple IFC-files into one model. These were exported from the same Revit file so the IfcProject, IfcSite, IfcBuilding and IfcBuildingStoreys are \"identical\" (all attributes, but not the STEP-number). \r\n\r\n```\r\nimport ifcopenshell\r\n\r\nnew_file = ifcopenshell.file(schema='IFC4')\r\n\r\nold_files = list(map(ifcopenshell.open, [\r\n r'C:\\Users\\***\\walls.ifc',\r\n r'C:\\Users\\***\\win_doors.ifc',\r\n r'C:\\Users\\***\\rest.ifc'\r\n]))\r\n\r\nfor old in old_files:\r\n for inst in old:\r\n #print(inst)\r\n new_file.add(inst)\r\n\r\nprojects = new_file.by_type(\"IfcProject\")\r\n# Process all but the first project\r\nfor p in projects[1:]:\r\n # Get instances that relate to this project\r\n refs = new_file.get_inverse(p)\r\n is_project = lambda inst: inst == p\r\n assign_first = lambda inst: projects[0]\r\n # Assign the first project wherever the other project is assigned\r\n for ref in refs:\r\n for index, attr in enumerate(ref):\r\n ref[index] = ifcopenshell.entity_instance.walk(\r\n is_project,\r\n assign_first,\r\n ref[index])\r\n # Remove from file\r\n new_file.remove(p)\r\n\r\nnew_file.write(r'C:\\Users\\***\\federated.ifc')\r\n```\r\n\r\nHowever, this leads to an error that reads:\r\n\r\n> Traceback (most recent call last):\r\n> File \"C:/Users/***/AppData/Local/Programs/Python/Python38/ifc_merge.py\", line 52, in \u003cmodule>\r\n> new_file.add(inst)\r\n> File \"C:\\Users\\***\\AppData\\Local\\Programs\\Python\\Python38\\Lib\\ifcopenshell\\file.py\", line 128, in add\r\n> return entity_instance(self.wrapped_data.add(inst.wrapped_data))\r\n> File \"C:\\Users\\***\\AppData\\Local\\Programs\\Python\\Python38\\Lib\\ifcopenshell\\ifcopenshell_wrapper.py\", line 1524, in add\r\n> return _ifcopenshell_wrapper.file_add(self, entity)\r\n> RuntimeError: Unable to map instance to file\r\n\r\nAny ideas how to solve this?\r\n\r\n","author":{"url":"https://github.com/TZwielehner","@type":"Person","name":"TZwielehner"},"datePublished":"2021-05-20T14:24:04Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/1478"}
| 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:2d8d02b3-4ab6-1037-5d43-0980fd167e72 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD98:249B28:64A696:876E30:6B04A862 |
| html-safe-nonce | a5d284d53533a3cea26504cd99ffa16af27522665efc7e05cdae0d15f2100eaf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDk4OjI0OUIyODo2NEE2OTY6ODc2RTMwOjZCMDRBODYyIiwidmlzaXRvcl9pZCI6IjExNzcxNzk1ODA0NzQzNzAxNDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 25643f046b998294b128ab9fe06895b0c8a1ac137b045d82ce0bc89196f50c7a |
| hovercard-subject-tag | issue:896901532 |
| 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/1478/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fff1348aac028472df4c855ae9bc3a7937a622a25c742cd3a46648f23ba029f7/IfcOpenShell/IfcOpenShell/issues/1478 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fff1348aac028472df4c855ae9bc3a7937a622a25c742cd3a46648f23ba029f7/IfcOpenShell/IfcOpenShell/issues/1478 |
| og:image:alt | I tried to use the following script to merge multiple IFC-files into one model. These were exported from the same Revit file so the IfcProject, IfcSite, IfcBuilding and IfcBuildingStoreys are "iden... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TZwielehner |
| 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