From 50fc8e86c70636dac747d8f19862473e1c874ffa Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sun, 17 Dec 2023 21:28:37 +0800 Subject: [PATCH] PD: fix creating new body in active part Add to active App::Part before setting active body in order to obtain correct object path when setting active body Fixes #10371 --- src/Mod/PartDesign/Gui/CommandBody.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index e5f49d5bad..356af20657 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -212,6 +212,12 @@ void CmdPartDesignBody::activated(int iMsg) } } addModule(Gui,"PartDesignGui"); // import the Gui module only once a session + + if (actPart) { + doCommand(Doc,"App.activeDocument().%s.addObject(App.ActiveDocument.%s)", + actPart->getNameInDocument(), bodyString); + } + doCommand(Gui::Command::Gui, "Gui.activateView('Gui::View3DInventor', True)\n" "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PDBODYKEY, bodyString); @@ -219,10 +225,6 @@ void CmdPartDesignBody::activated(int iMsg) // Make the "Create sketch" prompt appear in the task panel doCommand(Gui,"Gui.Selection.clearSelection()"); doCommand(Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s)", bodyString); - if (actPart) { - doCommand(Doc,"App.activeDocument().%s.addObject(App.ActiveDocument.%s)", - actPart->getNameInDocument(), bodyString); - } // check if a proxy object has been created for the base feature inside the body if (baseFeature) {