IMsProblemScenarios.FindByInternalKey

Syntax

FindByKey(InrernalKey: Integer): IMsScenario;

Parameters

InrernalKey. Internal key of the modelling scenario.

Description

The FindByInternalKey method searches for the modelling scenario by the internal key.

Comments

To get the internal key of the modelling scenario, use the IMsScenario.InternalKey property.

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. The modeling container must contain several modelling scenarios.

Add links to the Metabase, Ms system assemblies.

Sub FindByInternalKey;
Var
    MB: IMetabase;
    MsObj: IMetabaseObject;
    MObj: IMetabaseObject;
    Ms: IMsModelSpace;
    Problem: IMsProblem;
    ScenTree: IMsScenarioTreeEntries;
    MsScen, PoblemScen: IMsScenario;
    IntKey: Integer;
    ProbScen: IMsProblemScenarios;
Begin
    MB := MetabaseClass.Active;
    // Get modeling container
    MsObj := MB.ItemById("MODEL_SPACE").Bind;
    Ms := MsObj As IMsModelSpace;
    // Get modeling problem
    MObj := MB.ItemByIdNamespace("PROBLEM", MsObj.Key).Edit;
    Problem := MObj As IMsProblem;
    // Get the first scenario in the modeling container
    ScenTree := Ms.ScenarioTree;
    MsScen := (ScenTree.Item(0As IMsScenarioTreeElement).Scenario;
    // Get the internal key of the modelling scenario
    IntKey := MsScen.InternalKey;
    // Get modeling problem scenarios
    ProbScen := Problem.Scenarios;
    // Search for the first scenario of the container
    // modelling in scenarios of the modelling problem
    PoblemScen := ProbScen.FindByInternalKey(IntKey);
    // If the scenario is found, remove it from the modeling problem
    If PoblemScen <> Null Then
        ProbScen.RemoveByInternalKey(IntKey);
    End If;
    // Save modeling problem
    MObj.Save;
End Sub FindByInternalKey;

Example execution result: the first scenario of the modeling container will be removed from the collection of scenarios of the PROBLEM modeling problem if this scenario is contained in the collection.

See also:

IMsProblemScenarios