From 11ff46f84a5ae90c6a0a73c93a278cf17db55b17 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Sat, 22 Mar 2025 18:27:24 +0100 Subject: [PATCH] Assembly: ignore joints in error (#20253) Co-authored-by: drwho495 --- src/Mod/Assembly/App/AssemblyObject.cpp | 2 +- src/Mod/Assembly/JointObject.py | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Mod/Assembly/App/AssemblyObject.cpp b/src/Mod/Assembly/App/AssemblyObject.cpp index 3c3b20d21e..a7164bad36 100644 --- a/src/Mod/Assembly/App/AssemblyObject.cpp +++ b/src/Mod/Assembly/App/AssemblyObject.cpp @@ -652,7 +652,7 @@ AssemblyObject::getJoints(bool updateJCS, bool delBadJoints, bool subJoints) } auto* prop = dynamic_cast(joint->getPropertyByName("Activated")); - if (!prop || !prop->getValue()) { + if (joint->isError() || !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 8fb431fcae..3aa2ab41b2 100644 --- a/src/Mod/Assembly/JointObject.py +++ b/src/Mod/Assembly/JointObject.py @@ -569,6 +569,9 @@ class Joint: if App.isRestoring(): return + if prop == "Reference1" or prop == "Reference2": + joint.recompute() + if prop == "Offset1" or prop == "Offset2": if joint.Reference1 is None or joint.Reference2 is None: return @@ -591,10 +594,21 @@ class Joint: self.preventParallel(joint) solveIfAllowed(self.getAssembly(joint)) - def execute(self, fp): - """Do something when doing a recomputation, this method is mandatory""" - # App.Console.PrintMessage("Recompute Python Box feature\n") - pass + def execute(self, joint): + errStr = joint.Label + ": " + QT_TRANSLATE_NOOP("Assembly", "Broken link in: ") + if ( + hasattr(joint, "Reference1") + and joint.Reference1 is not None + and (joint.Reference1[1][0].find("?") != -1) + ): + raise Exception(errStr + "Reference1") + + if ( + hasattr(joint, "Reference2") + and joint.Reference2 is not None + and (joint.Reference2[1][0].find("?") != -1) + ): + raise Exception(errStr + "Reference2") def setJointConnectors(self, joint, refs): # current selection is a vector of strings like "Assembly.Assembly1.Assembly2.Body.Pad.Edge16" including both what selection return as obj_name and obj_sub