Assembly: Replace "Activated" property by the core "Suppressed" mecha… (#22409)

* 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>
This commit is contained in:
PaddleStroke
2025-07-28 18:20:01 +02:00
committed by GitHub
parent 2ee64c1732
commit 38fb1ef274
5 changed files with 33 additions and 24 deletions

View File

@@ -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