IMsCalculationChainSystem.RemoveModel

Fore Syntax

RemoveModel(Model: IMsModel);

Fore.NET Syntax

RemoveModel(Model: Prognoz.Platform.Interop.Ms.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.

Fore Example

Executing the example requires a modeling container with the MODEL_SPACE identifier, containing a metamodel with the METAMODEL identifier in the repository.

Add links to the Metabase, 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;

Result of example execution: 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.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Ms;

Public
 Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    CalcChain, Models: IMsCalculationChainEntries;
    ChainEntry: IMsCalculationChainEntry;
    Model: IMsCalculationChainModel;
    i, j: Integer;
    SysKey: uinteger;
    CalcSystem: IMsCalculationChainSystem;
Begin
    mb := Params.Metabase;
    // 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.mccetSystem 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;

 

See also:

IMsCalculationChainSystem