//Gets all the members in the model and bakes them as breps to the rhino. public static Tuple <Member[], Dlubal.RFEM5.CrossSection[]> GetMembers(string comment) { OpenConnection(); try { IModelData rData = RModel.GetModelData(); Dlubal.RFEM5.Line[] lines = rData.GetLines(); Dlubal.RFEM5.CrossSection[] crossSecs = rData.GetCrossSections(); Member[] members = rData.GetMembers(); members = members.Where(o => o.Comment == comment).ToArray(); List <Member> mList = new List <Member>(); Dictionary <int, Brep> rCrossSecs = new Dictionary <int, Brep>(); foreach (Dlubal.RFEM5.CrossSection crossSec in crossSecs) { rCrossSecs.Add(crossSec.No, GetCrscDBShape(crossSec.TextID)); } foreach (Member member in members) { Dlubal.RFEM5.Line line = rData.GetLine(member.LineNo, ItemAt.AtNo).GetData(); Rhino.Geometry.Line rhLine = lineRfemToRhino(line, rData); Vector3d direction = new Vector3d(rhLine.To - rhLine.From); Plane plane = new Plane(rhLine.From, direction); Brep tempCross = (Brep)rCrossSecs[member.StartCrossSectionNo].Duplicate(); Transform tr = Transform.PlaneToPlane(Plane.WorldXY, plane); tempCross.Transform(tr); Brep extruded = tempCross.Faces[0].CreateExtrusion(rhLine.ToNurbsCurve(), true); ProjectPlugIn.Instance.beamBreps.Add(Tuple.Create(member.No, extruded)); } foreach (Member m in members) { Dlubal.RFEM5.CrossSection c = Array.Find(crossSecs, o => o.No == m.StartCrossSectionNo); if (c.TextID.Split(' ')[0] == "Rechteck" || c.TextID.Split(' ')[0] == "Kreis") { mList.Add(m); } } CloseConnection(); return(Tuple.Create(mList.ToArray(), crossSecs)); } 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(); CloseConnection(); } return(Tuple.Create <Member[], Dlubal.RFEM5.CrossSection[]>(null, null)); }
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); }