Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 16.0.0.0 (16.0.0.0)
Syntax
Remarks
BoundingBoxXYZ objects are used in Revit in several places related to views (for example, the section box of a 3D view or the definition of a section or detail view). BoundingBoxXYZ objects can also be obtained from elements representing the boundary of the element in a given view.
The extents of the box are determined by three orthogonal planes extended through the minimum ( Min ) and maximum ( Max ) points, but the coordinates of these points and the orientation of the planes in relation to the coordinates of the source model is determined by the box Transform ( Transform ).
This class also has the ability to detect and mark certain extents as disabled. Note that in the current Revit API uses of this class it is not expected that Revit will give objects with disabled extents, and disabled extents in objects sent to Revit will likely be ignored.
Examples

public void GetBoundingBoxXYZInfo(View3D view3D)
{
string message = "BoundingBoxXYZ : ";
message += "\nView name : " + view3D.Name;
BoundingBoxXYZ boundingBox = view3D.GetSectionBox();
// The section box of the 3D view can cut the model.
if (view3D.IsSectionBoxActive)
{
BoundingBoxXYZ sectionBox = view3D.GetSectionBox();
// Note that the section box can be rotated and transformed.
// So the min/max corners coordinates relative to the model must be computed via the transform.
Transform trf = sectionBox.Transform;
XYZ max = sectionBox.Max; //Maximum coordinates (upper-right-front corner of the box before transform is applied).
XYZ min = sectionBox.Min; //Minimum coordinates (lower-left-rear corner of the box before transform is applied).
// Transform the min and max to model coordinates
XYZ maxInModelCoords = trf.OfPoint(max);
XYZ minInModelCoords = trf.OfPoint(min);
message += "\nView has an active section box: ";
message += "\n'Maximum' coordinates: " + maxInModelCoords;
message += "\n'Minimum' coordinates: " + minInModelCoords;
}
TaskDialog.Show("Revit", message);
}

Dim doc As Document = uiApplication.ActiveUIDocument.Document
Dim view3D As View3D = Nothing
Dim collector As New FilteredElementCollector(doc)
Dim collection As ICollection(Of Element) = collector.OfClass(GetType(View3D)).ToElements()
For Each element As Element In collection
view3D = TryCast(element, View3D)
If view3D IsNot Nothing Then
Dim messageInfo As String = "BoundingBoxXYZ : "
messageInfo += vbLf & "View name : " + view3D.Name
Dim boundingBox As BoundingBoxXYZ = view3D.GetSectionBox()
If Not boundingBox.Enabled Then
boundingBox.Enabled = True
End If
If boundingBox.Enabled Then
' Get max boundingbox
Dim max As XYZ = boundingBox.Max
messageInfo += ((vbLf & "Max boundingbox : (" + max.X & ",") + max.Y & ",") + max.Z & ")"
' Get min boundingbox
Dim min As XYZ = boundingBox.Min
messageInfo += ((vbLf & "Min boundingbox : (" + min.X & ",") + min.Y & ",") + min.Z & ")"
' Get if max boundingbox enabled,
' use 0 for X, 1 for Y and 2 for Z
Dim bMaxEnabledX As Boolean = boundingBox.MaxEnabled(0)
' Get if min boundingbox enabled,
' use 0 for X, 1 for Y and 2 for Z
Dim bMinEnabledX As Boolean = boundingBox.MinEnabled(0)
' Get if bound boundingbox enabled
' For bound, use 0 for Min and 1 for Max.
' For dimension, use 0 for X, 1 for Y and 2 for Z
Dim bBoundEnabled As Boolean = boundingBox.BoundEnabled(0, 0)
' Get minimum bound of boundingbox
Dim minBound As XYZ = boundingBox.Bounds(0)
' Get maximum bound of boundingbox
Dim maxBound As XYZ = boundingBox.Bounds(1)
End If
TaskDialog.Show("Revit", messageInfo)
End If
Next