Convert(format: MsModelFormat);
format. Required metamodel format.
The Convert method transforms the metamodel calculated by a problem into an internal one without use of objects, and vice versa.
By default, problems created in the desktop application use a metamodel that is a separate repository object, and problems created in the web application use internal metamodels that are not separate repository objects.
Executing the example requires that the repository contains a modeling container with the MS identifier containing a model with the MODEL_LINEARREGR identifier.
Add links to the Metabase and Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
Ms: IMetabaseObjectDescriptor;
CreateInfo: IMetabaseObjectCreateInfo;
Problem: IMsProblem;
Model: IMsModel;
MetaModel: IMsMetaModel;
CalcChain: IMsCalculationChainEntries;
Begin
// Get repository
Mb := MetabaseClass.Active;
// Get modeling container
Ms := mb.ItemById("MS");
// Create a modeling problem
CreateInfo := Mb.CreateCreateInfo;
CreateInfo.ClassId := MetabaseObjectClass.KE_CLASS_MSPROBLEM;
CreateInfo.Parent := Ms;
CreateInfo.Permanent := True;
CreateInfo.Id := Mb.GenerateId("PROBLEM_META", Ms.Key);
CreateInfo.Name := "Problem with internal metamodel";
Problem := Mb.CreateObject(CreateInfo).Edit As IMsProblem;
// Transform problem
Problem.Convert(MsModelFormat.WithoutObject);
// Create an internal metamodel
MetaModel := Problem.CreateMetaModel;
// Get metamodel calculation chain
CalcChain := MetaModel.CalculationChain;
// Get model
Model := mb.ItemByIdNamespace("MODEL_LINEARREGR", Ms.Key).Edit As IMsModel;
// Add obtained model to calculation chain
CalcChain.AddModel(Model);
// Save changes
(Problem As IMetabaseObject).Save;
End Sub UserProc;
After executing the example a problem that contains internal metamodel is created in the modeling container.
See also: