IMsScenarioTreeEntries.FindByInternalKey

Syntax

FindByKey(InrernalKey: Integer): IMsScenarioTreeEntry;

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

Add links to the Metabase, Ms system assemblies.

Sub FindByInternalKey;
Var
    MB: IMetabase;
    MsObj: IMetabaseObject;
    Ms: IMsModelSpace;
    ScenTree: IMsScenarioTreeEntries;
    ScenEntry: IMsScenarioTreeEntry;
    IntKey: Integer;
Begin
    MB := MetabaseClass.Active;
    // Get modeling container
    MsObj := MB.ItemById("MODEL_SPACE").Edit;
    Ms := MsObj As IMsModelSpace;
    // Get scenario tree
    ScenTree := Ms.ScenarioTree;
    // Set internal key value
    IntKey := 44489;
    // Search for the object by internal key value in the scenario tree
    ScenEntry := ScenTree.FindByInternalKey(IntKey);
    // If the object is found, remove it from the scenario tree
    If ScenEntry <> Null Then
        ScenTree.RemoveByInternalKey(IntKey);
    End If;
    // Save changes
    MsObj.Save;
End Sub FindByInternalKey;

Example execution result: a scenario with the 44489 key will be removed from the scenario tree in the MODEL_SPACE modeling container if this scenario is contained in the container.

See also:

IMsScenarioTreeEntries