IMsScenarioTreeEntries.AddScenario

Syntax

AddScenario([External: Boolean = False;][Save: Boolean = True]): IMsScenarioTreeElement;

Parameters

External. Indicates whether the scenario is external.

Save. Indicates whether the scenario is saved.

Description

The AddScenario method adds a new scenario.

Comments

Available values of the External parameter:

Available values of the Save parameter:

Example

Executing the example requires that the repository contains a modeling container with the MS identifier.

Add links to the Metabase, Ms system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    ModelSpace: IMsModelSpace;
    Tree: IMsScenarioTreeEntries;
    Folder: IMsScenarioTreeFolder;
    Scen: IMsScenarioTreeElement;
    Scenario: IMsScenario;
Begin
    // Get current repository
    MB := MetabaseClass.Active;
    // Get modeling container
    MObj := MB.ItemById("MS").Edit;
    ModelSpace := MObj As IMsModelSpace;
    // Get scenario tree
    Tree := ModelSpace.ScenarioTree;
    // Add folder
    Folder := Tree.AddFolder("Additional scenario");
    // Create a new scenario
    Scen := Folder.Contents.AddScenario(FalseFalse);
    // Set scenario name
    Scen.Name := "Base scenario";
    // Specify that scenario is protected
    Scenario := Scen.Scenario;
    Scenario.Protected_ := True;
    // Save changes to scenario
    (Scenario As IMetabaseObject).Save;
    // Save changes in modeling container
    MObj.Save;
End Sub UserProc;

After executing the example a new folder is added into the scenarios tree of modeling container. One protected scenario will be created in this folder.

See also:

IMsScenarioTreeEntries