IModelBox.ResultsViewScenario

Syntax

ResultsViewScenario: Integer;

Description

The ResultsViewScenario property determines the key of the scenario, by which the model is calculated.

Comments

Set the property to -1 to calculate by the Fact scenario.

Example

Executing the example requires that the repository contains:

Add links to the Metabase, Ms, Ui system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    ms: IMsModelSpace;
    Problem: IMsProblem;
    MetaModel: IMsMetaModel;
    CalcChain: IMsCalculationChainEntries;
    i: Integer;
    CalcChainEntry: IMsCalculationChainEntry;
    Scenarios: IMsProblemScenarios;
    ScenKey: integer;
    ScenTree: IMsScenarioTreeEntries;
    ScenEntry: IMsScenarioTreeEntry;
Begin
    UiModel1.Active := False;
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MODEL_SPACE");
    ms := MsObj.Bind As IMsModelSpace;
    // Get modeling problem
    Problem := mb.ItemByIdNamespace("PROBLEM", MsObj.Key).Bind As IMsProblem;
    // Get metamodel calculated by the problem
    MetaModel := Problem.MetaModel;
    // Get metamodel calculation chain
    CalcChain := MetaModel.CalculationChain;
    // Get the first model in calculation chain
    For i := 0 To CalcChain.Count - 1 Do
        CalcChainEntry := CalcChain.Item(i);
        If CalcChainEntry.Type = MsCalculationChainEntryType.Model Then
            // Use the model as a data source for UiModel1
            UiModel1.Model := (CalcChainEntry As IMsCalculationChainModel).Model;
            UiModel1.Active := True;
            Break;
        End If;
    End For;
    // Get scenarios, by which modelling problem is calculated
    Scenarios := Problem.Scenarios;
    // Get the second scenario of modelling problem
    ScenKey := Scenarios.Item(1).InternalKey;
    // Get key of the second scenario
    ScenTree := ms.ScenarioTree;
    ScenEntry := ScenTree.FindByInternalKey(ScenKey);
    // Specify that the model is calculated by the second scenario
    ModelBox1.ResultsViewScenario := ScenEntry.Key;
    // Calculate the model
    ModelBox1.Execute;
    // Save changes
    ModelBox1.SaveObject;
End Sub UserProc;

After executing the example the ModelBox1 component will display the first model calculated by a modeling problem. The second scenario of the modeling problem will be used for problem calculation.

See also:

IModelBox