Symptom
Running a script for Scenario Management addressing Scenario attributes fails with an error message:
How can I use Scenario attributes like Name or Code from a Python script that uses the Scenario Management?
Cause
Due to the different scopes this is not directly possible: The Visum instance running the Scenario Management cannot share data with a Visum instance opened with one Scenario.
Solution
There is a way to achieve this:
- In the Scenario Management, in its tab "Procedure parameter sets", edit the Procedure parameter set used in the Scenarios.
- In Calculate -> Procedure variables -> Definitions
add a Procedure Variable like "ScenNo".
- Finish the edit mode.
- In the tab "Scenarios" this variable is listed like any other Scenario attribute, you can even add it together with Number and Code. Use this to copy&paste values like in Excel.
- When opening one Scenario, you'll find its respective value in:
Calculate -> Procedure variables -> Values
- In the Procedure "Edit attribute" this is accessible through:
Network object type: OperationVariables
Target attribute: ScenNo
- In a script this is accessible through:
myScenNo = Visum.Procedures.OperationVariables.GetOperationVariable("ScenNo")
myScenNo.ValueOfVariable
