- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Basically i have some code that gets the parts list on a drawing sheet and if there is more than one allows you to manually select which to use.
It is a sub that calls up a selection class and defines the filter to be used. My problem is that once the selection event for multiple partlsists has been initialised i cannot select the parts lists. I'm not sure if it's the selection filter or the still selecting do events loop.
I have tried using the other doevents methods but it doesn't seem to work.
The code is below, If anyone could help it would be much appreciated. I have have left this problem unsolved for a long time and am finally getting to finish my addins.
Private Sub Total_Mass
' Define variables
Dim oDoc As Inventor.DrawingDocument
Dim oSheet As Inventor.Sheet
Dim oPListColl As Inventor.PartsLists
Dim oPList As Inventor.PartsList
Dim oPListCount As Integer
' Set references to variables
oDoc = ThisApplication.ActiveDocument
oSheet = oDoc.ActiveSheet
oPListColl = oDoc.ActiveSheet.PartsLists
' Reset Values
oPListCount = 0
oPList = Nothing
Select Case oPListColl.Count
Case 0
MsgBox("There are no parts lists on the active sheet", MsgBoxStyle.Exclamation)
Me.Close
Case 1
oPList = oDoc.ActiveSheet.PartsLists.Item(1)
GoTo PListSelected
Case Is > 1
GoTo MSelectPList
End Select
MSelectPList: ' Manual Parts List Selection Process
' Declare a variable and create a new instance of the select class.
Dim oSelect As New clsSelect
' Call the Pick method of clsSelect object and set filter to pick any parts list.
oPList = oSelect.Pick(SelectionFilterEnum.kDrawingPartsList Filter) ' **************** Not Sure if the filter is not working properly
MsgBox("Parts List Title = " & oPList.Title, MsgBoxStyle.Information)
End Sub
Public Class clsSelect
' Declare the event objects
Private WithEvents oInteraction As Inventor.InteractionEvents
Private WithEvents oSelect As Inventor.SelectEvents
' Declare a flag that's used to determine when selection stops.
Private bStillSelecting As Boolean
Public Function Pick(ByVal filter As Inventor.SelectionFilterEnum) As Object ' dont know if filter definition is correct
' Initialize flag.
bStillSelecting = True
' Create an InteractionEvents object.
oInteraction = ThisApplication.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 ' *********************************** It gets stuck in this loop
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 Inventor.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
Private Sub oInteraction_OnTerminate()
' Set the flag to indicate we're done.
bStillSelecting = False
End Sub
Private Sub oSelect_OnSelect(ByVal JustSelectedEntities As Inventor.ObjectsEnumerator, _
ByVal SelectionDevice As Inventor.SelectionDeviceEnum, _
ByVal ModelPosition As Inventor.Point, _
ByVal ViewPosition As Inventor.Point2d, _
ByVal View As Inventor.View)
' Set the flag to indicate we're done.
bStillSelecting = False
End Sub
End Class
Solved! Go to Solution.