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 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-18 14:45:06 +03:00
commit 446430d2b3
2 changed files with 34 additions and 2 deletions

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();