Esempio n. 1
0
        public static IGeometry Geometry3D(this IFramingElement framingElement)
        {
            if (framingElement == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the 3D Geometry of a null framing element.");
                return(null);
            }

            if (framingElement.Location == null)
            {
                BH.Engine.Reflection.Compute.RecordError($"Cannot compute the Geometry3D for this {nameof(IFramingElement)} because its `{nameof(IFramingElement.Location)}` is null.");
                return(null);
            }

            Line line = framingElement.Location as Line;

            if (line == null)
            {
                Polyline pl = framingElement.Location as Polyline;
                if (pl != null)
                {
                    line = new Line()
                    {
                        Start = pl.ControlPoints.First(), End = pl.ControlPoints.Last()
                    };
                }

                if (pl == null || (pl != null && pl.ControlPoints.Count() > 2))
                {
                    BH.Engine.Reflection.Compute.RecordWarning($"Geometry3D for {nameof(IFramingElement)} currently works only if it has its {nameof(IFramingElement.Location)} defined as a {nameof(Line)}. Proceeding by taking Start/End point of the provided {framingElement.Location.GetType().Name}.");
                }
            }

            Vector extrusionVec          = BH.Engine.Geometry.Create.Vector(line.Start, line.End);
            Vector normal                = line.ElementNormal(0);
            IFramingElementProperty prop = framingElement.Property;

            ConstantFramingProperty constantFramingProperty = prop as ConstantFramingProperty;

            if (constantFramingProperty == null)
            {
                BH.Engine.Reflection.Compute.RecordError($"Geometry3D for {nameof(IFramingElement)} currently works only if its {nameof(IFramingElement.Property)} is of type {nameof(ConstantFramingProperty)}.");
                return(null);
            }

            List <ICurve> profileToExtrude = constantFramingProperty.Profile.Edges.ToList();

            if (profileToExtrude == null || !profileToExtrude.Any())
            {
                BH.Engine.Reflection.Compute.RecordError($"Geometry3D error: could not gather the profile curve to be extruded for this {framingElement.GetType().Name}.");
                return(null);
            }

            TransformMatrix totalTransform = SectionTranformation(line.Start, extrusionVec.Normalise(), normal);

            return(Extrude(profileToExtrude, totalTransform, extrusionVec));
        }
Esempio n. 2
0
        public static Column Column(Point basePoint, double height, IFramingElementProperty property, string name = "")
        {
            if (basePoint == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot create a Physical.Column from a null base point.");
                return(null);
            }

            return(Create.Column(Geometry.Create.Line(basePoint, basePoint + Vector.ZAxis * height), property, name));
        }
Esempio n. 3
0
        public static double IAverageProfileArea(this IFramingElementProperty framingProperty)
        {
            if (framingProperty == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the average profile area of a null framing property.");
                return(0);
            }

            return(AverageProfileArea(framingProperty as dynamic));
        }
Esempio n. 4
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static Column ColumnFromRevit(this FamilyInstance familyInstance, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            Column column = refObjects.GetValue <Column>(familyInstance.Id);

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

            oM.Geometry.ICurve      locationCurve = familyInstance.LocationCurveColumn(settings);
            IFramingElementProperty property      = familyInstance.FramingElementProperty(settings, refObjects);

            column = BH.Engine.Physical.Create.Column(locationCurve, property, familyInstance.Name);

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

            refObjects.AddOrReplace(familyInstance.Id, column);
            return(column);
        }
Esempio n. 5
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static Beam BeamFromRevit(this FamilyInstance familyInstance, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            Beam beam = refObjects.GetValue <Beam>(familyInstance.Id);

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

            oM.Geometry.ICurve      locationCurve = familyInstance.LocationCurveFraming(settings);
            IFramingElementProperty property      = familyInstance.FramingElementProperty(settings, refObjects);

            beam = BH.Engine.Physical.Create.Beam(locationCurve, property, familyInstance.Name);

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

            refObjects.AddOrReplace(familyInstance.Id, beam);
            return(beam);
        }
Esempio n. 6
0
 public static Bracing Bracing(ICurve location, IFramingElementProperty property, string name = "")
 {
     return(new Bracing {
         Location = location, Property = property, Name = name
     });
 }
Esempio n. 7
0
 public static Cable Cable(ICurve location, IFramingElementProperty property, string name = "")
 {
     return(new Cable {
         Location = location, Property = property, Name = name
     });
 }
Esempio n. 8
0
 public static Column Column(Point basePoint, double height, IFramingElementProperty property, string name = "")
 {
     return(Create.Column(Geometry.Create.Line(basePoint, basePoint + Vector.ZAxis * height), property, name));
 }
        /***************************************************/
        /**** Private Fallback Methods                  ****/
        /***************************************************/

        private static MaterialComposition MaterialComposition(this IFramingElementProperty prop)
        {
            throw new NotImplementedException();
        }
        /******************************************************/
        /**** IFramingElementProperty Methods              ****/
        /******************************************************/

        private static MaterialComposition IMaterialComposition(this IFramingElementProperty prop)
        {
            return(MaterialComposition(prop as dynamic));
        }
Esempio n. 11
0
 public static FramingElement FramingElement(ICurve locationCurve, IFramingElementProperty property, StructuralUsage1D structuralUsage = StructuralUsage1D.Beam, string name = "")
 {
     return new FramingElement { LocationCurve = locationCurve, Property = property, StructuralUsage = structuralUsage, Name = name };
 }
Esempio n. 12
0
        /***************************************************/
        /****    private fallback method            ********/
        /***************************************************/

        private static double AverageProfileArea(this IFramingElementProperty framingProperty)
        {
            throw new NotImplementedException();
        }
Esempio n. 13
0
 public static double IAverageProfileArea(this IFramingElementProperty framingProperty)
 {
     return(AverageProfileArea(framingProperty as dynamic));
 }