From 38fb1ef274d7b08f02ec0694a9296aca2f8db432 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Mon, 28 Jul 2025 18:20:01 +0200 Subject: [PATCH] =?UTF-8?q?Assembly:=20Replace=20"Activated"=20property=20?= =?UTF-8?q?by=20the=20core=20"Suppressed"=20mecha=E2=80=A6=20(#22409)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Assembly: Replace "Activated" property by the core "Suppressed" mechanism. * Fix inaccuracy * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * move the change to migrationScript5 function * Update JointObject.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/Mod/Assembly/App/AssemblyLink.cpp | 2 +- src/Mod/Assembly/App/AssemblyObject.cpp | 4 +-- src/Mod/Assembly/App/AssemblyUtils.cpp | 8 ++--- src/Mod/Assembly/App/JointGroup.cpp | 4 +-- src/Mod/Assembly/JointObject.py | 39 +++++++++++++++---------- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/Mod/Assembly/App/AssemblyLink.cpp b/src/Mod/Assembly/App/AssemblyLink.cpp index 6fa032466d..64f1f5da08 100644 --- a/src/Mod/Assembly/App/AssemblyLink.cpp +++ b/src/Mod/Assembly/App/AssemblyLink.cpp @@ -352,7 +352,7 @@ void AssemblyLink::synchronizeJoints() } // Then we have to check the properties one by one. - copyPropertyIfDifferent(joint, lJoint, "Activated"); + copyPropertyIfDifferent(joint, lJoint, "Suppressed"); copyPropertyIfDifferent(joint, lJoint, "Distance"); copyPropertyIfDifferent(joint, lJoint, "Distance2"); copyPropertyIfDifferent(joint, lJoint, "JointType"); diff --git a/src/Mod/Assembly/App/AssemblyObject.cpp b/src/Mod/Assembly/App/AssemblyObject.cpp index a705ed5e97..dc49cf7eb2 100644 --- a/src/Mod/Assembly/App/AssemblyObject.cpp +++ b/src/Mod/Assembly/App/AssemblyObject.cpp @@ -651,8 +651,8 @@ AssemblyObject::getJoints(bool updateJCS, bool delBadJoints, bool subJoints) continue; } - auto* prop = dynamic_cast(joint->getPropertyByName("Activated")); - if (joint->isError() || !prop || !prop->getValue()) { + auto* prop = dynamic_cast(joint->getPropertyByName("Suppressed")); + if (joint->isError() || !prop || prop->getValue()) { // Filter grounded joints and deactivated joints. continue; } diff --git a/src/Mod/Assembly/App/AssemblyUtils.cpp b/src/Mod/Assembly/App/AssemblyUtils.cpp index b1df6e437e..d55156c13e 100644 --- a/src/Mod/Assembly/App/AssemblyUtils.cpp +++ b/src/Mod/Assembly/App/AssemblyUtils.cpp @@ -404,8 +404,8 @@ void setJointActivated(const App::DocumentObject* joint, bool val) return; } - if (auto propActivated = joint->getPropertyByName("Activated")) { - propActivated->setValue(val); + if (auto propSuppressed = joint->getPropertyByName("Suppressed")) { + propSuppressed->setValue(!val); } } @@ -415,8 +415,8 @@ bool getJointActivated(const App::DocumentObject* joint) return false; } - if (const auto propActivated = joint->getPropertyByName("Activated")) { - return propActivated->getValue(); + if (const auto propActivated = joint->getPropertyByName("Suppressed")) { + return !propActivated->getValue(); } return false; } diff --git a/src/Mod/Assembly/App/JointGroup.cpp b/src/Mod/Assembly/App/JointGroup.cpp index c38a4f16d2..c22bbbdd33 100644 --- a/src/Mod/Assembly/App/JointGroup.cpp +++ b/src/Mod/Assembly/App/JointGroup.cpp @@ -65,8 +65,8 @@ std::vector JointGroup::getJoints() continue; } - auto* prop = dynamic_cast(joint->getPropertyByName("Activated")); - if (!prop || !prop->getValue()) { + auto* prop = dynamic_cast(joint->getPropertyByName("Suppressed")); + if (!prop || prop->getValue()) { // Filter grounded joints and deactivated joints. continue; } diff --git a/src/Mod/Assembly/JointObject.py b/src/Mod/Assembly/JointObject.py index cb8dc73440..839cdef039 100644 --- a/src/Mod/Assembly/JointObject.py +++ b/src/Mod/Assembly/JointObject.py @@ -174,6 +174,8 @@ class Joint: def __init__(self, joint, type_index): joint.Proxy = self + joint.addExtension("App::SuppressibleExtensionPython") + joint.addProperty( "App::PropertyEnumeration", "JointType", @@ -196,6 +198,7 @@ class Joint: self.migrationScript2(joint) self.migrationScript3(joint) self.migrationScript4(joint) + self.migrationScript5(joint) # First Joint Connector if not hasattr(joint, "Reference1"): @@ -314,19 +317,6 @@ class Joint: locked=True, ) - if not hasattr(joint, "Activated"): - joint.addProperty( - "App::PropertyBool", - "Activated", - "Joint", - QT_TRANSLATE_NOOP( - "App::Property", - "This indicates if the joint is active.", - ), - locked=True, - ) - joint.Activated = True - if not hasattr(joint, "EnableLengthMin"): joint.addProperty( "App::PropertyBool", @@ -563,6 +553,23 @@ class Joint: processReference("Reference1") processReference("Reference2") + def migrationScript5(self, joint): + if not joint.hasExtension("App::SuppressibleExtensionPython"): + joint.addExtension("App::SuppressibleExtensionPython") + + if App.GuiUp: + if not joint.ViewObject.hasExtension("Gui::ViewProviderSuppressibleExtensionPython"): + joint.ViewObject.addExtension("Gui::ViewProviderSuppressibleExtensionPython") + + if hasattr(joint, "Activated"): + activated = joint.Activated + if not activated: + print( + "The 'Activated' property has been replaced by the 'Suppressed' property. Your file has a deactivated joint that is being migrated. If you open back this file in an older version, it will not be deactivated anymore." + ) + joint.removeProperty("Activated") + joint.Suppressed = not activated + def dumps(self): return None @@ -747,10 +754,10 @@ class Joint: isAssembly = assembly.Type == "Assembly" if isAssembly: - joint.Activated = False + joint.Suppressed = True part1Connected = assembly.isPartConnected(part1) part2Connected = assembly.isPartConnected(part2) - joint.Activated = True + joint.Suppressed = False else: part1Connected = True part2Connected = False @@ -853,6 +860,8 @@ class ViewProviderJoint: vobj.Proxy = self + vobj.addExtension("Gui::ViewProviderSuppressibleExtensionPython") + def attach(self, vobj): """Setup the scene sub-graph of the view provider, this method is mandatory""" self.app_obj = vobj.Object