Returns the specified Area Plan
'return the specified area plan
Public Function GetAreaPlanByName(levelName As String, curDoc As Document) As ViewPlan
'collect all viewplans in current model
Dim viewCollector As New FilteredElementCollector(curDoc)
viewCollector.OfCategory(BuiltInCategory.OST_Views)
viewCollector.OfClass(GetType(ViewPlan)).ToElements
'loop through collection
For Each curView As ViewPlan In viewCollector
If curView.IsTemplate = False Then
If curView.ViewType.ToString Like "AreaPlan" Then
If curView.Name = levelName Then
'return specified area plan
Return curView
Exit Function
End If
End If
End If
Next
Return Nothing
End Function