ActiveView Property


The document's active view.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.484.0)

Syntax

C#
public View ActiveView { get; }
Visual Basic
Public ReadOnly Property ActiveView As View
	Get
Visual C++
public:
property View^ ActiveView {
	View^ get ();
}

Field Value

The active view is the view that last had focus in the UI. a null reference ( Nothing in Visual Basic) if no view is considered active.

Examples

Copy C#
// Get the active view of the current document.
Autodesk.Revit.DB.View view = document.ActiveView;

// Get the class type of the active view, and format the prompt string
String prompt = "Revit is currently in ";
if (view is Autodesk.Revit.DB.View3D)
{
    prompt += "3D view.";
}
else if (view is Autodesk.Revit.DB.ViewSection)
{
    prompt += "section view.";
}
else if (view is Autodesk.Revit.DB.ViewSheet)
{
    prompt += "sheet view.";
}
else if (view is Autodesk.Revit.DB.ViewDrafting)
{
    prompt += "drafting view.";
}
else
{
    prompt += "normal view, the view name is " + view.Name;
}

// Give the user some information
TaskDialog.Show("Revit",prompt);
Copy VB.NET
' Get the active view of the current document.
Dim view As Autodesk.Revit.DB.View = document.ActiveView

' Get the class type of the active view, and format the prompt string
Dim prompt As [String] = "Revit is currently in "
If TypeOf view Is Autodesk.Revit.DB.View3D Then
   prompt += "3D view."
ElseIf TypeOf view Is Autodesk.Revit.DB.ViewSection Then
   prompt += "section view."
ElseIf TypeOf view Is Autodesk.Revit.DB.ViewSheet Then
   prompt += "sheet view."
ElseIf TypeOf view Is Autodesk.Revit.DB.ViewDrafting Then
   prompt += "drafting view."
Else
   prompt += "normal view, the view name is " + view.Name
End If

' Give the user some information
TaskDialog.Show("Revit", prompt)

See Also