Beispiel #1
0
        public static List <Bar> MapTaperedProfile(List <Bar> bars, IGeometricalSection section)
        {
            if (bars.Any(x => x.IsNull()) || section.IsNull())
            {
                return(null);
            }

            List <Bar> newBars = bars.ShallowClone();

            if (!(section.SectionProfile is TaperedProfile))
            {
                Reflection.Compute.RecordError("Section provided does not contain a TaperedProfile.");
                foreach (Bar newBar in newBars)
                {
                    newBar.SectionProperty = section;
                }
            }
            else
            {
                List <TaperedProfile>      mappedTaperedProfiles = MapTaperedProfile(bars, section.SectionProfile as TaperedProfile);
                List <IGeometricalSection> sections = mappedTaperedProfiles.Select(x => Create.SectionPropertyFromProfile(x, section.Material)).ToList();
                for (int i = 0; i < sections.Count; i++)
                {
                    sections[i].Name           = section.Name + "-s" + i;
                    newBars[i].SectionProperty = sections[i];
                }
            }

            return(newBars);
        }
Beispiel #2
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);
            }
        }
Beispiel #3
0
 public static IGeometry Geometry(this IGeometricalSection section)
 {
     if (section?.SectionProfile?.Edges == null)
     {
         return(new CompositeGeometry());
     }
     else
     {
         return new CompositeGeometry {
                    Elements = section.SectionProfile.Edges.ToList <IGeometry>()
         }
     };
 }
Beispiel #4
0
        /***************************************************/
        /**** Set Section                               ****/
        /***************************************************/

        private void SetSection(IGeometricalSection bhomSection)
        {
            string name = bhomSection.DescriptionOrName();

            if (bhomSection.SectionProfile == null)
            {
                Engine.Base.Compute.RecordWarning($"Profile for {name} is null. Section was not created");
                return;
            }

            SetProfile(bhomSection.SectionProfile as dynamic, bhomSection.DescriptionOrName(), bhomSection.Material?.DescriptionOrName() ?? "");
            return;
        }
Beispiel #5
0
        /***************************************************/
        /******     SetSection                       *******/
        /***************************************************/

        private void SetSection(IGeometricalSection section)
        {
            if (section.SectionProfile != null)
            {
                if (!ISetProfile(section.SectionProfile, section.DescriptionOrName(), section.Material))
                {
                    SetGeneral(section);
                }
            }
            else
            {
                Engine.Base.Compute.RecordWarning($"Section of type {section.GetType().Name} with name {section.DescriptionOrName()} has a null SectionProfile. Section will be pushed as an explicit section");
                SetGeneral(section);
            }
        }
Beispiel #6
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static IProfile ProfileFromRevit(this FamilySymbol familySymbol, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            IProfile profile = refObjects.GetValue <IProfile>(familySymbol.Id);

            if (profile != null)
            {
                return(profile);
            }

            IGeometricalSection property = BH.Engine.Library.Query.Match("SectionProperties", familySymbol.Name) as IGeometricalSection;

            if (property != null)
            {
                profile = property.SectionProfile.DeepClone();
            }

            if (profile == null)
            {
                Parameter sectionShapeParam         = familySymbol.get_Parameter(BuiltInParameter.STRUCTURAL_SECTION_SHAPE);
                StructuralSectionShape sectionShape = sectionShapeParam == null ? sectionShape = StructuralSectionShape.NotDefined : (StructuralSectionShape)sectionShapeParam.AsInteger();

                if (sectionShape == StructuralSectionShape.NotDefined)
                {
                    sectionShape = familySymbol.Family.Name.SectionShape();
                }

                switch (sectionShape)
                {
                case StructuralSectionShape.RoundBar:
                case StructuralSectionShape.ConcreteRound:
                    profile = familySymbol.CircleProfileFromRevit();
                    break;

                case StructuralSectionShape.IWelded:
                    profile = familySymbol.FabricatedISectionProfileFromRevit();
                    break;

                case StructuralSectionShape.RectangleParameterized:
                case StructuralSectionShape.RectangularBar:
                case StructuralSectionShape.ConcreteRectangle:
                    profile = familySymbol.RectangleProfileFromRevit();
                    break;

                case StructuralSectionShape.LAngle:
                case StructuralSectionShape.LProfile:
                    profile = familySymbol.AngleProfileFromRevit();
                    break;

                case StructuralSectionShape.RectangleHSS:
                    profile = familySymbol.BoxProfileFromRevit();
                    break;

                case StructuralSectionShape.CParallelFlange:
                case StructuralSectionShape.CProfile:
                    profile = familySymbol.ChannelProfileFromRevit();
                    break;

                case StructuralSectionShape.IParallelFlange:
                case StructuralSectionShape.IWideFlange:
                    profile = familySymbol.ISectionProfileFromRevit();
                    break;

                case StructuralSectionShape.ISplitParallelFlange:
                case StructuralSectionShape.StructuralTees:
                case StructuralSectionShape.ConcreteT:
                    profile = familySymbol.TSectionProfileFromRevit();
                    break;

                case StructuralSectionShape.ZProfile:
                    profile = familySymbol.ZSectionProfileFromRevit();
                    break;

                case StructuralSectionShape.PipeStandard:
                case StructuralSectionShape.RoundHSS:
                    profile = familySymbol.TubeProfileFromRevit();
                    break;
                }
            }

            if (profile == null)
            {
                profile = familySymbol.FreeFormProfileFromRevit(settings);
            }

            if (profile == null)
            {
                return(null);
            }

            //Set identifiers, parameters & custom data
            profile.SetIdentifiers(familySymbol);
            profile.CopyParameters(familySymbol, settings.ParameterSettings);
            profile.SetProperties(familySymbol, settings.ParameterSettings);

            profile.Name = familySymbol.Name;
            refObjects.AddOrReplace(familySymbol.Id, profile);

            return(profile);
        }
Beispiel #7
0
 public static IGeometry Geometry(this IGeometricalSection section)
 {
     return(new CompositeGeometry {
         Elements = section.SectionProfile.Edges.ToList <IGeometry>()
     });
 }