/***************************************************/ /**** 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); } }
/***************************************************/ 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); }
/***************************************************/ /**** 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); }