IMsCalculationChainSystem.RemoveModel

Syntax

RemoveModel(Model: IMsModel);

Parameters

Model. Removable model.

Description

The RemoveModel method removes the specified model from the system of equations.

Comments

To add equations to the system, use the IMsCalculationChainSystem.AddModel method.

Example

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

Add links to the Metabase and Ms system assemblies.

Sub RemoveModel;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    CalcChain, Models: IMsCalculationChainEntries;
    ChainEntry: IMsCalculationChainEntry;
    Model: IMsCalculationChainModel;
    i, j, SysKey: Integer;
    CalcSystem: IMsCalculationChainSystem;
Begin
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MODEL_SPACE");
    // Get metamodel
    Meta := mb.ItemByIdNamespace("METAMODEL", MsObj.Key).Edit As IMsMetaModel;
    CalcChain := Meta.CalculationChain;
    // If the calculation chain contains the system of equations,
    // then remove all equations from system
    SysKey := 0;
    For i := 0 To CalcChain.Count - 1 Do
        ChainEntry := CalcChain.Item(i);
        If ChainEntry.Type = MsCalculationChainEntryType.System Then
            CalcSystem := ChainEntry As IMsCalculationChainSystem;
            SysKey := CalcSystem.Key;
            Models := CalcSystem.Models;
            For j := 0 To Models.Count - 1 Do
                Model := Models.Item(j) As IMsCalculationChainModel;
                CalcSystem.RemoveModel(Model.Model);
            End For;
        End If;
    End For;
    // Remove the system of equations
    If SysKey <> 0 Then
        CalcChain.RemoveByKey(SysKey);
    End If;
    // Save changes
    (Meta As IMetabaseObject).Save;
End Sub RemoveModel;

After executing the example, if the METAMODEL metamodel calculation chain contains the system of equations, then all equations will be removed and the system of equations will be removed.

See also:

IMsCalculationChainSystem