You can't use select events to just get a point. SelectEvents are used to
select an entity. You can get the point where the entity was selected. In
your case, the user won't be selecting anything but just clicking somewhere
on the sheet to define the location of the symbol. For this you can use
MouseEvents. They're similar to SelectEvents but instead of supporting
selection they just support watching for any mouse actions. I've modified
the code you sent to do this.
======== Sample illustrating the use of the class below. ============
Public Sub PointTest()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
' Declare a variable and create a new instance of the select class.
Dim oGetPoint As New clsGetPoint
' Call the Pick method of the clsSelect object and set
' the filter to pick any face.
Dim oPoint As Point2d
Set oPoint = oGetPoint.GetPoint
' Check to make sure a point was defined.
If Not oPoint Is Nothing Then
' Place the symbol.
Dim oSymbol As SketchedSymbol
Set oSymbol = oDoc.ActiveSheet.SketchedSymbols.Add( _
oDoc.SketchedSymbolDefinitions.Item(1), oPoint)
End If
End Sub
======== The new class for handling mouse events. ============
' Declare the event objects
Private WithEvents oInteraction As InteractionEvents
Private WithEvents oMouseEvents As MouseEvents
' Declare a flag that's used to determine when selection stops.
Private bStillSelecting As Boolean
Private oSelectedPoint As Point2d
Public Function GetPoint() As Point2d
' Initialize flag.
bStillSelecting = True
' Create an InteractionEvents object.
Set oInteraction =
ThisApplication.CommandManager.CreateInteractionEvents
' Set a reference to the mouse events.
Set oMouseEvents = oInteraction.MouseEvents
' Disable mouse move since we only need the click.
oMouseEvents.MouseMoveEnabled = False
' The InteractionEvents object.
oInteraction.Start
' Loop until a selection is made.
Do While bStillSelecting
DoEvents
Loop
' Set the return variable with the point.
Set GetPoint = oSelectedPoint
' Stop the InteractionEvents object.
oInteraction.Stop
' Clean up.
Set oMouseEvents = Nothing
Set oInteraction = Nothing
End Function
Private Sub oInteraction_OnTerminate()
' Set the flag to indicate we're done.
bStillSelecting = False
End Sub
Private Sub oMouseEvents_OnMouseClick(ByVal Button As MouseButtonEnum, _
ByVal ShiftKeys As ShiftStateEnum, _
ByVal ModelPosition As Point, _
ByVal ViewPosition As Point2d, _
ByVal View As View)
Set oSelectedPoint =
ThisApplication.TransientGeometry.CreatePoint2d(ModelPosition.X,
ModelPosition.Y)
bStillSelecting = False
End Sub
--
Brian Ekins
Autodesk Inventor API