IMsScenarioTreeEntries.RemoveByKeyEx

Syntax

RemoveByKeyEx(EntryKey: Integer; Recursive: Boolean): Boolean;

Parameters

EntryKey. Key of the element that must be removed.

Recursive. It determines whether to perform recursive removal of child elements. Available values:

Description

The RemoveByKeyEx method removes the element from the scenario tree with ability of recursive removal of child elements.

Comments

If the removal is successful, the method returns True, otherwise it returns False.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier. This modeling container should include scenarios.

Add links to the Metabase and Ms system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MsObj: IMetabaseObject;
    ModelSpace: IMsModelSpace;
    Tree: IMsScenarioTreeEntries;
    Element: IMsScenarioTreeEntry;
    res: Boolean;
Begin
    // Get modeling container
    MB := MetabaseClass.Active;
    MsObj := MB.ItemById("MS").Edit;
    ModelSpace := MsObj As IMsModelSpace;
    // Get scenario tree
    Tree := ModelSpace.ScenarioTree;
    // Get the first element of the tree
    Element := Tree.Item(0);
    // Perform recursive removal
    res := Tree.RemoveByKeyEx(Element.Key, True);
    // Display removal results in the console window
    Debug.WriteLine("Removal is successful: " + res.ToString);
    // Save changes
    MsObj.Save;
End Sub UserProc;

After execution of the example the recursive deletion of the first scenario tree will be performed. Removal results are displayed in the console window.

See also:

IMsScenarioTreeEntries