RemoveByKeyEx(EntryKey: Integer; Recursive: Boolean): Boolean;
EntryKey. Key of the element that must be removed.
Recursive. It determines whether to perform recursive removal of child elements. Available values:
True. The recursive removal of child element including elements located in child folders is performed.
False. Only the element which has its key specified in the EntryKey parameter is removed.
The RemoveByKeyEx method removes the element from the scenario tree with ability of recursive removal of child elements.
If the removal is successful, the method returns True, otherwise it returns False.
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: