From 13be1ad37f9952285f4be2025d7ce806c7ccb8a8 Mon Sep 17 00:00:00 2001 From: Abdelhadi Wael Date: Tue, 18 Mar 2025 05:44:09 +0200 Subject: [PATCH] Update CommandStructure.cpp --- src/Gui/CommandStructure.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Gui/CommandStructure.cpp b/src/Gui/CommandStructure.cpp index f93ab07511..c0490e719c 100644 --- a/src/Gui/CommandStructure.cpp +++ b/src/Gui/CommandStructure.cpp @@ -72,9 +72,19 @@ void StdCmdPart::activated(int iMsg) QObject::tr(PartName.c_str()).toUtf8().data()); doCommand(Doc, - "for obj in Gui.Selection.getSelection()[1:]:\n" - " App.activeDocument().%s.addObject(obj)", - PartName.c_str()); + "selected_objects = Gui.Selection.getSelection()\n" + "if len(selected_objects) > 1:\n" + " for obj in selected_objects:\n" + " # Exclude spreadsheets\n" + " if obj.TypeId == 'Spreadsheet::Sheet':\n" + " continue\n" + " # Add subobjects if obj is a container (optional)\n" + " if hasattr(obj, 'OutList') and len(obj.OutList) > 0:\n" + " for child in obj.OutList:\n" + " App.activeDocument().%s.addObject(child)\n" + " else:\n" + " App.activeDocument().%s.addObject(obj)\n", + PartName.c_str(), PartName.c_str()); doCommand(Gui::Command::Gui, "Gui.activateView('Gui::View3DInventor', True)\n" "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)",