You are currently reviewing an older revision of this page.
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));}
WaterObjects.NET - Extending the capabilities of your OpenFlows product