Ejemplo n.º 1
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/


        public static Type GetSectionType(this rf.CrossSection rfSectionProperty)
        {
            string[] propertyString = rfSectionProperty.TextID.Split('@');

            if (true)
            {
                return(typeof(SteelSection));
            }
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static ISectionProperty FromRFEM(this rf.ICrossSection rfISectionProperty, rf.Material rfMaterial)
        {
            rf.CrossSection rfSectionProperty = rfISectionProperty.GetData();

            string sectionName = rfSectionProperty.Description;

            rf3.DB_CRSC_PROPERTY[] sectionDBProps = null;
            object libraryObj = null;

            if (sectionName != "")
            {
                try
                {
                    libraryObj = rfISectionProperty.GetDatabaseCrossSection();
                    rf3.IrfCrossSectionDB sectionFromDB = libraryObj as rf3.IrfCrossSectionDB;

                    int propCount = sectionFromDB.rfGetPropertyCount();
                    sectionDBProps = new rf3.DB_CRSC_PROPERTY[propCount];
                    sectionFromDB.rfGetPropertyArrAll(propCount, sectionDBProps);
                }
                catch
                {
                    Engine.Base.Compute.RecordWarning("Could not create section named " + sectionName + " from library parameters. Best guess on name will be used");
                }
            }


            IMaterialFragment materialFragment = rfMaterial.FromRFEM();
            IProfile          profile          = Engine.Adapters.RFEM.Compute.GetSectionProfile(sectionName, sectionDBProps);

            if (profile != null)
            {
                IGeometricalSection geoSection = BH.Engine.Structure.Create.SectionPropertyFromProfile(profile, materialFragment, rfSectionProperty.TextID);// this creates the right property if the right material is provided
                geoSection.SetAdapterId(typeof(RFEMId), rfSectionProperty.No);
                geoSection.Name = rfSectionProperty.TextID;

                return(geoSection);
            }
            else
            {
                ExplicitSection expSection = new ExplicitSection();
                expSection.Material = materialFragment;
                expSection.Area     = rfSectionProperty.AxialArea;
                expSection.J        = rfSectionProperty.TorsionMoment;
                expSection.Asy      = rfSectionProperty.ShearAreaY;
                expSection.Asz      = rfSectionProperty.ShearAreaZ;
                expSection.Iy       = rfSectionProperty.BendingMomentY;
                expSection.Iz       = rfSectionProperty.BendingMomentZ;
                expSection.SetAdapterId(typeof(RFEMId), rfSectionProperty.No);
                expSection.Name = rfSectionProperty.TextID;
                return(expSection);
            }
        }
Ejemplo n.º 4
0
        private void button_Import_Click(object sender, EventArgs e)
        {
            if (textBox_Comment.Text != null)
            {
                try
                {
                    Tuple <Member[], Dlubal.RFEM5.CrossSection[]> res = GetGeometry.GetMembers(textBox_Comment.Text);
                    Member[] members = res.Item1;
                    Dlubal.RFEM5.CrossSection[] crossSecs = res.Item2;
                    if (dataGridViewValues.Rows.Count == 1)
                    {
                        dataGridViewValues.Rows.Add();
                    }
                    for (int i = 0; i < members.Length; i++)
                    {
                        if (i > dataGridViewValues.Rows.Count - 1)
                        {
                            dataGridViewValues.Rows.Add();
                        }

                        dataGridViewValues.Rows[i].Cells["No"].Value = members[i].No;
                        //dataGridViewValues.Rows[i].Cells["Length"].Value = Math.Round(members[i].Length,3);
                        Dlubal.RFEM5.CrossSection c = Array.Find(crossSecs, o => o.No == members[i].StartCrossSectionNo);
                        if (c.TextID.Split(' ')[0] == "Rechteck")
                        {
                            double height = double.Parse(c.TextID.Split(' ')[1].Split('/')[1]);
                            double width  = double.Parse(c.TextID.Split(' ')[1].Split('/')[0]);
                            dataGridViewValues.Rows[i].Cells["Type"].Value        = "Rectangle";
                            dataGridViewValues.Rows[i].Cells["Rect_Height"].Value = height;
                            dataGridViewValues.Rows[i].Cells["Rect_Width"].Value  = width;
                        }
                        else if (c.TextID.Split(' ')[0] == "Kreis")
                        {
                            double diam = double.Parse(c.TextID.Split(' ')[1]);
                            dataGridViewValues.Rows[i].Cells["Type"].Value        = "Circle";
                            dataGridViewValues.Rows[i].Cells["Circle_Diam"].Value = diam.ToString();
                        }
                        else
                        {
                            MessageBox.Show($"Wrong type cross section. at member No. {members[i].No}. Cannot import", "Error", MessageBoxButtons.OK);
                        }
                    }
                }
                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();
                }
            }
        }
Ejemplo n.º 5
0
        /***************************************************/

        private ISectionProperty GetSectionProperty(int crossSectionNumber)
        {
            ISectionProperty sectionProperty;

            if (!m_sectionDict.TryGetValue(crossSectionNumber, out sectionProperty))
            {
                rf.ICrossSection rfISection = modelData.GetCrossSection(crossSectionNumber, rf.ItemAt.AtNo);
                rf.CrossSection  rfSection  = rfISection.GetData();
                rf.Material      rfMat      = modelData.GetMaterial(rfSection.MaterialNo, rf.ItemAt.AtNo).GetData();
                sectionProperty = rfISection.FromRFEM(rfMat);
                m_sectionDict.Add(crossSectionNumber, sectionProperty);
            }

            return(sectionProperty);
        }
Ejemplo n.º 6
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static rf.CrossSection ToRFEM(this ISectionProperty sectionProperty, int sectionPropertyId, int materialId)
        {
            rf.CrossSection rfSectionProperty = new rf.CrossSection();
            string          name;

            rfSectionProperty.No             = sectionPropertyId;
            rfSectionProperty.MaterialNo     = materialId;
            rfSectionProperty.AxialArea      = sectionProperty.Area;
            rfSectionProperty.TorsionMoment  = sectionProperty.J;
            rfSectionProperty.ShearAreaY     = sectionProperty.Asy;
            rfSectionProperty.ShearAreaZ     = sectionProperty.Asz;
            rfSectionProperty.BendingMomentY = sectionProperty.Iy;
            rfSectionProperty.BendingMomentZ = sectionProperty.Iz;

            name = sectionProperty.DescriptionOrName();

            rfSectionProperty.Description = name;
            rfSectionProperty.TextID      = name;

            return(rfSectionProperty);
        }
Ejemplo n.º 7
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private bool CreateCollection(IEnumerable <ISectionProperty> sectionProperties)
        {
            if (sectionProperties.Count() > 0)
            {
                int idNum    = 0;
                int matNumId = 0;
                List <ISectionProperty> secList         = sectionProperties.ToList();
                rf.CrossSection[]       rfCrossSections = new rf.CrossSection[secList.Count()];

                for (int i = 0; i < secList.Count(); i++)
                {
                    idNum              = GetAdapterId <int>(secList[i]);// NextId(secList[i].GetType()));
                    matNumId           = GetAdapterId <int>(secList[i]);
                    rfCrossSections[i] = secList[i].ToRFEM(idNum, matNumId);
                    modelData.SetCrossSection(rfCrossSections[i]);
                }

                //modelData.SetCrossSections(rfCrossSections);
            }

            return(true);
        }
Ejemplo n.º 8
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        //The List<string> in the methods below can be changed to a list of any type of identification more suitable for the toolkit
        //If no ids are provided, the convention is to return all elements of the type

        private List <ISectionProperty> ReadSectionProperties(List <string> ids = null)
        {
            List <ISectionProperty> sectionPropList = new List <ISectionProperty>();

            //ReadSectionFromRFEMLibrary("IPE 200");

            if (ids == null)
            {
                foreach (rf.CrossSection rfSection in modelData.GetCrossSections())
                {
                    rf.Material      rfMaterial = modelData.GetMaterial(rfSection.MaterialNo, rf.ItemAt.AtNo).GetData();
                    rf.ICrossSection rfISection = modelData.GetCrossSection(rfSection.No, rf.ItemAt.AtNo);
                    ISectionProperty section    = rfISection.FromRFEM(rfMaterial);

                    sectionPropList.Add(section);

                    int sectionId = rfSection.No;
                    if (!m_sectionDict.ContainsKey(sectionId))
                    {
                        m_sectionDict.Add(sectionId, section);
                    }
                }
            }
            else
            {
                foreach (string id in ids)
                {
                    rf.ICrossSection rfISection = modelData.GetCrossSection(Int32.Parse(id), rf.ItemAt.AtNo);
                    rf.CrossSection  rfSection  = rfISection.GetData();
                    rf.Material      rfMaterial = modelData.GetMaterial(rfSection.MaterialNo, rf.ItemAt.AtNo).GetData();
                    sectionPropList.Add(rfISection.FromRFEM(rfMaterial));
                }
            }


            return(sectionPropList);
        }