From 27f077c62b7373b392ec4010e8d7f2464d0e12a6 Mon Sep 17 00:00:00 2001 From: Timothy Miller Date: Wed, 21 Jan 2026 14:52:06 -0500 Subject: [PATCH] Part: Fix AttacherEngine property not synced with AttacherType (#15716) When Part2DObject (e.g., Sketch) is created, it calls setAttacher() to set up AttachEnginePlane. This updated the internal AttacherType property but left the user-visible AttacherEngine enum at its default "Engine 3D". Now setAttacher() also updates AttacherEngine for non-base attachers, keeping the visible property in sync with the actual engine type. Co-Authored-By: Claude Opus 4.5 --- src/Mod/Part/App/AttachExtension.cpp | 8 +++++++ src/Mod/Part/parttests/regression_tests.py | 25 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/Mod/Part/App/AttachExtension.cpp b/src/Mod/Part/App/AttachExtension.cpp index fa756e23e8..5d387adee5 100644 --- a/src/Mod/Part/App/AttachExtension.cpp +++ b/src/Mod/Part/App/AttachExtension.cpp @@ -293,6 +293,14 @@ void AttachExtension::setAttacher(AttachEngine* pAttacher, bool base) // onChange->changeAttacherType->onChange... props.attacherType->setValue(typeName); } + // Also update the visible AttacherEngine property for non-base attachers + // to keep it in sync with AttacherType (fixes issue #15716) + if (!base) { + const char* enumVal = classToEnum(typeName); + if (strcmp(AttacherEngine.getValueAsString(), enumVal) != 0) { + AttacherEngine.setValue(enumVal); + } + } updateAttacherVals(base); } else { diff --git a/src/Mod/Part/parttests/regression_tests.py b/src/Mod/Part/parttests/regression_tests.py index 5ebd05b7e3..331baba85a 100644 --- a/src/Mod/Part/parttests/regression_tests.py +++ b/src/Mod/Part/parttests/regression_tests.py @@ -185,6 +185,31 @@ class RegressionTests(unittest.TestCase): for name, pos, normal, xaxis in expected_planes: check_plane(name, pos, normal, xaxis) + def test_issue_15716_AttacherEngine_sync(self): + """ + 15716: AttacherType and AttacherEngine property conflict + + When creating a Part2DObject (like a Sketch), the AttacherEngine property + should be synchronized with AttacherType. Previously, AttacherType was + correctly set to "Attacher::AttachEnginePlane" but AttacherEngine stayed + at the default "Engine 3D" instead of "Engine Plane". + """ + if "BUILD_SKETCHER" in FreeCAD.__cmake__: + # Create a new sketch (which inherits from Part2DObject) + sketch = self.Doc.addObject("Sketcher::SketchObject", "TestSketch") + self.Doc.recompute() + + # The visible AttacherEngine property should match the actual engine type + # AttacherType is the internal type name, AttacherEngine is the user-visible enum + attacher_type = sketch.AttacherType + attacher_engine = sketch.AttacherEngine + + # For a sketch, AttacherType should be AttachEnginePlane + self.assertEqual(attacher_type, "Attacher::AttachEnginePlane") + + # AttacherEngine should show "Engine Plane" (not "Engine 3D") + self.assertEqual(attacher_engine, "Engine Plane") + def tearDown(self): """Clean up our test, optionally preserving the test document""" # This flag allows doing something like this: