diff --git a/Revit_Core_Engine/Query/Bounds.cs b/Revit_Core_Engine/Query/Bounds.cs index d9ab8ecd9..f79bc2fa2 100644 --- a/Revit_Core_Engine/Query/Bounds.cs +++ b/Revit_Core_Engine/Query/Bounds.cs @@ -36,10 +36,10 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("Returns the combined bounding box of a given colection of volumetric solids.")] + [Description("Returns the combined bounding box of a given collection of volumetric solids.")] [Input("solids", "A collection of solids to find the bounds for.")] [Input("transform", "Optional transform of the bounding box's coordinate system.")] - [Output("bounds", "Combined bounding box of the input colection of volumetric solids.")] + [Output("bounds", "Combined bounding box of the input collection of volumetric solids.")] public static BoundingBoxXYZ Bounds(this IEnumerable solids, Transform transform = null) { solids = solids?.Where(x => x != null && x.Volume > 1e-6).ToList(); @@ -81,6 +81,31 @@ public static BoundingBoxXYZ Bounds(this IEnumerable solids, Transform tr } /***************************************************/ + + [Description("Returns the combined outline of the given outlines.")] + [Input("outlines", "A list of outlines to combine.")] + [Output("bounds", "Combined outline of the given outlines.")] + public static Outline Bounds(this List outlines) + { + if (outlines == null || !outlines.Any()) + { + BH.Engine.Base.Compute.RecordError("Outline collection cannot be null or empty."); + return null; + } + + + Outline newOutline = new Outline(outlines[0]); + + foreach (Outline outline in outlines.Skip(1)) + { + newOutline.AddPoint(outline.MinimumPoint); + newOutline.AddPoint(outline.MaximumPoint); + } + + return newOutline; + } + + /***************************************************/ } } diff --git a/Revit_Core_Engine/Query/CenterPoint.cs b/Revit_Core_Engine/Query/CenterPoint.cs new file mode 100644 index 000000000..dcca66be0 --- /dev/null +++ b/Revit_Core_Engine/Query/CenterPoint.cs @@ -0,0 +1,46 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using BH.oM.Base.Attributes; +using System.ComponentModel; + +namespace BH.Revit.Engine.Core +{ + public static partial class Query + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + + [Description("Returns the center point of the outline.")] + [Input("outline", "Outline to get the center point from.")] + [Output("point", "Center point of the outline.")] + public static XYZ CenterPoint(this Outline outline) + { + return (outline.MinimumPoint + outline.MaximumPoint) / 2; + } + + /***************************************************/ + } +} +