From 13eeb7b8c23cb245a431bc8a825127570bf77c73 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Tue, 8 Oct 2024 01:48:38 +0200 Subject: [PATCH] Assembly: Fix migrationScript2 error with bad joints (#17010) * Fix migrationScript2 to handle bad joints --- src/Mod/Assembly/JointObject.py | 60 +++++++++++++++++---------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/Mod/Assembly/JointObject.py b/src/Mod/Assembly/JointObject.py index 5ce50989f3..bb4c8c69de 100644 --- a/src/Mod/Assembly/JointObject.py +++ b/src/Mod/Assembly/JointObject.py @@ -455,20 +455,6 @@ class Joint: def migrationScript2(self, joint): if hasattr(joint, "Object1"): - obj = joint.Object1[0] - part = joint.Part1 - elt = joint.Object1[1][0] - vtx = joint.Object1[1][1] - - joint.removeProperty("Object1") - joint.removeProperty("Part1") - - # now we need to get the 'selection-root-obj' and the global path - rootObj, path = UtilsAssembly.getRootPath(obj, part) - obj = rootObj - elt = path + elt - vtx = path + vtx - joint.addProperty( "App::PropertyXLinkSubHidden", "Reference1", @@ -476,22 +462,24 @@ class Joint: QT_TRANSLATE_NOOP("App::Property", "The first reference of the joint"), ) - joint.Reference1 = [obj, [elt, vtx]] + if joint.Object1 is not None: + obj = joint.Object1[0] + part = joint.Part1 + elt = joint.Object1[1][0] + vtx = joint.Object1[1][1] + + # now we need to get the 'selection-root-obj' and the global path + rootObj, path = UtilsAssembly.getRootPath(obj, part) + obj = rootObj + elt = path + elt + vtx = path + vtx + + joint.Reference1 = [obj, [elt, vtx]] + + joint.removeProperty("Object1") + joint.removeProperty("Part1") if hasattr(joint, "Object2"): - obj = joint.Object2[0] - part = joint.Part2 - elt = joint.Object2[1][0] - vtx = joint.Object2[1][1] - - joint.removeProperty("Object2") - joint.removeProperty("Part2") - - rootObj, path = UtilsAssembly.getRootPath(obj, part) - obj = rootObj - elt = path + elt - vtx = path + vtx - joint.addProperty( "App::PropertyXLinkSubHidden", "Reference2", @@ -499,7 +487,21 @@ class Joint: QT_TRANSLATE_NOOP("App::Property", "The second reference of the joint"), ) - joint.Reference2 = [obj, [elt, vtx]] + if joint.Object2 is not None: + obj = joint.Object2[0] + part = joint.Part2 + elt = joint.Object2[1][0] + vtx = joint.Object2[1][1] + + rootObj, path = UtilsAssembly.getRootPath(obj, part) + obj = rootObj + elt = path + elt + vtx = path + vtx + + joint.Reference2 = [obj, [elt, vtx]] + + joint.removeProperty("Object2") + joint.removeProperty("Part2") def migrationScript3(self, joint): if hasattr(joint, "Offset"):