IMsModelList.FindByKey

Syntax

FindByKey(ModelKey: Integer): IMsModel;

Parameters

ModelKey. Key of the required model.

Description

The FindByKey method finds a model in the collection by its key.

Example

Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier. This container should include a non-linear equation system with the NON_LINEAR_MODEL identifier.

Add links to the Metabase, Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    ModelCont: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Trans: IMsFormulaTransform;
    Formula: IMsFormula;
    Equations: IMsNonLinearEquationsTransform;
    Descript: IMetabaseObjectDescriptor;
    ExtModel: IMsModel;
    ExternalEquations: IMsModelList;
Begin
    mb := MetabaseClass.Active;
    ModelCont := mb.ItemById("CONT_MODEL");
    Descript := mb.ItemByIdNamespace("NON_LINEAR_MODEL", ModelCont.Key);
    Model := Descript.Edit As IMsModel;
    Trans := Model.Transform;
    Formula := Trans.EquationsFormula;
    Equations := Formula.Method As IMsNonLinearEquationsTransform;
// Getting collection of system equations
    ExternalEquations := Equations.ExternalEquations;
    ExtModel := ExternalEquations.FindByKey(1);
    If ExtModel <> Null Then
        ExternalEquations.FindByKey(1);
    End If;
    // Saving changes
    (Model As IMetabaseObject).Save;
End Sub UserProc;

After executing the example, an external model with the 1 key (if it is contained in the system) is removed from the system of non-linear equations.

See also:

IMsModelList