AutoCAD VBA uses a View object to represent a view. When you create a new drawing, no views are set up. All the views that you save in a drawing become members of the Views collection. The following code iterates through the Views collection and displays the names of saved views.
Public Sub DisplayViews() Dim objView As AcadView Dim strViewNames As String
If ThisDrawing.Views.Count > 0 Then
For Each objView In ThisDrawing.Views strViewNames = strViewNames & objView.Name
MsgBox "The following views are saved for this & strViewNames
MsgBox "There are no saved View objects in the End If
& vbCrLf drawing:" & vbCrLf Views collection."
Figure 14-1 shows this code's output. This is equivalent to the views displayed in the View dialog box's Named Views tab (see Figure 14-2).
The view named Current is not saved and is not part of the Views collection. Also, the Views collection is not imported into other drawings when you insert one drawing into another.
Was this article helpful?