IMsMetaModelVisualController.FillWithVariables

Syntax

FillWithVariables(EntryKeys: Array;
                  ScenarioKeys: Array;
                  Period: IMsModelPeriod
                  Problem: IMsProblem;
                  [TargetEntryKey: Integer = 1;]
                  [SortByVariables: Boolean = False;]
                  [Workbook: IMetabaseObject = Null]);

Parameters

EntryKeys. Array of keys of variables.

ScenarioKeys. Array of scenario keys.

Period. Period of data loading.

Problem. Modeling problem, to which the loading is performed.

TargetEntryKey. Criterion function key.

SortByVariables. Determines whether to sort variables.

Workbook. External workbook, to which the results should be loaded. Optional parameter.

Description

The FillWithVariables method returns the internal workbook with data of specified variables by specified scenarios.

Comments

To filter data by the scenario dictionary, use the Problem parameter. It allows to load data only by the specified problem, not by all scenarios in the modeling container. It is also used to determine whether the scenario modelling is used.

The TargetEntryKey parameter is used to get data of criterion function controlling variables. If the -1 value is specified, data of standard variables is obtained.

Available values of the SortByVariables parameter:

If Workbook = Null, the internal workbook with loaded data is returned by the IMsMetaModelVisualController.VariableWorkbook property or the IMsMetaModelVisualController.Workbook property, if the MsWorkbookType.Variable value should be specified as value of the WorkbookType parameter.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a modeling problem with the FILLMODEL identifier. This problem must contain an internal metamodel containing an internal time series database and a model.

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

Sub FillWithVariables;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    ScArr: Array Of Integer;
    Target: IUiCommandTarget;
    pr: IMsProblem;
    ProblDet: IMsProblemDetails;
    i, j: Integer;
    ChainEn: IMsCalculationChainEntries;
    Arr, VarArr: Array Of Integer;
Begin
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MS");
    // Get modeling problem
    pr := mb.ItemByIdNamespace("FILLMODEL", MsObj.Key).Bind As IMsProblem;
    // Get metamodel
    Meta := pr.MetaModel;
    MetaVisual := Meta.VisualController;
    ChainEn := Meta.CalculationChain;
    Arr := New Integer[ChainEn.Count];
    // Get variable keys
    j := 0;
    For i := 0 To ChainEn.Count - 1 Do
        If ChainEn.Item(i).Type = MsCalculationChainEntryType.Variable Then
            Arr[j] := ChainEn.Item(i).Key;
            j := j + 1;
        End If;
    End For;
    VarArr := New Integer[j];
    For i := 0 To VarArr.Length - 1 Do
        VarArr[i] := Arr[i];
    End For;
    // Create an array of scenario keys
    ScArr := New Integer[1];
    // Add the Fact scenario key
    ScArr[0] := -1;
    // Set the period of obtaining data
    ProblDet := pr.Details As IMsProblemDetails;
    // Fill the workbook with the data from the model
    MetaVisual.FillWithVariables(VarArr, ScArr, ProblDet.Period, pr);
    // Open the workbook
    Target := WinApplication.Instance.GetObjectTarget(MetaVisual.VariableWorkbook);
    Target.Execute("Object.Edit"Null);
End Sub FillWithVariables;

After executing the example the workbook filled with the data of variables from the internal model will be opened.

See also:

IMsMetaModelVisualController