From b961037b18f4fd029837f8b84d504059ab21429c Mon Sep 17 00:00:00 2001 From: forbes Date: Sat, 21 Feb 2026 22:04:18 -0600 Subject: [PATCH] fix(assembly): classify datum plane references in Distance joints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a Distance joint references a datum plane (XY_Plane, XZ_Plane, YZ_Plane), getDistanceType() failed to recognize it because datum plane sub-names yield an empty element type. This caused the fallback to DistanceType::Other → BaseJointKind::Planar, which adds spurious parallel-normal residuals that overconstrain the system. For example, three vertex-to-datum-plane Distance joints produced 10 residuals (3×Planar) with 6 mutually contradictory orientation constraints, causing the solver to find garbage least-squares solutions. Add early detection of App::Plane datum objects before the main geometry classification chain. Datum planes are now correctly mapped: - Vertex + DatumPlane → PointPlane → PointInPlane (1 residual) - Edge + DatumPlane → LinePlane → LineInPlane - Face/DatumPlane + DatumPlane → PlanePlane → Planar --- src/Mod/Assembly/App/AssemblyUtils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Mod/Assembly/App/AssemblyUtils.cpp b/src/Mod/Assembly/App/AssemblyUtils.cpp index 8ab3c064fd..064b777ce0 100644 --- a/src/Mod/Assembly/App/AssemblyUtils.cpp +++ b/src/Mod/Assembly/App/AssemblyUtils.cpp @@ -199,11 +199,11 @@ DistanceType getDistanceType(App::DocumentObject* joint) return DistanceType::LinePlane; } - // Face + datum or unknown + datum → PlanePlane - // Datum on Reference1 for consistency with Face+Face path. - if (!datum1) { - swapJCS(joint); // move datum from Ref2 → Ref1 - } + // Face + datum or unknown + datum → PlanePlane. + // No swap needed: PlanarConstraint is symmetric (uses both + // z_i and z_j), and preserving the original Reference order + // keeps the initial Placement values consistent so the solver + // stays in the correct orientation branch. return DistanceType::PlanePlane; }