From 348eef644b6a8cc017fd80418085f6083a7a95d3 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Sat, 20 Dec 2025 03:40:37 +0100 Subject: [PATCH] Part: fix Part_EditAttachment nesting handling (#26298) * Part: fix Part_EditAttachment nesting handling Fixes #26264. The previous 'fix' (#25887) did not consider that the object to-be-attached may not be in the global space. The code in this PR has been tested on the forum: https://forum.freecad.org/viewtopic.php?p=862968#p862968 * [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> --- .../AttachmentEditor/TaskAttachmentEditor.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py b/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py index 170bddc8df..f32916b6c6 100644 --- a/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py +++ b/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py @@ -443,6 +443,27 @@ class AttachmentEditorTaskPanel(FrozenClass): self.updateRefButtons() return if i > -1: + if ";" in subname: + # Test code: + # Gui.Selection.getSelectionEx("", 0)[0].SubElementNames + # Return value examples: + # ('Part.Body.;Edge10;:Hf19,E.Edge10',) + # ('Part.Body.;#1a:1;:H-f28,E;:Hf28,E.Edge15',) + # ('Part.Body.;#16:1;:G#28;FUS;:H-f28:a,E;:Hf28,E.Edge10',) + # ('Part.Body.Pad.;#1d:1;:H-f28,F.Face7',) + # ('Part.Box.Edge10',) + # ('Part.Sketch.;g1;SKT.Edge1',) + tmp = subname.split(";") + subname = tmp[0] + tmp[-1].split(".")[-1] + parent = self.obj.getParentGeoFeatureGroup() + if parent is not None: + path = [objname] + subname.split(".") + if parent.Name in path: + path = path[path.index(parent.Name) + 1 :] + if len(path) > 1: + objname = path[0] + subname = ".".join(path[1:]) + # assign the selected reference if objname == self.obj.Name: self.form.message.setText(