IMsProblemCalculation.Callback

Syntax

Callback: IMsProblemCalculationCallback;

Description

The Callback property determines an object to handle events that occur during modeling problem calculation.

Comments

On calculating the problem the following events are possible:

Example

Executing the example requires that the repository includes a modeling container with the MODEL_SPACE identifier including a modeling problem with the PROBLEM identifier.

Add links to the Metabase, Ms system assemblies.

The example also uses the MCallback class described in IMsProblemCalculationCallback.OnWarning.

Sub ProblemCalc;
Var
    mb: IMetabase;
    MsKey: Integer;
    Problem: IMsProblem;
    Calculation: IMsProblemCalculation;
    CallBack: MCallback;
    CalcSettings: IMsProblemCalculationSettings;
Begin
    mb := MetabaseClass.Active;
    // Get modeling problem
    MsKey := mb.GetObjectKeyById("MODEL_SPACE");
    Problem := mb.ItemByIdNamespace("PROBLEM", MsKey).Bind As IMsProblem;
    // Set problem calculation options
    CalcSettings := Problem.CreateCalculationSettings;
    CalcSettings.FactIncluded := True;
    CalcSettings.BreakOnError := True;
    Calculation := Problem.Calculate(CalcSettings);
    // Set event handler
    CallBack := New MCallback.Create;
    Calculation.Callback := CallBack;
    // Perform calculation
    Calculation.Run;
End Sub ProblemCalc;

After executing the example the problem is calculated. If there is an error, the calculation is stopped. The handler of the events occurring on problem calculation is the MCallback class.

See also:

IMsProblemCalculation