Title: Bonsai: a reference on a sheet renders blank when its SVG ids collide with the titleblock's · Issue #9369 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Bonsai: a reference on a sheet renders blank when its SVG ids collide with the titleblock's · Issue #9369 · IfcOpenShell/IfcOpenShell
X Title: Bonsai: a reference on a sheet renders blank when its SVG ids collide with the titleblock's · Issue #9369 · IfcOpenShell/IfcOpenShell
Description: Bug Description A reference (references/*.svg) placed on a sheet renders blank. Only its view-title tag draws — the circle, the rule and the title text. All of the reference's actual content is missing, even though it is present in the b...
Open Graph Description: Bug Description A reference (references/*.svg) placed on a sheet renders blank. Only its view-title tag draws — the circle, the rule and the title text. All of the reference's actual content is mis...
X Description: Bug Description A reference (references/*.svg) placed on a sheet renders blank. Only its view-title tag draws — the circle, the rule and the title text. All of the reference's actual content is...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/9369
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bonsai: a reference on a sheet renders blank when its SVG ids collide with the titleblock's","articleBody":"### Bug Description\n\nA reference (`references/*.svg`) placed on a sheet renders blank. Only its view-title tag draws — the circle, the rule and the title text. All of the reference's actual content is missing, even though it is present in the built sheet SVG.\n\nThe cause is an SVG id collision with the titleblock.\n\nReferenced documents authored in Inkscape carry generic ids. In my case `references/testy.svg` clips its content layer with a bare presentation attribute:\n\n```xml\n\u003cclipPath clipPathUnits=\"userSpaceOnUse\" id=\"clipPath1\">\n \u003cpath d=\"M 0,0 H 4032 V 2880 H 0 Z\" id=\"path1\" />\n\u003c/clipPath>\n...\n\u003cg id=\"g1\" inkscape:groupmode=\"layer\" inkscape:label=\"G100\" clip-path=\"url(#clipPath1)\">\n```\n\nThe titleblock, also an Inkscape file, defines its own `clipPath1`:\n\n```xml\n\u003cclipPath clipPathUnits=\"userSpaceOnUse\" id=\"clipPath1\">\n \u003cpath d=\"M 0,194 H 300.48 V 0.559 H 0 Z\"\n transform=\"matrix(0.00332801,0,0,-0.00516956,0,1.002895)\" id=\"path1\" />\n\u003c/clipPath>\n```\n\nThat transform resolves to a **1×1 unit square at the origin**.\n\n`SheetBuilder.build_titleblock` and `SheetBuilder.build_documents` both inline their SVG verbatim, without namespacing ids — unlike `build_drawings`, which runs each drawing through `ensure_drawing_unique_styles`. The titleblock is inlined first, so the built sheet contains `id=\"clipPath1\"` twice, titleblock first. Duplicate ids are invalid SVG and renderers resolve `url(#…)` to the first match in document order, so the reference's content layer is clipped to the titleblock's 1×1 box and disappears.\n\nOn one sheet in my project, the titleblock and a single reference shared **274 duplicate ids**.\n\nThis is not specific to one file. Any Inkscape-authored reference is affected — a second sheet in the same project has the identical `clipPath1` collision, and the reference file I was copying from has the same structure.\n\n### Reproduce\n\n1. Author a reference SVG in Inkscape whose content layer uses `clip-path=\"url(#clipPath1)\"` — Inkscape emits this shape of markup on its own, e.g. after importing a PDF.\n2. Add it to a sheet that uses an Inkscape-authored titleblock.\n3. Create Sheets.\n4. Open the built sheet. The reference area is blank apart from its view-title tag.\n\nIn the built sheet:\n\n```\ngrep -c 'id=\"clipPath1\"' \"sheets/A09 - UNTITLED.svg\" # 2 — titleblock's wins\n```\n\n### Related, and why the existing PR does not cover it\n\nPR #8437 (for #7289) generalises `ensure_drawing_unique_styles` to `ensure_unique_ids` and applies it to referenced documents. It does not fix this case, for two reasons:\n\n1. It rewrites only `id`, `class`, `filter`, `style` and `\u003cuse>` hrefs. The reference here points at its clip through a **bare presentation attribute**, `clip-path=\"url(#clipPath1)\"`, not through `style`. So the `\u003cclipPath>` gets renamed while the pointer to it does not, and the now-dangling `url(#clipPath1)` still resolves to the titleblock's clip. The same blind spot applies to `mask`, `fill`/`stroke=\"url(#…)\"` and `marker-start`/`-mid`/`-end`, all common in Inkscape output.\n2. It does not process the titleblock, which is the other half of the collision and the one inlined first.\n\n### Suggested fix\n\nIn `src/bonsai/bonsai/bim/module/drawing/sheeter.py`:\n\n- Rewrite `url(#target)` in every presentation attribute that can hold one — `clip-path`, `mask`, `fill`, `stroke`, `filter`, `marker`/`-start`/`-mid`/`-end`, `cursor`, `color-profile` — alongside `style`, rather than special-casing `filter`.\n- Generalise local `#fragment` hrefs from `\u003cuse>` to any element, since gradients and patterns inherit from one another via `xlink:href`.\n- Run the titleblock through `ensure_unique_ids` as well, so every document inlined into a sheet is treated alike. `sheet.id()` works as its prefix and cannot collide with the document ids used for the other views.\n\nI have this working locally on top of #8437 and can open a PR. Measured against a project with 73 drawings, 3 references and 5 titleblocks: drawing output is byte for byte identical to before, 26 dangling references are repaired, and titleblocks change in `id` only — no class, style or presentation attribute is touched, and the `data-type` lookups `build_titleblock` performs afterwards still resolve.\n\n### Attachments\n\nThese are **minimal synthetic stand-ins**, not the files from my project — the real\ntitleblock carries client and consultant details I can't put on a public issue. They\nreproduce the collision identically, and are small enough to read end to end.\n\n**The failure, and the fix.** Both are sheets built by inlining the two files below,\nexactly as `SheetBuilder` does. Open them side by side:\n\n| Before | After |\n|---|---|\n| \u003cimg width=\"378\" alt=\"built sheet, reference missing\" src=\"https://github.com/user-attachments/assets/9a395bd3-10e8-44b4-8ca2-e38eebc216ee\" /> | \u003cimg width=\"378\" alt=\"built sheet, reference drawn\" src=\"https://github.com/user-attachments/assets/1b0bf7ce-20c6-4011-98c3-59c314e956d1\" /> |\n| 4 duplicate ids. The reference's `clip-path=\"url(#clipPath1)\"` resolves to the titleblock's clip — `M 0,194 H 300.48 V 0.559 H 0 Z` under a transform that collapses it to a 1×1 unit square — and the reference vanishes. | 0 duplicate ids. It resolves to its own `M 0,0 H 4032 V 2880 H 0 Z` and draws. |\n\n**The two inputs.**\n\n| `repro-reference.svg` | `repro-titleblock.svg` |\n|---|---|\n| \u003cimg width=\"160\" alt=\"reference, on its own\" src=\"https://github.com/user-attachments/assets/721c4607-e58e-4910-97bc-4698b0307b63\" /> | \u003cimg width=\"260\" alt=\"titleblock, on its own\" src=\"https://github.com/user-attachments/assets/84582173-b89f-4207-9c8d-5bd957b1450c\" /> |\n| Defines `clipPath1` covering its full extent, and clips its content layer through the bare `clip-path` presentation attribute — the markup Inkscape emits. Renders correctly on its own. | Defines its own `clipPath1`, the 1×1 one. Inlined into the sheet first, so its id wins every ambiguous lookup. |\n\nNote that the reference renders perfectly in isolation. It only disappears once it\nshares a sheet with the titleblock.\n\n### Debug and Error Output\n\nNo error is raised — the sheet builds successfully and the reference is simply invisible.\n\n```\nBonsai 0.8.6a260708\nBlender 4.5 and 5.2 (both reproduce)\nWindows 10\n```\n\n","author":{"url":"https://github.com/theoryshaw","@type":"Person","name":"theoryshaw"},"datePublished":"2026-08-28T01:21:19Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/9369"}
| 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:543aacb5-00ce-8994-8e05-e458affff2b2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B8C6:2366B8:79E6CF:A35051:6B04AD19 |
| html-safe-nonce | 408b7f7581622d8162a10948606a56bac9dd83cdd18d4873b28e0e217d84e5ba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEM2OjIzNjZCODo3OUU2Q0Y6QTM1MDUxOjZCMDRBRDE5IiwidmlzaXRvcl9pZCI6IjQxNTkzMTc4Mjk1NjI0NDUwODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 98d8456fdbe143b9ce29ab755a90cfc973416f47cffe45abede42c080e4c3e0b |
| hovercard-subject-tag | issue:5273681735 |
| 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/9369/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c9610677274b6906d33e66aa0f059b158c3a538325118bf6327b69ffb1f04aa1/IfcOpenShell/IfcOpenShell/issues/9369 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c9610677274b6906d33e66aa0f059b158c3a538325118bf6327b69ffb1f04aa1/IfcOpenShell/IfcOpenShell/issues/9369 |
| og:image:alt | Bug Description A reference (references/*.svg) placed on a sheet renders blank. Only its view-title tag draws — the circle, the rule and the title text. All of the reference's actual content is mis... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | theoryshaw |
| hostname | github.com |
| expected-hostname | github.com |
| None | f1d110ea058a0915c1d8aa3fc2069fa15801e128f591e5762525abe77490ecb1 |
| 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 | ffa22a65e4c46d376940fe34b05e6a7e9c7fdb9b |
| 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