Creating a Metamodel

Executing the example requires that the repository contains a modeling container with the Kont_Model identifier. There are two Model_1 and Model_2 models in the container.

Sub Main;

Var

MB: IMetabase;

KMDesc: IMetabaseObjectDescriptor;

CrInfo: IMetabaseObjectCreateInfo;

MObj: IMetabaseObject;

Meta: IMsMetaModel;

Model1, Model2: IMsModel;

Root: IMsCalculationChainEntries;

NewFolder: IMsCalculationChainFolder;

Begin

MB := MetabaseClass.Active;

KMDesc := MB.ItemById("Kont_Model");

CrInfo := MB.CreateCreateInfo;

CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MSMETAMODEL;

CrInfo.Id := "MetaModel_1";

CrInfo.Name := Metamodel;

CrInfo.Parent := KMDesc;

MObj := MB.CreateObject(CrInfo).Edit;

Meta := MObj As IMsMetaModel;

Model1 := MB.ItemByIdNamespace("Model_1", KMDesc.Key).Bind As IMsModel;

Model2 := MB.ItemByIdNamespace("Model_2", KMDesc.Key).Bind As IMsModel;

Root := Meta.CalculationChain;

NewFolder := Root.AddFolder(Model 1);

NewFolder.Contents.AddModel(Model1);

NewFolder := Root.AddFolder(Model 2);

NewFolder.Contents.AddModel(Model2);

MObj.Save;

End Sub Main;

After executing the example a metamodel is created in the modeling container. Two folders are created in the metamodel calculation chain, one model is added to each folder.

See also:

Examples