Salome HOME
updated copyright message
[modules/shaper.git] / src / InitializationPlugin / InitializationPlugin_EvalListener.cpp
index 76a388ee5faa9197d57babd4e3444fa1f5146bc8..f698026f44e20f36c4a6964af04220af14308ef6 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -78,6 +78,7 @@ InitializationPlugin_EvalListener::InitializationPlugin_EvalListener()
   aLoop->registerListener(this, ModelAPI_ParameterEvalMessage::eventId(), NULL, true);
   aLoop->registerListener(this, ModelAPI_BuildEvalMessage::eventId(), NULL, true);
   aLoop->registerListener(this, ModelAPI_ComputePositionsMessage::eventId(), NULL, true);
+  aLoop->registerListener(this, ModelAPI_ImportParametersMessage::eventId(), NULL, true);
 
   myInterp = std::shared_ptr<InitializationPlugin_PyInterp>(new InitializationPlugin_PyInterp());
   myInterp->initialize();
@@ -179,6 +180,16 @@ void InitializationPlugin_EvalListener::processEvent(
     }
     aMsg->setResults(aParamsList, anError);
   }
+  else if (theMessage->eventID() == ModelAPI_ImportParametersMessage::eventId())
+  {
+    std::shared_ptr<ModelAPI_ImportParametersMessage> aMsg =
+      std::dynamic_pointer_cast<ModelAPI_ImportParametersMessage>(theMessage);
+    std::string anImportScript("from salome.shaper import model;");
+    std::string aDocScript("doc = model.activeDocument();");
+    std::string anParamImpScript("model.importParameters(doc, \"");
+    std::string aPath = aMsg->filename();
+    myInterp->runString(anImportScript + aDocScript + anParamImpScript + aPath + "\")");
+  }
 }
 
 //=================================================================================================