Returns a new detail ViewSection.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since: 2013
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Parameters
- document
- Type: Autodesk.Revit.DB Document
The document to which the new detail ViewSection will be added.
- viewFamilyTypeId
- Type: Autodesk.Revit.DB ElementId
The id of the ViewFamilyType which will be used by the new detail ViewSection. The type needs to be a Detail ViewFamily.
- sectionBox
- Type: Autodesk.Revit.DB BoundingBoxXYZ
The BoundingBoxXYZ which specifies the new ViewSection's view direction and extents.
Return Value
The new detail ViewSection.Remarks
Create a detail ViewSection whose view volume corresponds geometrically with the specified sectionBox. The view direction of the resulting section will be sectionBox.Transform.BasisZ and the up direction will be sectionBox.Transform.BasisY. The right hand direction will be computed so that (right, up, view direction) form a left handed coordinate system. The resulting view will be cropped, and far clipping will be active. The crop region will correspond to the projections of BoundingBoxXYZ.Min and BoundingBoxXYZ.Max onto the view's cut plane. The far clip distance will be equal to the difference of the z-coordinates of BoundingBoxXYZ.Min and BoundingBoxXYZ.Max. The new detail ViewSection will receive a unique view name.
Examples

// Get a BoundingBoxXYZ instance from Revit
BoundingBoxXYZ box = document.ActiveView.CropBox;
if (null == box)
{
throw new Exception("No BoundingBoxXYZ instance found.");
}
// Create a new view section.
ElementId DetailViewId = ElementId.InvalidElementId;
IList<Element> elems = new FilteredElementCollector(document).OfClass(typeof(ViewFamilyType)).ToElements();
foreach (Element e in elems)
{
ViewFamilyType v = e as ViewFamilyType;
if (v != null && v.ViewFamily == ViewFamily.Detail)
{
DetailViewId = e.Id;
break;
}
}
ViewSection viewSection = ViewSection.CreateDetail(document, DetailViewId, box);

' Get a BoundingBoxXYZ instance from Revit
Dim box As BoundingBoxXYZ = document.ActiveView.CropBox
If box Is Nothing Then
Throw New Exception("No BoundingBoxXYZ instance found.")
End If
' Create a new view section.
Dim DetailViewId As ElementId = ElementId.InvalidElementId
Dim elems As IList(Of Element) = New FilteredElementCollector(document).OfClass(GetType(ViewFamilyType)).ToElements()
For Each e As Element In elems
Dim v As ViewFamilyType = TryCast(e, ViewFamilyType)
If v IsNot Nothing AndAlso v.ViewFamily = ViewFamily.Detail Then
DetailViewId = e.Id
Exit For
End If
Next
Dim viewSection__1 As ViewSection = ViewSection.CreateDetail(document, DetailViewId, box)
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.Exceptions ArgumentException | The ViewFamilyType must be a Detail ViewFamily. -or- The BoundingBoxXYZ is not appropriate for detail views. The basis vectors of must be unit length and orthonormal. The near and far bound offsets cannot be reversed or too close to each other. MinEnabled and MaxEnabled must be set to true for all three directions. -or- Detail section view creation is not allowed in this family. |
Autodesk.Revit.Exceptions ArgumentNullException | A non-optional argument was NULL |
Autodesk.Revit.Exceptions ModificationForbiddenException | The document is in failure mode: an operation has failed, and Revit requires the user to either cancel the operation or fix the problem (usually by deleting certain elements). -or- The document is being loaded, or is in the midst of another sensitive process. |
Autodesk.Revit.Exceptions ModificationOutsideTransactionException | The document has no open transaction. |