A project model can have several view types. In the API, there are three ways to classify views. The first way is by using the view element View.ViewType property. It returns an enumerated value indicating the view type. The following table lists all available view types.
Table 44: Autodesk.Revit.DB.ViewType
Member Name |
Description |
AreaPlan |
Area view. |
CeilingPlan |
Reflected ceiling plan view. |
ColumnSchedule |
Coulmn schedule view. |
CostReport |
Cost report view. |
Detail |
Detail view. |
DraftingView |
Drafting view. |
DrawingSheet |
Drawing sheet view. |
Elevation |
Elevation view. |
EngineeringPlan |
Engineering view. |
FloorPlan |
Floor plan view. |
Internal |
Revit's internal view. |
Legend |
Legend view. |
LoadsReport |
Loads report view. |
PanelSchedule |
Panel schedule view. |
PressureLossReport |
Pressure Loss Report view. |
Rendering |
Rendering view. |
Report |
Report view. |
Schedule |
Schedule view. |
Section |
Cross section view. |
ThreeD |
3-D view. |
Undefined |
Undefined/unspecified view. |
Walkthrough |
Walkthrough view. |
The second way to classify views is by the class type.
The following table lists the view types and the corresponding views in the Project browser.
Table 45: Project Browser Views
Project Browser Views |
View Type |
Class Type |
Area Plans |
ViewType.AreaPlan |
Elements.ViewPlan |
Ceiling Plans |
ViewType.CeilingPlan |
Elements.ViewPlan |
Graphic Column Schedule |
ViewType.ColumnSchedule |
Elements.View |
Detail Views |
ViewType.Detail |
Elements.ViewSection |
Drafting Views |
ViewType.DraftingView |
Elements.ViewDrafting |
Sheets |
ViewType.DrawingSheet |
Elements.ViewSheet |
Elevations |
ViewType.Elevation |
Elements.ViewSection |
Structural Plans |
ViewType.EngineeringPlan |
Elements.ViewPlan |
Floor Plans |
ViewType.FloorPlan |
Elements.ViewPlan |
Legends |
ViewType.Legend |
Elements.View |
Reports (MEP engineering) |
ViewType.LoadsReport |
Elements.View |
Reports (MEP engineering) |
ViewType.PanelSchedule |
Elements.PanelScheduleView |
Reports (MEP engineering) |
ViewType.PresureLossReport |
Elements.View |
Renderings |
ViewType.Rendering |
Elements.ViewDrafting |
Reports |
ViewType.Report |
Elements.View |
Schedules/Quantities |
ViewType.Schedule |
Elements.ViewSchedule |
Sections |
ViewType.Section |
Elements.ViewSection |
3D Views |
ViewType.ThreeD |
Elements.View3D |
Walkthroughs |
ViewType.Walkthrough |
Elements.View3D |
Code Region: Determining the View type |
public void GetViewType(Autodesk.Revit.DB.View view) { // Get the view type of the given view, and format the prompt string String prompt = "The view is "; switch (view.ViewType) { case ViewType.AreaPlan: prompt += "an area view."; break; case ViewType.CeilingPlan: prompt += "a reflected ceiling plan view."; break; case ViewType.ColumnSchedule: prompt += "a column schedule view."; break; case ViewType.CostReport: prompt += "a cost report view."; break; case ViewType.Detail: prompt += "a detail view."; break; case ViewType.DraftingView: prompt += "a drafting view."; break; case ViewType.DrawingSheet: prompt += "a drawing sheet view."; break; case ViewType.Elevation: prompt += "an elevation view."; break; case ViewType.EngineeringPlan: prompt += "an engineering view."; break; case ViewType.FloorPlan: prompt += "a floor plan view."; break; // ... default: break; } // Give the user some information MessageBox.Show(prompt, "Revit", MessageBoxButtons.OK); } |
The third way to classify views is using the ViewFamilyType class. Most view creation methods required the Id of a ViewFamilyType for the new view. The Id of the ViewFamilyType can be retrieved from the View.GetTypeId() method. The ViewFamilyType.ViewFamily property returns a ViewFamily enumeration which specifies the family of the ViewFamilyType and similar to the ViewType enum documented above. The following example shows how to get the ViewFamily from a View.
Code Region: Determining view type from ViewFamilyType |
public ViewFamily GetViewFamily(Document doc, View view) { ViewFamily viewFamily = ViewFamily.Invalid; ElementId viewTypeId = view.GetTypeId(); if (viewTypeId.IntegerValue > 1) // some views may not have a ViewFamilyType { ViewFamilyType viewFamilyType = doc.GetElement(viewTypeId) as ViewFamilyType; viewFamily = viewFamilyType.ViewFamily; } return viewFamily; } |