From a450c50765f06f4e0eb4746b89ed14804c58d9e0 Mon Sep 17 00:00:00 2001 From: Uwe Date: Sat, 26 Mar 2022 04:37:17 +0100 Subject: [PATCH] [FEM] fix creation of PostPipeline object - the object was not created inside the analysis container (while this was correctly done when it is created from a solver run) - after the creation, the object was only hardly visible for the user --- src/Mod/Fem/Gui/Command.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index 44ad6fe0a4..f5817dca0f 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -1671,13 +1671,33 @@ void CmdFemPostPipelineFromResult::activated(int) , app->getName(), (*it)->getNameInDocument()); } + // we need single result object to attach the pipeline to std::vector results = getSelection().getObjectsOfType(); if (results.size() == 1) { + // the pipeline should be inside the analysis container if possible + bool foundAnalysis = false; + Fem::FemAnalysis* pcAnalysis; std::string FeatName = getUniqueObjectName("ResultPipeline"); + auto parents = results[0]->getInList(); + if (parents.size()) { + for (auto parentObject : parents) { + if (parentObject->getTypeId() == Base::Type::fromName("Fem::FemAnalysis")) { + pcAnalysis = static_cast(parentObject); + foundAnalysis = true; + } + } + } + // create the pipeline object openCommand(QT_TRANSLATE_NOOP("Command", "Create pipeline from result")); - doCommand(Doc, "App.activeDocument().addObject('Fem::FemPostPipeline','%s')", FeatName.c_str()); + if (foundAnalysis) + pcAnalysis->addObject("Fem::FemPostPipeline", FeatName.c_str()); + else + doCommand(Doc, "App.activeDocument().addObject('Fem::FemPostPipeline','%s')", FeatName.c_str()); + // load the contents of the result object to the pipeline doCommand(Doc, "App.activeDocument().ActiveObject.load(" "App.activeDocument().getObject(\"%s\"))", results[0]->getNameInDocument()); + // set display to assure the user sees the new object + doCommand(Doc, "App.activeDocument().ActiveObject.ViewObject.DisplayMode = \"Surface\""); commitCommand(); this->updateActive();