Пример #1
0
        public static void GetAllCalculatedResults(this ILoads loads, ref List <string> lCasesAndCombos, ref ICalculation results, ref int countCases, ref int countCombos, ref int countResultCombos, ref List <string> msg)
        {
            /// Get results just of calculated load cases and combos and add names to dropdown menu

            lCasesAndCombos   = new List <string>();
            countCases        = 0;
            countCombos       = 0;
            countResultCombos = 0;

            // Load cases
            foreach (var lc in loads.GetLoadCases())
            {
                var loading = lc.Loading;
                if (loads.HasLoadingResults(loading))
                {
                    lCasesAndCombos.Add($"LoadCase {loading.No}");
                    var errors = results.Calculate(loading.Type, loading.No);
                    if (errors != null)
                    {
                        msg.AddRange(errors.Select(x => x.Description));
                    }
                    countCases++;
                }
            }

            // Load combos
            foreach (var lc in loads.GetLoadCombinations())
            {
                var loading = lc.Loading;
                if (loads.HasLoadingResults(loading))
                {
                    lCasesAndCombos.Add($"LoadCombo {loading.No}");
                    var errors = results.Calculate(loading.Type, loading.No);
                    if (errors != null)
                    {
                        msg.AddRange(errors.Select(x => x.Description));
                    }
                }
                countCombos++;
            }

            // Result combos
            foreach (var lc in loads.GetResultCombinations())
            {
                var loading = lc.Loading;
                if (loads.HasLoadingResults(loading))
                {
                    lCasesAndCombos.Add($"ResultCombo {loading.No}");
                    var errors = results.Calculate(loading.Type, loading.No);
                    if (errors != null)
                    {
                        msg.AddRange(errors.Select(x => x.Description));
                    }
                }
                countResultCombos++;
            }
        }
Пример #2
0
        public static void GetLoadCasesAndCombos(this ILoads loads, ref List <string> lCasesAndCombos, ref int countCases, ref int countCombos, ref int countRcombos)
        {
            var lCases  = new List <string>();
            var lCombos = new List <string>();
            var rCombos = new List <string>();

            lCases       = loads.GetLoadCases().Select(x => "LoadCase " + x.Loading.No.ToString()).ToList();
            countCases   = lCases.Count;
            lCombos      = loads.GetLoadCombinations().Select(x => "LoadCombo " + x.Loading.No.ToString()).ToList();
            countCombos  = lCombos.Count;
            rCombos      = loads.GetResultCombinations().Select(x => "ResultCombo " + x.Loading.No.ToString()).ToList();
            countRcombos = rCombos.Count;

            lCasesAndCombos = new List <string>();
            lCasesAndCombos.AddRange(lCases);
            lCasesAndCombos.AddRange(lCombos);
            lCasesAndCombos.AddRange(rCombos);
        }
Пример #3
0
        public static List <string> GetLoadCasesAndCombos(this ILoads loads, ref int countCases, ref int countCombos, ref int countRcombos)
        {
            var lCasesAndCombos = new List <string>();

            countCases   = 0;
            countCombos  = 0;
            countRcombos = 0;
            // Load cases
            foreach (var lc in loads.GetLoadCases())
            {
                var loading = lc.Loading;
                if (loads.HasLoadingResults(loading))
                {
                    lCasesAndCombos.Add($"LoadCase {loading.No}");
                    countCases++;
                }
            }

            // Load combos
            foreach (var lc in loads.GetLoadCombinations())
            {
                var loading = lc.Loading;
                if (loads.HasLoadingResults(loading))
                {
                    lCasesAndCombos.Add($"LoadCombo {loading.No}");
                }
                countCombos++;
            }

            // Result combos
            foreach (var lc in loads.GetResultCombinations())
            {
                var loading = lc.Loading;
                if (loads.HasLoadingResults(loading))
                {
                    lCasesAndCombos.Add($"ResultCombo {loading.No}");
                }
                countRcombos++;
            }

            return(lCasesAndCombos);
        }
        public static List <Tuple <int, Vector3d, Vector3d> > GetMemberIternalForces(List <int> loadCases, LoadingType loadingType, int memberNumber)
        {
            OpenConnection();

            List <Tuple <int, Vector3d, Vector3d> > results = new List <Tuple <int, Vector3d, Vector3d> >();

            try
            {
                ICalculation      calc  = RModel.GetCalculation();
                IModelData        data  = RModel.GetModelData();
                ILoads            loads = RModel.GetLoads();
                LoadCombination[] lc    = loads.GetLoadCombinations();
                foreach (int loadcase in loadCases)
                {
                    try
                    {
                        IResults       res         = calc.GetResultsInFeNodes(loadingType, loadcase);
                        MemberForces[] mf          = res.GetMemberInternalForces(memberNumber, ItemAt.AtNo, true);
                        Vector3d       startForces = new Vector3d(mf[0].Forces.X, mf[0].Moments.Y, mf[0].Moments.Z);
                        Vector3d       endForces   = new Vector3d(mf[mf.Length - 1].Forces.X, mf[mf.Length - 1].Moments.Y, mf[mf.Length - 1].Moments.Z);
                        results.Add(Tuple.Create(loadcase, startForces, endForces));
                    }
                    catch { continue; }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Cleans Garbage collector for releasing all COM interfaces and objects
                System.GC.Collect();
                System.GC.WaitForPendingFinalizers();
            }
            finally
            {
                CloseConnection();
            }
            return(results);
        }
        public static List <double> GetUtilizations(Classes_and_structures.Column col, List <int> memberNumbs)
        {
            //Create new Columns for each of the imported column
            foreach (int no in memberNumbs)
            {
                ProjectPlugIn.Instance.Beams.Add(col.ShallowCopy(no.ToString()));
            }

            List <double> utilzTot = new List <double>();

            OpenConnection();
            try
            {
                Dictionary <int, Tuple <int, double> > utilz = new Dictionary <int, Tuple <int, double> >();
                foreach (int numb in memberNumbs)
                {
                    utilz.Add(numb, Tuple.Create(0, 0.0));
                }

                ICalculation      calc  = RModel.GetCalculation();
                IModelData        data  = RModel.GetModelData();
                ILoads            loads = RModel.GetLoads();
                LoadCombination[] lc    = loads.GetLoadCombinations();

                //int[] numbs = lc.Select(o => o.Loading.No).ToArray();
                //numbs = Array.FindAll(numbs, o => o > 100 || o < 200);
                List <int> numbs = new List <int>()
                {
                    149, 150, 153, 154, 157, 158, 159, 160, 166
                };
                int k = 0;
                foreach (int number in numbs)
                {
                    IResults res = calc.GetResultsInFeNodes(LoadingType.LoadCombinationType, number);

                    MemberForces[] mfs = res.GetMembersInternalForces(true);

                    ProjectPlugIn  ppi = ProjectPlugIn.Instance;
                    SimpleLoadCase slc;
                    for (int i = 0; i < mfs.Length; i++)
                    {
                        if (memberNumbs.Contains(mfs[i].MemberNo))
                        {
                            slc = new SimpleLoadCase(mfs[i].Forces.X, mfs[i].Moments.Z, mfs[i].Moments.Y,
                                                     col, number.ToString(), LimitState.Ultimate);

                            if (slc.Utilization > utilz[mfs[i].MemberNo].Item2)
                            {
                                utilz[mfs[i].MemberNo] = Tuple.Create(i, slc.Utilization);
                            }
                        }
                    }

                    foreach (int key in utilz.Keys)
                    {
                        Classes_and_structures.Column tempCol = (Classes_and_structures.Column)ProjectPlugIn.Instance.Beams
                                                                .Find(o => o.Name == key.ToString());
                        tempCol.LoadCases.Add(new SimpleLoadCase(mfs[utilz[key].Item1].Forces.X, mfs[utilz[key].Item1].Moments.Z, mfs[utilz[key].Item1].Moments.Y,
                                                                 tempCol, number.ToString(), LimitState.Ultimate));
                    }
                    mfs = null;

                    k++;
                }

                foreach (int memberNo in memberNumbs)
                {
                    Classes_and_structures.Column tempCol = (Classes_and_structures.Column)ProjectPlugIn.Instance.Beams
                                                            .Find(o => o.Name == memberNo.ToString());

                    SimpleLoadCase[] temp = tempCol.LoadCases.Select(o => o as SimpleLoadCase).ToArray();
                    utilzTot.Add(temp.MaxBy(o => o.Utilization).Utilization);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Cleans Garbage collector for releasing all COM interfaces and objects
                System.GC.Collect();
                System.GC.WaitForPendingFinalizers();
            }
            finally
            {
                CloseConnection();
            }

            return(utilzTot);
        }