Product(s): |
WaterCAD, WaterGEMS, HAMMER, StormCAD, SewerCAD, SewerGEMS, CivilStorm, PondPack |
Version(s): |
V8 XM, V8i, CONNECT Edition |
Area: |
Modeling |
Problem
How can I create a child scenario in a WaterObjects.NET project?
Solution
Adding a child scenario is technically simple but there are a few things that need to be done after adding the child scenario.
Here is example code with comments to help you to better understand how to do this:
IDomainDataSet domainDataSet = GetDomainDataSet();
IScenarioManager scenarioManager = domainDataSet.ScenarioManager;
//Use the alternatives assigned to the first base scenario as
//the alternatives for the new alternative if a new base scenario
IScenario baseScenario = (IScenario)scenarioManager.Elements()[0];
int id = scenarioManager.Add();
IScenario child = (IScenario)scenarioManager.Element(id);
//parentID is the ID of the parent scenario.
//Leave this property 0 to make it a base scenario.
child.ParentID = parentID;
//This part is important to make sure alternatives are marked as
//inherited for the new child scenario.
AlternativeTypeCollection alternativeTypes = domainDataSet.DomainDataSetType().AlternativeTypes();
for (int i = 0; i < alternativeTypes.Count; ++i)
{
if (child.ParentID > 0)
child.MakeAlternativeInherited(alternativeTypes[i].Id);
else
child.AlternativeID(alternativeTypes[i].Id,
baseScenario.AlternativeID(alternativeTypes[i].Id));
}
//It is also important to mark calculation options inherited as well.
NumericalEngineTypeCollection engineTypes = domainDataSet.DomainDataSetType().NumericalEngineTypes();
for (int i = 0; i < engineTypes.Count; ++i)
{
if (child.ParentID > 0)
child.MakeCalculationOptionsInherited(engineTypes[i].Name);
else
child.CalculationOptionsID(engineTypes[i].Name,
baseScenario.CalculationOptionsID(engineTypes[i].Name));
}
If you need further assistance, please post your questions to the Forum
See Also:
WaterObjects.NET - Extending the capabilities of your OpenFlows product