In a class module named Class1, insert :
'Permet de sélectionner une vue à l'écran en la cliquant
Option Explicit
Private WithEvents oInteractEvents As InteractionEvents
Private WithEvents oSelectEvents As SelectEvents
' Declare a flag that's used to determine when selection stops.
Private bStillSelecting As Boolean
Public Function Pick(filter As SelectionFilterEnum) As Object
' Initialize flag.
bStillSelecting = True
' Create an InteractionEvents object.
Set oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents
' Ensure interaction is enabled.
oInteractEvents.InteractionDisabled = False
' Set a reference to the select events.
Set oSelectEvents = oInteractEvents.SelectEvents
' Set the filter using the value passed in.
oSelectEvents.AddSelectionFilter filter
' Start the InteractionEvents object.
oInteractEvents.Start
' Loop until a selection is made.
Do While bStillSelecting
ThisApplication.UserInterfaceManager.DoEvents
Loop
' Get the selected item. If more than one thing was selected,
' just get the first item and ignore the rest.
Dim oSelectedEnts As ObjectsEnumerator
Set oSelectedEnts = oSelectEvents.SelectedEntities
If oSelectedEnts.Count > 0 Then
Set Pick = oSelectedEnts.Item(1)
Else
Set Pick = Nothing
End If
' Stop the InteractionEvents object.
oInteractEvents.Stop
' Clean up.
Set oSelectEvents = Nothing
Set oInteractEvents = Nothing
End Function
Private Sub oInteractEvents_OnTerminate()
' Set the flag to indicate we're done.
bStillSelecting = False
End Sub
Private Sub oSelectEvents_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View)
' Set the flag to indicate we're done.
bStillSelecting = False
End Sub
In a standard module, insert :
Sub SelectView()
Dim clsSelectView As Class1
Dim oSelectedView As DrawingView
Set clsSelectView = New Class1
Set oSelectedView = clsSelectView.Pick(kDrawingViewFilter)
MsgBox ("Selected view = " & oSelectedView.Name)
End Sub
Run SelectView, then switch on a drawing and click in a view : the name of the view is displayed.
This is just a way to get any drawing view property, just by selecting it.
For example, if you want to select the view whose scale is to be displayed in the title block, you can run this code to get the view scale, write it in a custom property, and use this custom property in the title block.
Hope this helps !