ICalcBlock.AddModel

Syntax

AddModel(Parent: IMsCalculationChainEntry): IMsCalculationChainModel;

Parameters

Parent. Metamodel calculation chain.

Description

The AddModel method creates a new model in the metamodel calculation chain.

Example

Executing the example requires that the repository contains a ready calculation algorithm with the ALGORITHM identifier. A calculation block is added in the calculation algorithm.

Add links to the Algo, Metabase, Ms system assemblies. Add a link to the assembly required for working with calculation algorithm.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObjectDescriptor;
    Algo: ICalcObject;
    CalcList: ICalcObjectsList;
    CalcAlgo: ICalcAlgorithm;
    CalcBlock: ICalcBlock;
    Folder: IMsCalculationChainFolder;
    Model: IMsCalculationChainModel;
    CalcBlockEntry: IMsCalculationChainEntry;
Begin
    MB := MetabaseClass.Active;
    // Get calculation algorithm
    MObj := MB.ItemById("ALGORITHM");
    Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
    CalcAlgo := Algo As ICalcAlgorithm;
    // Create a list of algorithm objects
    CalcList := CalcAlgo.Items.Clone;
    CalcBlock := CalcList.Item(0As ICalcBlock;
    // Create a new folder in metamodel calculation chain.
    Folder := CalcBlock.AddFolder(CalcBlock.MetaModel.CalculationChain.Item(0));
    Folder.Name := "Folder";
    // Create a model in metamodel calculation chain.
    Model := CalcBlock.AddModel(Folder.Contents.ParentEntry);
    Model.Name := "Model";
    // Move all nested elements of calculation chain to created folder
    Debug.WriteLine(CalcBlock.Folder.Contents.Count);
    For Each CalcBlockEntry In CalcBlock.Folder.Contents Do
        CalcBlockEntry.MoveToParent(Folder.Contents, 0);
    End For;
    // Save changes
    CalcBlock.SaveObject;
End Sub UserProc;

After executing the example, a folder will be created for the calculation block in the metamodel calculation chain. A model will be added in this folder. All existing elements of the calculation chain will also be moved to this folder.

See also:

ICalcBlock