From b7440a660c2ca2f14e456df9cd26497bb23392e7 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Thu, 21 Aug 2025 07:15:36 +0200 Subject: [PATCH] Assembly: Move label change logic to onChange --- src/Mod/Assembly/JointObject.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Mod/Assembly/JointObject.py b/src/Mod/Assembly/JointObject.py index 55ad10d09c..2e825b71a4 100644 --- a/src/Mod/Assembly/JointObject.py +++ b/src/Mod/Assembly/JointObject.py @@ -590,12 +590,6 @@ class Joint: if newType != oldType: joint.JointType = newType - # try to replace the joint type in the label. - tr_old_type = TranslatedJointTypes[JointTypes.index(oldType)] - tr_new_type = TranslatedJointTypes[JointTypes.index(newType)] - if tr_old_type in joint.Label: - joint.Label = joint.Label.replace(tr_old_type, tr_new_type) - def onChanged(self, joint, prop): """Do something when a property has changed""" # App.Console.PrintMessage("Change property: " + str(prop) + "\n") @@ -604,6 +598,19 @@ class Joint: if App.isRestoring(): return + if prop == "JointType": + newType = joint.JointType + tr_new_type = TranslatedJointTypes[JointTypes.index(newType)] + + # Find the old joint type in the label and replace it + for i, old_type_name in enumerate(JointTypes): + if old_type_name == newType: + continue + tr_old_type = TranslatedJointTypes[i] + if tr_old_type in joint.Label: + joint.Label = joint.Label.replace(tr_old_type, tr_new_type) + break + if prop == "Reference1" or prop == "Reference2": joint.recompute()