Message 1 of 11

Not applicable
06-28-2007
06:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
IV 2008, VS 2005
I am converting over my VBA to add-ins. Still quite new to VB.net and having problem with pausing for user selection. The following is based on an example from help. The DoEvents does not work like this in net and I can not seem to get anything else to work for the pause. Also seems that DoEvents is not suggested in net anyway.
So what is the proper way to pause for input? An example would be best... Thanks
Public Class TestPick
' Declare the event objects
Private WithEvents oInteraction As InteractionEvents
Private WithEvents oSelect As SelectEvents
' Declare a flag that's used to determine when selection stops.
Private bStillSelecting As Boolean
Public Function Pick(ByVal filter As SelectionFilterEnum) As Object
' Initialize flag.
bStillSelecting = True
' Create an InteractionEvents object.
oInteraction = Button.InventorApplication.CommandManager.CreateInteractionEvents
' Define that we want select events rather than mouse events.
oInteraction.SelectionActive = True
' Set a reference to the select events.
oSelect = oInteraction.SelectEvents
' Set the filter using the value passed in.
oSelect.AddSelectionFilter(filter)
' The InteractionEvents object.
oInteraction.Start()
' Loop until a selection is made.
Do While bStillSelecting
DoEvents() '---------------------------problem
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
oSelectedEnts = oSelect.SelectedEntities
If oSelectedEnts.Count > 0 Then
Pick = oSelectedEnts.Item(1)
Else
Pick = Nothing
End If
' Stop the InteractionEvents object.
oInteraction.Stop()
' Clean up.
oSelect = Nothing
oInteraction = Nothing
End Function
End Class
I am converting over my VBA to add-ins. Still quite new to VB.net and having problem with pausing for user selection. The following is based on an example from help. The DoEvents does not work like this in net and I can not seem to get anything else to work for the pause. Also seems that DoEvents is not suggested in net anyway.
So what is the proper way to pause for input? An example would be best... Thanks
Public Class TestPick
' Declare the event objects
Private WithEvents oInteraction As InteractionEvents
Private WithEvents oSelect As SelectEvents
' Declare a flag that's used to determine when selection stops.
Private bStillSelecting As Boolean
Public Function Pick(ByVal filter As SelectionFilterEnum) As Object
' Initialize flag.
bStillSelecting = True
' Create an InteractionEvents object.
oInteraction = Button.InventorApplication.CommandManager.CreateInteractionEvents
' Define that we want select events rather than mouse events.
oInteraction.SelectionActive = True
' Set a reference to the select events.
oSelect = oInteraction.SelectEvents
' Set the filter using the value passed in.
oSelect.AddSelectionFilter(filter)
' The InteractionEvents object.
oInteraction.Start()
' Loop until a selection is made.
Do While bStillSelecting
DoEvents() '---------------------------problem
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
oSelectedEnts = oSelect.SelectedEntities
If oSelectedEnts.Count > 0 Then
Pick = oSelectedEnts.Item(1)
Else
Pick = Nothing
End If
' Stop the InteractionEvents object.
oInteraction.Stop()
' Clean up.
oSelect = Nothing
oInteraction = Nothing
End Function
End Class
Solved! Go to Solution.