Select multiple parts

Select multiple parts

matt_jlt
Collaborator Collaborator
765 Views
1 Reply
Message 1 of 2

Select multiple parts

matt_jlt
Collaborator
Collaborator
I am using the clsSelect class module and was wondering how to change it so the user can hold [Ctrl] and be able to select multiple part occurences in an assembly file (parts only)

#################### I have the following code in a Module:

Public Sub MultipleSelect()

' Declare a variable and create a new instance of the select class.
Dim oSelect As New clsMultiSelect

' Call the Pick method of the clsSelect object and set
' the filter to pick any face.
Dim oView As PartDocument
Set oView = oSelect.Pick(kAssemblyOccurrenceFilter)

' Check to make sure a face was selected.
If Not oView Is Nothing Then
MsgBox "oView is Nothing", , "Report 1"
End If
MsgBox "oView is Something", , "Report 1"
Exit Sub
End Sub

#################### the following is in a class file called clsMultiSelect:
' 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(filter As SelectionFilterEnum) As Object
' Initialize flag.
bStillSelecting = True

' Create an InteractionEvents object.
Set oInteraction = ThisApplication.CommandManager.CreateInteractionEvents

' Define that we want select events rather than mouse events.
oInteraction.SelectionActive = True

' Set a reference to the select events.
Set oSelect = oInteraction.SelectEvents

' Set the filter using the value passed in.
oSelect.AddSelectionFilter filter

' The InteractionEvents object.
oInteraction.SelectEvents.SingleSelectEnabled = False
oInteraction.Start

' Loop until a selection is made.
Do While bStillSelecting
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 = oSelect.SelectedEntities
' The below if statement should be disabled
If oSelectedEnts.count > 0 Then
Set Pick = oSelectedEnts.Item(1)
Else
Set Pick = Nothing
End If

' Stop the InteractionEvents object.
oInteraction.Stop

' Clean up.
Set oSelect = Nothing
Set oInteraction = Nothing
End Function


Private Sub oInteraction_OnTerminate()
' Set the flag to indicate we're done.
bStillSelecting = False
End Sub


Private Sub oSelect_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

Can anyone help me?, cheers
0 Likes
766 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
The clsSelect class was written to try and provide a simple wrapper to do
single selections. If you want to do more than this you should probably use
the InteractionEvents object directly instead of clsSelect. This will give
you the behavior you want. In fact the default behavior when using
InterationEvents to do selection is to allow the user to select multiple
objects. You'll need some way for the user to indicate that they're done so
you can continue with whatever processing needs to be done using the
selection. Most of Invnetor's commands behave like this. For example, when
running the Fillet command you can select many edges and then processing
occurrs when you pick the OK or Apply button.
--
Brian Ekins
Autodesk Inventor API
0 Likes