Пример #1
0
        private static bool VerifyDesignSection(ref SAPFrameElement elem, SAPSection sec)
        {
            string name = elem.Name;

            mySapModel.SelectObj.PropertyFrame(elem.Name);//Select Frame Element

            SAPDesignStatistics statistics = new SAPDesignStatistics();

            mySapModel.DesignSteel.StartDesign();
            int 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
            {
                if (statistics.failedElementsNames.FirstOrDefault(c => c == name) == null)
                {
                    elem.IsDesignPassed = true;
                }
            }
            mySapModel.SelectObj.PropertyFrame(elem.Name, true);//DeSelect Frame Element
            return(true);
        }
Пример #2
0
 /// <summary>
 /// The general function that takes any type of sections and define it in SAP2000
 /// </summary>
 /// <param name="section"></param>
 public static void AddSection(SAPSection section)
 {
     if (section is SAPISection)
     {
         SetISection((SAPISection)section);
     }
     else if (section is SAPITaperedSection)
     {
         SetITaperedSection((SAPITaperedSection)section);
     }
     //TODO else if another section .. etc
 }
Пример #3
0
        public static bool DeleteSection(SAPSection sec)
        {
            int flag = mySapModel.PropFrame.Delete(sec.Name);

            if (flag != 0)
            {
                return(false);
            }
            else
            {
                sec.IsDefinedInSAP = false;
                return(true);
            }
        }
Пример #4
0
        public static SAPSection GetSection(SAPSection section)
        {
            if (section is SAPISection)
            {
                SAPISection temp = (SAPISection)section;
                temp    = GetISection(temp);
                section = temp;
            }
            else if (section is SAPITaperedSection)
            {
                SAPITaperedSection temp = (SAPITaperedSection)section;
                temp    = GetITaperedSection(temp);
                section = temp;
            }

            //TODO else if another section .. etc
            return(section);
        }
Пример #5
0
        public static bool SetDesignSection(ref SAPFrameElement elem, SAPSection sec)
        {
            VerifyDesignSection(ref elem, elem.Section);
            if (sec.IsDefinedInSAP == false)
            {
                mySapModel.SetModelIsLocked(false);
                // DeleteSection(elem.Section);
                AddSection(sec);
                AnalayzeModel();
            }
            int flag = mySapModel.DesignSteel.SetDesignSection(elem.Name, sec.Name, false);

            if (flag != 0)
            {
                return(false);
            }
            else
            {
                elem.Section = sec;
                VerifyDesignSection(ref elem, sec);
                return(true);
            }
        }
Пример #6
0
        private static SAPSection GetSectionByElement(string elementName)
        {
            //TODO : THIS FUNCTION IS TERRIBLE, REWRITE IT AGIAN
            SAPSection section = null;
            int        flag;
            string     propName = string.Empty;
            string     SAlist   = string.Empty;

            flag = mySapModel.FrameObj.GetSection(elementName, ref propName, ref SAlist);
            if (flag != 0)
            {
                return(null);
            }
            else
            {
                //Try to get this section as if it was a tapered section
                SAPITaperedSection tSec = new SAPITaperedSection();
                tSec.Name = propName;
                tSec      = GetITaperedSection(tSec);
                section   = tSec;
                if (tSec == null)
                {
                    //It's not tapered then it's I built up section
                    SAPISection sec = new SAPISection();
                    sec.Name = propName;
                    sec      = GetISection(sec);
                    section  = sec;
                }
                if (section == null)
                {
                    section                = new SAPITaperedSection();
                    section.Name           = propName;
                    section.IsDefinedInSAP = true;
                }
            }
            return(section);
        }
Пример #7
0
 public SAPFrameElement(string name, SAPPoint startPoint, SAPPoint endPoint, SAPSection section) : this(name)
 {
     StartPoint = startPoint;
     EndPoint   = endPoint;
     Section    = section;
 }
Пример #8
0
        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);
            }
        }