You are currently reviewing an older revision of this page.
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 for how to do this 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 scenarioIScenario 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 instruction, please post your questions to the Forum
WaterObjects.NET - Extending the capabilities of your OpenFlows product