Title: Bonsai: bind the MEP fitting start port even when no port is at the origin (#6249) by petruconduraru · Pull Request #8441 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Bonsai: bind the MEP fitting start port even when no port is at the origin (#6249) by petruconduraru · Pull Request #8441 · IfcOpenShell/IfcOpenShell
X Title: Bonsai: bind the MEP fitting start port even when no port is at the origin (#6249) by petruconduraru · Pull Request #8441 · IfcOpenShell/IfcOpenShell
Description: Refs #6249. This fixes the primary crash in the issue: while fitting flow segments, pack_return_data inside get_compatible_fitting_type raised UnboundLocalError: cannot access local variable 'start_port' where it is not associated with a value start_port was assigned only inside a loop that breaks when a fitting port sits exactly at the fitting's local origin. When get_compatible_fitting_type reuses an existing compatible fitting occurrence whose ports were not created parametrically at the origin (imported models, non BBIM fittings), no port satisfies the origin test, so start_port stayed unbound and the next line crashed. This selects the port closest to the origin with min over the ports by local placement length, which always binds start_port and is behavior preserving for the normal case, since a port at the origin has length 0 and is still chosen. Verified live in headless Blender 5.1.2 with a TRANSITION IfcPipeFitting occurrence whose two ports are both off the local origin, connected to typed pipe segments: before, get_compatible_fitting_type raised the exact UnboundLocalError; after, it returns the fitting type with a correct start port match. Note the issue thread bundles two more items left out of scope here: a separate double bend limitation (offset by non lateral axis not supported for a bend), and non crashing UI flip glitches. Test added on v0.9.0: The new test uses a real fitting whose ports are both off the origin and shows it is found and reused instead of failing an assertion. Generated with the assistance of an AI coding tool. Added 2026-10-07 after an independent re-run Corrections. This now says "Refs" for #6249. The file attached to that issue fails the same way with and without this change ("Detected an offset of 1e-05 along the local axis Y when lateral axis is X"), as the reporter pointed out on the issue. What this change fixes is the start port choice: with a fitting type whose first port is not exactly at the origin, a second bend raised after the ducts had already been trimmed in 3 of 5 variants on the merge base, and matches a control bend in 5 of 5 with the change (headless Blender 5.2; bends between ducts of the same type only). The error on the merge base is an AssertionError, not the UnboundLocalError named above, and the Blender version for these runs is 5.2.
Open Graph Description: Refs #6249. This fixes the primary crash in the issue: while fitting flow segments, pack_return_data inside get_compatible_fitting_type raised UnboundLocalError: cannot access local variable 's...
X Description: Refs #6249. This fixes the primary crash in the issue: while fitting flow segments, pack_return_data inside get_compatible_fitting_type raised UnboundLocalError: cannot access local variable &#...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/pull/8441
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:674f2251-77cf-3c5e-fd0a-76a956d09516 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D330:1F7E5E:3CB580:4EC291:6B050471 |
| html-safe-nonce | 42028b2cedf07b82ec52a5c82ecebae9ecd54db5cb9a99deed42d060674d40e7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzMwOjFGN0U1RTozQ0I1ODA6NEVDMjkxOjZCMDUwNDcxIiwidmlzaXRvcl9pZCI6IjI0MTg1MzQ3OTY3MTMzMjk3NzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3f45a00a151794220b78830676a7bed52fc66b3ce9adf728502f58eae04fd7d1 |
| hovercard-subject-tag | pull_request:4027380426 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/IfcOpenShell/IfcOpenShell/pull/8441/files |
| twitter:image | https://avatars.githubusercontent.com/u/139251053?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/139251053?s=400&v=4 |
| og:image:alt | Refs #6249. This fixes the primary crash in the issue: while fitting flow segments, pack_return_data inside get_compatible_fitting_type raised UnboundLocalError: cannot access local variable 's... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width