IMsCalculationChainSystem.Models

Syntax

Models: IMsCalculationChainEntries;

Description

The Models property returns models included in the equation system.

Comments

To add the model to the system, use the IMsCalculationChainSystem.AddModel method, to remove the model from the system, use the IMsCalculationChainSystem.RemoveModel method.

Example

Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier, containing a modeling problem with the PROBLEM identifier and a metamodel with the METAMODEL identifier.

Add links to the Metabase and Ms system assemblies.

Sub ArrangeModels;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Problem: IMsProblem;
    Meta: IMsMetaModel;
    CalcChain, Models: IMsCalculationChainEntries;
    ChainEntry, Model: IMsCalculationChainEntry;
    i, j: Integer;
    CalcSystem: IMsCalculationChainSystem;
Begin
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MODEL_SPACE");
    // Get modeling problem
    Problem := mb.ItemByIdNamespace("PROBLEM", MsObj.Key).Edit As IMsProblem;
    // Get metamodel
    //Meta := Problem.MetaModel;
    Meta := mb.ItemByIdNamespace("METAMODEL", MsObj.Key).Edit As IMsMetaModel;
    CalcChain := Meta.CalculationChain;
    // Automatically build the calculation chain
    CalcChain.ArrangeModels(MsArrangeMode.CreateSystems, Problem);
    // If the result of the automatic building is the creation of
    // equation system, then display model names in the console window,
    // included in the equation system
    For i := 0 To CalcChain.Count - 1 Do
        ChainEntry := CalcChain.Item(i);
        If ChainEntry.Type = MsCalculationChainEntryType.System Then
            CalcSystem := ChainEntry As IMsCalculationChainSystem;
            Models := CalcSystem.Models;
            For j := 0 To Models.Count - 1 Do
                Model := Models.Item(j);
                Debug.WriteLine(Model.Name);
            End For;
        End If;
    End For;
    // Save changes
    (Meta As IMetabaseObject).Save;
    (Problem As IMetabaseObject).Save;
End Sub ArrangeModels;

After executing the example, the calculation chain will be automatically built for the METAMODEL metamodel. If, as a result, the system of equations is created, the names of models included in the system will be displayed in the console window. System calculation periods will be taken from the PROBLEM problem.

See also:

IMsCalculationChainSystem