René's URL Explorer Experiment


Title: copy_class shares the original's annotations with the duplicate, assigning them to two products (cause behind #4014) · Issue #9049 · IfcOpenShell/IfcOpenShell · GitHub

Open Graph Title: copy_class shares the original's annotations with the duplicate, assigning them to two products (cause behind #4014) · Issue #9049 · IfcOpenShell/IfcOpenShell

X Title: copy_class shares the original's annotations with the duplicate, assigning them to two products (cause behind #4014) · Issue #9049 · IfcOpenShell/IfcOpenShell

Description: Bug Description Duplicating a product that has annotations assigned to it (Shift+D in Bonsai, or ifcopenshell.api.root.copy_class directly) does not give the copy its own annotations, and does not leave the copy without annotations eithe...

Open Graph Description: Bug Description Duplicating a product that has annotations assigned to it (Shift+D in Bonsai, or ifcopenshell.api.root.copy_class directly) does not give the copy its own annotations, and does not ...

X Description: Bug Description Duplicating a product that has annotations assigned to it (Shift+D in Bonsai, or ifcopenshell.api.root.copy_class directly) does not give the copy its own annotations, and does not ...

Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/9049

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"copy_class shares the original's annotations with the duplicate, assigning them to two products (cause behind #4014)","articleBody":"### Bug Description\n\nDuplicating a product that has annotations assigned to it (Shift+D in Bonsai, or `ifcopenshell.api.root.copy_class` directly) does not give the copy its own annotations, and does not leave the copy without annotations either. It clones the `IfcRelAssignsToProduct` relationship, points the clone at the new product, and keeps the **original's annotations** in `RelatedObjects`. Both products then claim the same annotation entities, so every annotation involved ends up assigned to two products.\n\nThis appears to be the missing cause behind #4014. PR #8373 says as much in its own scope note: *\"this does not address how annotations accumulate multiple products in the first place (still under investigation via the diagnostic warning).\"* This is that path.\n\n**Minimal reproduction** (no Blender required):\n\n```python\nimport ifcopenshell, ifcopenshell.api.root, ifcopenshell.guid\n\nf = ifcopenshell.file(schema=\"IFC4\")\nwall = ifcopenshell.api.root.create_entity(f, ifc_class=\"IfcWall\")\nannotation = ifcopenshell.api.root.create_entity(f, ifc_class=\"IfcAnnotation\")\nf.create_entity(\"IfcRelAssignsToProduct\", GlobalId=ifcopenshell.guid.new(),\n                RelatedObjects=[annotation], RelatingProduct=wall)\n\ncopy = ifcopenshell.api.root.copy_class(f, product=wall)\n\nrels = [r for r in annotation.HasAssignments if r.is_a(\"IfcRelAssignsToProduct\")]\nprint(len(rels), [r.RelatingProduct.id() for r in rels])\n```\n\n```\nbefore: annotation assigned to 1 product(s)\nafter copy_class: annotation assigned to 2 product(s): [1, 4]   # original wall #1, copy #4\n```\n\n**Root cause.** In `src/ifcopenshell-python/ifcopenshell/api/root/copy_class.py`, `IfcRelAssignsToProduct` matches none of the special cases in `copy_indirect_attributes`, so it falls through to the generic `else` branch:\n\n```python\nelse:\n    for i, value in enumerate(inverse):\n        if value == from_element:\n            new_inverse = ifcopenshell.util.element.copy(self.file, inverse)\n            new_inverse[i] = to_element\n```\n\n`value == from_element` matches at `RelatingProduct`, so the whole relationship is copied and only that one attribute is swapped. `RelatedObjects` — the original's annotations — is carried over untouched.\n\n**Impact in a real project.** In a production model of mine, 60 of 808 annotations are assigned to more than one product, across 22 rel-sets that are exact clones (same `RelatedObjects`, different `RelatingProduct`). One `IfcSpace` was duplicated twice, so a single annotation is now assigned to three spaces:\n\n```\nannotation #3542995\n    via rel #3543012 -> #3540997  IfcSpace 06XX6WklnFdeYNmzrdhn4i\n    via rel #3550684 -> #3550678  IfcSpace 3LKyBBG0LDLwxBGxvi_Qyn\n    via rel #3552280 -> #3552274  IfcSpace 2E30n7LafENhO3LEp8hJYt\n```\n\nThe practical consequence is that `tool.Drawing.get_assigned_product` returns whichever rel happens to come first, so an annotation can silently label the wrong element. `tool.Drawing.get_assigned_product_workaround` exists to paper over exactly this and prints the multi-product warning pointing at #4014.\n\n**Relationship to existing work.**\n\n- #6621 / PR #8032 fix the case where the *annotation* is duplicated (alone, or together with its product). I reimplemented `fix_assigns_to_product_after_duplication` from that PR verbatim and ran it against both scenarios: it fixes duplicating product + annotation together, but the guard `if not rel.is_a(\"IfcRelAssignsToProduct\") or new_elem not in rel.RelatedObjects: continue` skips this case entirely, because here the new element is the `RelatingProduct`, not a related object. The two fixes are complementary, not competing.\n- #8373 / #8374 clean up annotations that already have multiple products; they don't prevent them being created.\n\n**Suggested fix.** Skip the relationship when the element being copied is the `RelatingProduct`, the same way `IfcRelAggregates` and `IfcRelContainedInSpatialStructure` are already skipped when the copied element is on the relating side. The duplicate then simply starts with no annotations.\n\nThe opposite direction must keep working: when an *annotation* is copied it takes the list branch, which appends the copy to the same relationship, and that behaviour is what the copy-annotation-to-drawing feature relies on.\n\nNote this is a behaviour change for every `copy_class` caller, not just Bonsai's duplicate path: a duplicated product will no longer inherit assignments made *to* it through `IfcRelAssignsToProduct`, which can include objects other than annotations.\n","author":{"url":"https://github.com/theoryshaw","@type":"Person","name":"theoryshaw"},"datePublished":"2026-07-29T14:26:15Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/9049"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0e14310b-1e44-4d71-6605-4402101d0ccc
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB748:3C835:5BA3D5:80A17C:6B047566
html-safe-nonce9964c0393e40bd00bde862a1f547da66405b7095c97a2103e84326917e922ae0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzQ4OjNDODM1OjVCQTNENTo4MEExN0M6NkIwNDc1NjYiLCJ2aXNpdG9yX2lkIjoiMTYyMjY0MjQwNDMyMDYzODMxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac375c5e73e704de035513db230a9bbfab7a7ca02eba6160a753cf1fc471cfa286
hovercard-subject-tagissue:5010353641
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/9049/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3ddbf02949c1d24d820ea7a067b34f168b6c0c5658bea099f5e092df770cbc7c/IfcOpenShell/IfcOpenShell/issues/9049
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3ddbf02949c1d24d820ea7a067b34f168b6c0c5658bea099f5e092df770cbc7c/IfcOpenShell/IfcOpenShell/issues/9049
og:image:altBug Description Duplicating a product that has annotations assigned to it (Shift+D in Bonsai, or ifcopenshell.api.root.copy_class directly) does not give the copy its own annotations, and does not ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametheoryshaw
hostnamegithub.com
expected-hostnamegithub.com
None9c099f1b85def81ca352464c276510dfef32deaf3c305404e65b8d270284a58b
turbo-cache-controlno-preview
go-importgithub.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git
octolytics-dimension-user_id13692563
octolytics-dimension-user_loginIfcOpenShell
octolytics-dimension-repository_id40473201
octolytics-dimension-repository_nwoIfcOpenShell/IfcOpenShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id40473201
octolytics-dimension-repository_network_root_nwoIfcOpenShell/IfcOpenShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecf73f57448d52b3a7b619195e182b33d3b3454ca
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/IfcOpenShell/IfcOpenShell/issues/9049#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2F9049
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2F9049
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=IfcOpenShell%2FIfcOpenShell
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/9049
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/9049
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/9049
IfcOpenShellhttps://github.com/IfcOpenShell
IfcOpenShellhttps://github.com/IfcOpenShell/IfcOpenShell
Codehttps://github.com/IfcOpenShell/IfcOpenShell
Issues1.2k (1.2k)https://github.com/IfcOpenShell/IfcOpenShell/issues
Pull requests937 (937)https://github.com/IfcOpenShell/IfcOpenShell/pulls
Discussionshttps://github.com/IfcOpenShell/IfcOpenShell/discussions
Actionshttps://github.com/IfcOpenShell/IfcOpenShell/actions
Projectshttps://github.com/IfcOpenShell/IfcOpenShell/projects
Wikihttps://github.com/IfcOpenShell/IfcOpenShell/wiki
Security and qualityhttps://github.com/IfcOpenShell/IfcOpenShell/security
Insightshttps://github.com/IfcOpenShell/IfcOpenShell/insights
https://github.com/IfcOpenShell/IfcOpenShell
New issuehttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/9049
New issuehttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/9049
#9054https://github.com/IfcOpenShell/IfcOpenShell/pull/9054
copy_class shares the original's annotations with the duplicate, assigning them to two products (cause behind #4014)https://github.com/IfcOpenShell/IfcOpenShell/issues/9049#top
#9054https://github.com/IfcOpenShell/IfcOpenShell/pull/9054
Bonsaihttps://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22Bonsai%22
PR ProposedA PR has been proposed for this bug/feature.https://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22PR%20Proposed%22
https://github.com/theoryshaw
theoryshawhttps://github.com/theoryshaw
on Jul 29, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9049#issue-5010353641
#4014https://github.com/IfcOpenShell/IfcOpenShell/issues/4014
#8373https://github.com/IfcOpenShell/IfcOpenShell/pull/8373
#4014https://github.com/IfcOpenShell/IfcOpenShell/issues/4014
Duplicated object and annotation should get unique IfcRelAssignsToProduct #6621https://github.com/IfcOpenShell/IfcOpenShell/issues/6621
Closes #6621: Fix IfcRelAssignsToProduct on duplicate #8032https://github.com/IfcOpenShell/IfcOpenShell/pull/8032
Bonsai: clear all stale annotation products on linked-aggregate refresh (#4014) #8373https://github.com/IfcOpenShell/IfcOpenShell/pull/8373
drawing: clear all assigned products on annotation reassign in RefreshLinkedAggregate (#4014) #8374https://github.com/IfcOpenShell/IfcOpenShell/pull/8374
theoryshawhttps://github.com/theoryshaw
Bonsaihttps://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22Bonsai%22
on Jul 29, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9049#event-28666354484
theoryshawhttps://github.com/theoryshaw
on Jul 29, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9049#event-28670042889
Bonsai: hand the duplicated annotation to the duplicated product (#9049)https://github.com/IfcOpenShell/IfcOpenShell/commit/df35a8954bd39ca0a4612a965b420a8e5f97a03a
#9049https://github.com/IfcOpenShell/IfcOpenShell/issues/9049
df35a89https://github.com/IfcOpenShell/IfcOpenShell/commit/df35a8954bd39ca0a4612a965b420a8e5f97a03a
theoryshawhttps://github.com/theoryshaw
PR ProposedA PR has been proposed for this bug/feature.https://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22PR%20Proposed%22
on Jul 29, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9049#event-28670094210
https://github.com/theoryshaw
theoryshawhttps://github.com/theoryshaw
on Jul 29, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9049#issuecomment-5120526648
#9054https://github.com/IfcOpenShell/IfcOpenShell/pull/9054
#4014https://github.com/IfcOpenShell/IfcOpenShell/issues/4014
#4014 (comment)https://github.com/IfcOpenShell/IfcOpenShell/issues/4014#issuecomment-5120523808
#4014https://github.com/IfcOpenShell/IfcOpenShell/issues/4014
theoryshawhttps://github.com/theoryshaw
on Oct 2, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/9049#event-32361043244
Bonsai: hand the duplicated annotation to the duplicated product (#9049)https://github.com/IfcOpenShell/IfcOpenShell/commit/45dc5397611ec762ece615db33b22935ec670c81
#9049https://github.com/IfcOpenShell/IfcOpenShell/issues/9049
45dc539https://github.com/IfcOpenShell/IfcOpenShell/commit/45dc5397611ec762ece615db33b22935ec670c81
copy_class: don't share the original's annotations with the copy (Ifc…https://github.com/theoryshaw/IfcOpenShell/commit/ec0aca9f459cf7f8c595f94ec6a608f3cf230048
Ifc…https://github.com/IfcOpenShell/IfcOpenShell/issues/9049
ec0aca9https://github.com/theoryshaw/IfcOpenShell/commit/ec0aca9f459cf7f8c595f94ec6a608f3cf230048
Sign up for freehttps://github.com/signup?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/9049
Sign in to commenthttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/9049
Bonsaihttps://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22Bonsai%22
PR ProposedA PR has been proposed for this bug/feature.https://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22PR%20Proposed%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.