public static bool DesignSteelModel(string codeName, ref SAPDesignStatistics statistics, bool ToChangeSections, params IEnumerable <SAPFrameElement>[] elements) { // List<SAPITaperedSection> sectionsInventory = new List<SAPITaperedSection>(); int flag = mySapModel.DesignSteel.SetCode(codeName); //Setting the design Code AddDesignDefaultCombos(eMatType.Steel); flag = mySapModel.DesignSteel.StartDesign();//Starting the design process if (flag != 0) { //Design Failed return(false); } else { //A Question to be answered, should we use here verify passed or verify sections flag = mySapModel.DesignSteel.VerifyPassed(ref statistics.noVerified, ref statistics.noFailed, ref statistics.noUnchecked, ref statistics.failedElementsNames); } if (flag != 0) { //Retrieving Sections Failed return(false); } else { //Changing Flags foreach (IEnumerable <SAPFrameElement> param in elements) { foreach (string name in statistics.failedElementsNames) { //TODO: Optimizing search algorithm here is important SAPFrameElement element = param.FirstOrDefault(c => c.Name == name); if (element != null) { element.IsDesignPassed = false; if (ToChangeSections == true) { //sectionsInventory.Add((SAPITaperedSection)element.Section); //int k = 0; //while (sectionsInventory[k]!=null) //{ // sectionsInventory.Add(sectionsInventory[k]); // k++; // mySapModel.SetModelIsLocked(false); // AddSection(sectionsInventory[k]); //} //AnalayzeModel(); int iterationsNo = 0; bool flagD = true; while (element.IsDesignPassed == false && iterationsNo < 30) { SAPSection sec = element.Section.GetAssumedSection(); if (sec == null || element.Section == sec || flagD == false) { flagD = true; break; } SAPSection sapSec = GetSection(sec); if (sapSec != null) { sec = sapSec; } flagD = SetDesignSection(ref element, sec); iterationsNo++; } } } } foreach (SAPFrameElement element in param) { if (element.IsDesignPassed == null) { element.IsDesignPassed = true; } } } // flag = mySapModel.DesignSteel.VerifySections(ref statistics.noDesigned, ref statistics.changedElementsNames); //} //if (flag != 0) //{ // //Retrieving changed sections failed // return false; //} //else if (statistics.ChangedElementsNames[0] != null) //{ // foreach (IEnumerable<SAPFrameElement> param in elements) // { // foreach (string name in statistics.ChangedElementsNames) // { // SAPSection section = param.FirstOrDefault(c => c.Name == name).Section; // if (section != null) // { // section = GetSection(section); // } // } // } //} return(true); } }
public static bool DesignSteelModel(string codeName, SAPLoadCombination deflectionCombo, SAPLoadCombination strengthCombo, bool ToChangeSections, IEnumerable <SAPFrameElement> elements, ref SAPDesignStatistics statistics) { //Setting Design combinations int flag = mySapModel.DesignSteel.SetComboDeflection(deflectionCombo.Name, true); flag = mySapModel.DesignSteel.SetComboStrength(deflectionCombo.Name, true); if (flag != 0) { return(false); } else { return(DesignSteelModel(codeName, ref statistics, ToChangeSections, elements)); } }