Ejemplo n.º 1
0
        public static Opening Opening(IEnumerable <ICurve> edges, FrameEdgeProperty headProperty = null, FrameEdgeProperty jambProperty = null, FrameEdgeProperty sillProperty = null, IConstruction construction = null, string name = "")
        {
            if (edges == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot create an opening from a null collection of edges.");
                return(null);
            }

            List <ICurve> externalEdges = edges.SelectMany(x => x.ISubParts()).ToList();

            List <PolyCurve> joined = Geometry.Compute.IJoin(edges.ToList());

            if (joined.Count == 0)
            {
                Reflection.Compute.RecordError("Could not join Curves. Opening not created.");
                return(null);
            }
            else if (joined.Count > 1)
            {
                Reflection.Compute.RecordError("Provided curves could not be joined to a single curve. Opening not created.");
                return(null);
            }

            //Single joined curve
            if (joined[0].IIsClosed())
            {
                Opening opening = new Opening {
                    Edges = externalEdges.Select(x => new FrameEdge {
                        Curve = x
                    }).ToList(), OpeningConstruction = construction, Name = name
                };
                foreach (FrameEdge edge in opening.Edges)
                {
                    string edgeType = edge.FrameEdgeType(opening);
                    switch (edgeType)
                    {
                    case "Head":
                        edge.FrameEdgeProperty = headProperty;
                        break;

                    case "Jamb":
                        edge.FrameEdgeProperty = jambProperty;
                        break;

                    case "Sill":
                        edge.FrameEdgeProperty = sillProperty;
                        break;

                    default:
                        break;
                    }
                }
                return(opening);
            }
            else
            {
                Reflection.Compute.RecordError("Provided curves do not form a closed loop. Could not create opening.");
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static Polyline SimpleGeometry(this FrameEdgeProperty frameEdgeProp)
        {
            if (frameEdgeProp == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the simple geometry of a null frame edge property.");
                return(null);
            }

            List <BoundingBox> propProfileBounds = new List <BoundingBox>();
            List <ICurve>      profileOutlines   = new List <ICurve>();

            if (frameEdgeProp.SectionProperties.Count == 0)
            {
                BH.Engine.Reflection.Compute.RecordWarning("This FrameEdgeProperty has no SectionProperties and therefore no geometry associated with it.");
                return(new Polyline());
            }

            foreach (ConstantFramingProperty prop in frameEdgeProp.SectionProperties)
            {
                List <ICurve> crv = new List <ICurve>(prop.Profile.Edges);
                profileOutlines.AddRange(crv);
            }

            if (profileOutlines.Count == 0)
            {
                BH.Engine.Reflection.Compute.RecordWarning("This FrameEdgeProperty's SectionProperties have no profile geometry associated with them.");
                return(new Polyline());
            }

            List <PolyCurve> crvs = profileOutlines.IJoin();

            foreach (PolyCurve outline in crvs)
            {
                propProfileBounds.Add(outline.Bounds());
            }

            BoundingBox bounds = propProfileBounds.Bounds();
            double      maxY   = bounds.Max.Y;
            double      minY   = bounds.Min.Y;
            double      maxX   = bounds.Max.X;
            double      minX   = bounds.Min.X;

            Polyline rect = Engine.Geometry.Create.Polyline(new List <Point>()
            {
                new Point {
                    X = minX, Y = maxY
                }, new Point {
                    X = maxX, Y = maxY
                }, new Point {
                    X = maxX, Y = minY
                }, new Point {
                    X = minX, Y = minY
                }, new Point {
                    X = minX, Y = maxY
                }
            });

            return(rect);
        }
Ejemplo n.º 3
0
        public static double WidthIntoOpening(this FrameEdgeProperty frameEdgeProp)
        {
            if (frameEdgeProp == null)
            {
                return(0);
            }
            Polyline    rectGeo = frameEdgeProp.SimpleGeometry();
            BoundingBox bounds  = rectGeo.Bounds();

            if (bounds == null)
            {
                return(0);
            }
            return(bounds.Max.Y);
        }
Ejemplo n.º 4
0
        public static double Depth(this FrameEdgeProperty frameEdgeProp)
        {
            if (frameEdgeProp == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the depth of a null frame edge property.");
                return(0);
            }

            Polyline    rectGeo = frameEdgeProp.SimpleGeometry();
            BoundingBox bounds  = rectGeo.Bounds();

            if (bounds == null)
            {
                return(0);
            }
            return(bounds.Extents().X);
        }
Ejemplo n.º 5
0
        public static Panel Panel(ICurve outline, List <ICurve> openings = null, IConstruction construction = null, FrameEdgeProperty frameEdgeProperty = null, PanelType panelType = PanelType.Undefined, IConstruction openingConstruction = null, FrameEdgeProperty openingFrameEdgeProperty = null, string name = "")
        {
            if (outline == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot create a panel from a null outline.");
                return(null);
            }

            if (!outline.IIsClosed())
            {
                Reflection.Compute.RecordError("Outline not closed. Could not create Panel.");
                return(null);
            }
            List <Opening> pOpenings = openings != null?openings.Select(o => Create.Opening(new List <ICurve> {
                o
            }, openingConstruction, frameEdgeProperty)).Where(x => x != null).ToList() : new List <Opening>();

            List <FrameEdge> externalEdges = outline.ISubParts().Select(x => new FrameEdge {
                Curve = x, FrameEdgeProperty = frameEdgeProperty
            }).ToList();

            return(Create.Panel(externalEdges, pOpenings, construction, panelType, name));
        }
Ejemplo n.º 6
0
        public static Panel Panel(PlanarSurface surface, Construction construction = null, FrameEdgeProperty frameEdgeProperty = null, PanelType panelType = PanelType.Undefined, IConstruction openingConstruction = null, FrameEdgeProperty openingFrameEdgeProperty = null, string name = "")
        {
            if (surface == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot create a panel from a null surface.");
                return(null);
            }

            return(Panel(surface.ExternalBoundary, surface.InternalBoundaries.ToList(), construction, frameEdgeProperty, panelType, openingConstruction, openingFrameEdgeProperty, name));
        }
Ejemplo n.º 7
0
        public static Opening Opening(IEnumerable <ICurve> edges, IConstruction construction = null, FrameEdgeProperty frameEdgeProperty = null, string name = "")
        {
            if (edges == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot create an opening from a null collection of edges.");
                return(null);
            }

            List <ICurve> externalEdges = new List <ICurve>();

            foreach (ICurve edge in edges)
            {
                externalEdges.AddRange(edge.ISubParts());
            }

            List <PolyCurve> joined = Geometry.Compute.IJoin(edges.ToList());

            if (joined.Count == 0)
            {
                Reflection.Compute.RecordError("Could not join Curves. Opening not Created.");
                return(null);
            }
            else if (joined.Count > 1)
            {
                Reflection.Compute.RecordError("Provided curves could not be joined to a single curve. Opening not created.");
                return(null);
            }

            //Single joined curve
            if (joined[0].IIsClosed())
            {
                return new Opening {
                           Edges = externalEdges.Select(x => new FrameEdge {
                        Curve = x, FrameEdgeProperty = frameEdgeProperty
                    }).ToList(), OpeningConstruction = construction, Name = name
                }
            }
            ;
            else
            {
                Reflection.Compute.RecordError("Provided curves do not form a closed loop. Could not create opening.");

                return(null);
            }
        }
Ejemplo n.º 8
0
        public static CurtainWall CurtainWall(IEnumerable <ICurve> outlines, IEnumerable <IConstruction> constructions = null, FrameEdgeProperty headProperty = null, FrameEdgeProperty jambProperty = null, FrameEdgeProperty sillProperty = null, FrameEdgeProperty externalHeadProperty = null, FrameEdgeProperty externalJambProperty = null, FrameEdgeProperty externalSillProperty = null, string name = "")
        {
            if (outlines == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot create a CurtainWall from a null collection of outlines.");
                return(null);
            }

            if (constructions == null)
            {
                constructions = new List <IConstruction>();
            }

            bool useConstructions = true;

            if (outlines.Count() != constructions.Count())
            {
                BH.Engine.Reflection.Compute.RecordWarning("Outline and Construction list lengths do not match. CurtainWall will be created with no Opening Constructions applied.");
                useConstructions = false;
            }

            externalHeadProperty = externalHeadProperty ?? headProperty;
            externalJambProperty = externalJambProperty ?? jambProperty;
            externalSillProperty = externalSillProperty ?? sillProperty;

            List <Opening> openings = new List <Opening>();

            for (int i = 0; i < outlines.Count(); i++)
            {
                ICurve outline = outlines.ElementAt(i);
                if (outline == null)
                {
                    continue;
                }
                if (!outline.IIsClosed())
                {
                    BH.Engine.Reflection.Compute.RecordError("Outline at index " + i + " was not closed and was excluded from the created CurtainWall. This method only works with closed outlines which each represent one opening in the CurtainWall.");
                }
                else
                {
                    IConstruction construction = useConstructions ? constructions.ElementAt(i) : null;
                    Opening       opening      = Create.Opening(new List <ICurve> {
                        outline
                    }, headProperty, jambProperty, sillProperty, construction, name + "_" + i);
                    openings.Add(opening);
                }
            }

            List <IElement1D> externalEdges = Query.ExternalEdges(openings);

            foreach (Opening opening in openings)
            {
                foreach (FrameEdge edge in opening.Edges)
                {
                    if (edge.AdjacentElements(externalEdges).Count > 0)
                    {
                        string edgeType = edge.FrameEdgeType(opening);
                        switch (edgeType)
                        {
                        case "Head":
                            edge.FrameEdgeProperty = externalHeadProperty;
                            break;

                        case "Jamb":
                            edge.FrameEdgeProperty = externalJambProperty;
                            break;

                        case "Sill":
                            edge.FrameEdgeProperty = externalSillProperty;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }

            List <FrameEdge> extFrameEdges = externalEdges.OfType <ICurve>().Select(x => new FrameEdge {
                Curve = x
            }).ToList();

            return(new CurtainWall {
                ExternalEdges = extFrameEdges, Openings = openings, Name = name
            });
        }
Ejemplo n.º 9
0
        public static CurtainWall CurtainWall(IEnumerable <ICurve> outlines, IConstruction construction = null, FrameEdgeProperty frameEdgeProperty = null, string name = "")
        {
            if (outlines == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot create a CurtainWall from a null collection of outlines.");
                return(null);
            }

            List <Opening> openings = new List <Opening>();

            for (int i = 0; i < outlines.Count(); i++)
            {
                ICurve outline = outlines.ElementAt(i);
                if (outline.IIsClosed() != true)
                {
                    BH.Engine.Reflection.Compute.RecordError("Outline at index " + i + " was not closed and was excluded from the created CurtainWall. This method only works with closed outlines which each represent one opening in the CurtainWall.");
                }
                else
                {
                    Opening opening = Create.Opening(new List <ICurve> {
                        outline
                    }, construction, frameEdgeProperty, name + "_" + i);
                    openings.Add(opening);
                }
            }

            List <IElement1D> externalEdges = Query.ExternalEdges(openings);
            List <FrameEdge>  extFrameEdges = externalEdges.OfType <ICurve>().Select(x => new FrameEdge {
                Curve = x
            }).ToList();

            return(new CurtainWall {
                ExternalEdges = extFrameEdges, Openings = openings, Name = name
            });
        }