IMsMetaModelVisualController.FillWithModel

Syntax

FillWithModel(Model: IMsModel;
              ScenarioKeys: Array;
              Period: IMsModelPeriod;
              LoadPeriod: IMsModelPeriod;
              Problem: IMsProblem;
              [Workbook: IMetabaseObject = Null;]
              [IncludeFact: Boolean = True]);

Parameters

Model. Internal model.

ScenarioKeys. Array of scenario keys.

Period. Period of data loading.

LoadPeriod. Period of data displaying.

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

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

IncludeFact. Determines whether to include model data by the Fact scenario.

Description

The FillWithModel method fills the internal workbook with the model data by the set 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.

If Workbook = Null, the internal workbook with loaded data is returned by the IMsMetaModelVisualController.VariableWorkbook or the IMsMetaModelVisualController.Workbook property, if it is required to specify the MsWorkbookType.Variable value as value of the WorkbookType parameter.

The IncludeFact parameter is considered if scenario modeling is used, and key of the Fact scenario is missing in the ScenarioKeys 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 created in the web application. This problem must contain equation. Several scenarios must be used on problem calculation.

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

Sub FillWithModel;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    SimpleModel: IMsModel;
    ScArr: Array Of Integer;
    Target: IUiCommandTarget;
    pr: IMsProblem;
    Period: IMsModelPeriod;
    i: Integer;
    ChainEn: IMsCalculationChainEntries;
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;
    // Get the model
    ChainEn := Meta.CalculationChain;
    For i := 0 To ChainEn.Count - 1 Do
        If ChainEn.Item(i).Type = MsCalculationChainEntryType.Model Then
            SimpleModel := (ChainEn.Item(i) As IMsCalculationChainModel).Model;
        End If;
    End For;
    // Create an array of scenario keys
    ScArr := New Integer[1];
    // Add first scenario key
    ScArr[0] := (MsObj.Bind As IMsModelSpace).ScenarioTree.Item(0).Key;
    Period := SimpleModel.Transform.Period;
    // Fill the workbook with the data from the model
    MetaVisual.FillWithModel(SimpleModel, ScArr, Period, Period, pr, NullFalse);
    // Open the workbook
    Target := WinApplication.Instance.GetObjectTarget(MetaVisual.VariableWorkbook);
    Target.Execute("Object.Edit"Null);
End Sub FillWithModel;

After executing the example a workbook is opened that is filled with internal model data without considering data by the Fact scenario.

See also:

IMsMetaModelVisualController