From 44c6ddc5139a61b4e6fddd71382908ac4d68b059 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Thu, 15 Oct 2026 20:36:35 +0300 Subject: [PATCH] fix(constraints): keep constraint groups the rebuild cannot write Saving `starttekening.dwg` unchanged lost 275 associative objects: the constraint network rebuilt before saving cannot write a dimensional constraint that drives a dynamic block's constraint parameter instead of a dimension, nor separate dependencies on single edges of one polyline. The block parameters ended up pointing at erased objects. A group with either link is now kept as read, through the existing preserved-group path; ODA counts the same 1948 associative proxies before and after. Co-Authored-By: Claude Opus 5.5 --- src/scene/dwg_native_constraints.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/scene/dwg_native_constraints.rs b/src/scene/dwg_native_constraints.rs index 78e8d29e5..9851f9b44 100644 --- a/src/scene/dwg_native_constraints.rs +++ b/src/scene/dwg_native_constraints.rs @@ -1727,7 +1727,26 @@ fn dependency_entity( } fn group_requires_preservation(document: &CadDocument, group: &Assoc2dConstraintGroup) -> bool { - group.nodes.iter().any(|node| { + // Links the rebuild does not write: a dimensional constraint driving a + // dynamic block's constraint parameter rather than a dimension, and + // single edges of one polyline each held by a dependency of its own. + let mut curves = Vec::new(); + let unmodelled = group.actions.iter().any(|handle| match document.objects.get(handle) { + Some(ObjectType::Associative(AssociativeObject { data, .. })) => match data { + AssociativeData::Dependency(dependency) => { + document.objects.contains_key(&dependency.dependent_on) + } + AssociativeData::GeomDependency(geometry) => { + let curve = geometry.dependency.dependent_on; + let repeated = curves.contains(&curve); + curves.push(curve); + repeated + } + _ => false, + }, + _ => false, + }); + unmodelled || group.nodes.iter().any(|node| { if matches!(node.data, AssocConstraintNodeData::RigidSet { .. }) { return true; }