Stop Activate simulation in Initialization script or Diagram-Context script

RoKet
RoKet
Altair Employee
edited June 2021 in Community Q&A

A few days ago I saw this interesting question with the additional explanation

"Are there any oml commands to stop Activate simulation which can be used within Initialization script or Diagram-Context script?
I use Diagram-Context for some pre-processing (getting data from other tool) for Activate simulation, but if a result from the pre-processing is wrong Activate simulation doesn’t have any meaning and I want to stop it before starting the simulation."

The answer is "Yes!". This can be done very easy by adding a return command in case of wrong pre-processing

  if wrongPrePro
return;
end;

In the diagram context you can alternatively use the error function (and include even additional information in the message)

  if wringPrePro
error(‘Pre-processing error.’);
end;

In addition to stop the complete simulation on top level you can use the return command in diagram home context of a super block to exclude the execution of this super block from simulation. I use it e.g. to switch the writing to file on or off.

Thanks for answers to Ramin and Manoj KV.