Message 1 of 2
Select multiple parts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
#################### 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