Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion Revit_Core_Engine/Query/ViewBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ public static BoundingBoxXYZ ViewBoxElevation(this IEnumerable<Element> elements

/***************************************************/

[Description("Returns the combined bounding box containing given Revit solids, aligned with the right given direction, inflated by a given offset.")]
[Input("solids", "Solids to find the elevation box for.")]
[Input("direction", "Direction, along which the elevation is meant to be made.")]
[Input("sideOffset", "Offset value to inflate the elevation view in width and height, in metres.")]
[Input("frontOffset", "Offset distance between the solid front and the origin of the view, in metres. Use negative value to create section.")]
[Input("backOffset", "Offset distance between the solid back and the back edge of the view, in metres.")]
[Output("box", "Elevation box of the input Revit solids.")]
public static BoundingBoxXYZ ViewBoxElevation(this IEnumerable<Solid> solids, XYZ direction, double sideOffset, double frontOffset, double backOffset)
{
return solids.ViewBoxSection(direction, XYZ.BasisZ, sideOffset, frontOffset, backOffset);
}

/***************************************************/

[Description("Returns the bounding box containing a given Revit element, aligned with the given right direction, inflated by a given offset.")]
[Input("element", "Element to find the elevation box for.")]
[Input("direction", "Direction, along which the elevation is meant to be made.")]
Expand Down Expand Up @@ -80,6 +94,33 @@ public static BoundingBoxXYZ ViewBoxSection(this IEnumerable<Element> elements,
return null;
}

Options options = new Options();
options.DetailLevel = Autodesk.Revit.DB.ViewDetailLevel.Fine;
options.ComputeReferences = false;
options.IncludeNonVisibleObjects = false;

IEnumerable<Solid> solids = elements?.SelectMany(x => x.Solids(options));
return solids.ViewBoxSection(rightDirection, upDirection, sideOffset, frontOffset, backOffset);
}

/***************************************************/

[Description("Returns the combined bounding box containing given Revit solids, aligned with the given right and up direction, inflated by a given offset.")]
[Input("solids", "Solids to find the elevation box for.")]
[Input("rightDirection", "Direction, along which the elevation is meant to be made.")]
[Input("upDirection", "Direction pointing up in the created section. Needs to be perpendicular to upDirection.")]
[Input("sideOffset", "Offset value to inflate the elevation view in width and height, in metres.")]
[Input("frontOffset", "Offset distance between the solid front and the origin of the view, in metres. Use negative value to create section.")]
[Input("backOffset", "Offset distance between the solid back and the back edge of the view, in metres.")]
[Output("box", "Elevation box of the input Revit solids.")]
public static BoundingBoxXYZ ViewBoxSection(this IEnumerable<Solid> solids, XYZ rightDirection, XYZ upDirection, double sideOffset, double frontOffset, double backOffset)
{
if (solids == null || !solids.Any())
{
BH.Engine.Base.Compute.RecordError("Could create view box for null Revit solids.");
return null;
}

if (upDirection == null || rightDirection == null)
{
BH.Engine.Base.Compute.RecordError("Could create view box with null direction.");
Expand Down Expand Up @@ -108,7 +149,7 @@ public static BoundingBoxXYZ ViewBoxSection(this IEnumerable<Element> elements,
Transform transform = orientationMatrix.ToRevit().TryFixIfNonConformal();

// Bounds of the element in the provided coordinate system
BoundingBoxXYZ boundingBox = elements.PhysicalBounds(transform.Inverse);
BoundingBoxXYZ boundingBox = solids.Bounds(transform.Inverse);
boundingBox.Transform = transform;

// Front offset and depth
Expand Down