IMsMetaModelVisualController.CopyScenarioData

Syntax

CopyScenarioData(
                 DestScenarioKey: Array;
                 SourceScenarioKey: Integer;
                 EntryKeys: Array;
                 [CopyAll: Boolean = False]

                );

Parameters

DestScenarioKey. Array of keys of consumer scenarios.

SourceScenarioKey. Provider scenario key.

EntryKeys. Array of keys of copied variables.

CopyAll. Indicates whether to copy data of all model variables.

Description

The CopyScenarioData method copies data by the modelling scenarios.

Comments

For correct copying of data, set the value of the IMsMetaModelVisualController.Problem property.

For copying data by the Fact scenario use -1 key.

The EntryKeys parameter must contain keys of elements of the metamodel calculation chain, which are variables.

Available values of the CopyAll parameter:

Example

Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier containing a modeling problem with the WEB_PROBLEM identifier. The modeling problem must contain several modeling scenarios and an internal metamodel.

Add links to the Metabase, Ms system assemblies.

Sub CopyScenarioData;
Var
    MB: IMetabase;
    MsObj: IMetabaseObject;
    Problem: IMsProblem;
    ProbScen: IMsProblemScenarios;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    DestScen: IMsScenario;
    DestScenKeys, VarsKeys: Array[1Of Integer;
    ChainEnts: IMsCalculationChainEntries;
    ChainEl: IMsCalculationChainEntry;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    // Get modeling container
    MsObj := MB.ItemById("MODEL_SPACE").Bind;
    // Get modeling problem
    Problem := MB.ItemByIdNamespace("WEB_PROBLEM", MsObj.Key).Bind As IMsProblem;
    // Get modeling problem scenarios
    ProbScen := Problem.Scenarios;
    // Get the first scenario in the modeling problem 
    DestScen := ProbScen.Item(0);
    DestScenKeys[0] := (DestScen As IMetabaseObject).Key;
    // Get metamodel  
    Meta := Problem.MetaModel;
    MetaVisual := Meta.VisualController;
    // Set the modeling problem
    MetaVisual.Problem := Problem;
    // Get the key of the first variable in the calculation chain   
    ChainEnts := Meta.CalculationChain;
    For i := 0 To ChainEnts.Count - 1 Do
        ChainEl := ChainEnts.Item(i);
        If ChainEl.Type = MsCalculationChainEntryType.Variable Then
            VarsKeys[0] := ChainEl.Key;
            Break;
        End If;
    End For;
    // Copy data of the first variable by the Fact scenario to the first scenario
    MetaVisual.CopyScenarioData(DestScenKeys, -1, VarsKeys);
End Sub CopyScenarioData;

Example execution result: the data of the first input variable in the metamodel calculation chain will be copied by the Fact scenario to the first scenario in the modeling problem.

See also:

IMsMetaModelVisualController