Salome HOME
Make model.end() in unit-tests set current feature to the last feature of the active...
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Services.cpp
index 20e21e1b47af7ba811e9af87fef05d29f14981bc..443b861ad9a99ebc3f25fd8d5174452691570cc6 100644 (file)
@@ -103,6 +103,15 @@ void begin()
 
 void end()
 {
+  // some operations make the current feature not the last one (like "galeries" change parameters)
+  DocumentPtr anActive = ModelAPI_Session::get()->activeDocument();
+  int aSize = anActive->size("Features");
+  if (aSize > 0) {
+    FeaturePtr aLastFeat =
+      std::dynamic_pointer_cast<ModelAPI_Feature>(anActive->object("Features", aSize - 1));
+    anActive->setCurrentFeature(aLastFeat, true);
+  }
+
   ModelAPI_Session::get()->finishOperation();
   // to update data tree in the end of dumped script execution
   ModelAPI_EventCreator::get()->sendReordered(FeaturePtr());