fix: regenerate inline sub-entity handles when copying entities

`document.add_entity` only assigns the top-level handle, leaving inline
sub-entities that carry their own — INSERT attributes and 3D-polyline
vertices — with the source's handles. Copying such an entity therefore
produced duplicate handles in the document, which corrupts the saved DWG
so other CAD apps (QCAD, DWG TrueView) refuse to open it.

Add `Scene::add_entity_clone` / `reset_clone_subhandles`, which allocate
fresh handles for the entity and every inline sub-entity, and route all
duplication paths through it: COPY/ARRAY/MIRROR-copy (via copy_entities)
and clipboard paste. (#129)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-18 14:45:06 +03:00
1 parent 70e73877b2
commit 446430d2b3
2 files changed
+34 -2

No files matched your search

+1 -2
View File
@@ -557,8 +557,7 @@ impl OpenCADStudio {
.into_iter()
.map(|mut entity| {
crate::scene::view::dispatch::apply_transform(&mut entity, &translate);
entity.common_mut().handle = acadrust::Handle::NULL;
self.tabs[i].scene.add_entity(entity)
self.tabs[i].scene.add_entity_clone(entity)
})
.filter(|h| !h.is_null())
.collect();