コード例 #1
0
        //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));
        }