UserInterfaceManager.DoEvents

UserInterfaceManager.DoEvents

Anonymous
Not applicable
1,792 Views
4 Replies
Message 1 of 5

UserInterfaceManager.DoEvents

Anonymous
Not applicable

I am trying to adapt a VBA routine to run in 64bit Inventor and accirding to Sanjay all DoEvents have to be replaced with "UserInterfaceManager.DoEvents" but this comes up with a variable not defined error. Am I missing an include?

 

All other posts refering to UserInterfaceManager.DoEvents are for .NET.

 

Below is the code where the problem is occouring.


Public Function Initialize() As Object
   
    ' Initialize flag.
    bStillSelecting = True

    ' Create a new InteractionEvents object.
    Set oInteraction = ThisApplication.CommandManager.CreateInteractionEvents
   
    ' Set the prompt.
    oInteraction.StatusBarText = "Select a dimension."
   
    ' Connect to the associated select events.
    Set oSelect = oInteraction.SelectEvents
   
    ' Enable single selection.
    oSelect.SingleSelectEnabled = True

    ' Start the selection process.
    oInteraction.Start
   
    ' Loop until a selection is made.
    Do While bStillSelecting
        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 ObjectsEnumerator
    Set oSelectedEnts = oSelect.SelectedEntities
   
    If oSelectedEnts.Count > 0 Then
        Set Initialize = oSelectedEnts.Item(1)
    Else
        Set Initialize = Nothing
    End If
   
    ' Stop the InteractionEvents object.
    oInteraction.Stop
   
    ' Clean up.
    Set oSelect = Nothing
    Set oInteraction = Nothing
End Function

0 Likes
1,793 Views
4 Replies
Replies (4)
Message 2 of 5

YuhanZhang
Autodesk
Autodesk

You can get the UserInterfaceManager through ThisApplication as below:

 

 

 

' Loop until a selection is made.
Do While bStillSelecting
ThisApplication.UserInterfaceManager.DoEvents
Loop

 

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 5

Anonymous
Not applicable

It would appear that this does not work in 64bit Inventor using dotNET.  Has anyone had success with this in 64bit dotNET?

 

What I see is that there is no response from the inventor user inteface once we enter the loop, which would indicate that userInterfaceManager.DoEvents is not releasing processing in the 64bit 2011 Inventor?

        ' Loop until a selection is made.
        Do While bStillSelecting
            InventorApplication.UserInterfaceManager.DoEvents()
        Loop

 

BTW, commandManager.Pick exibits the same behavior in 64bit:

oSketch = DirectCast(InventorApplication.CommandManager.Pick(SelectionFilterEnum.kSketchObjectFilter, "Note"), DrawingSketch)

 

Instead, it needs to be split into two parts, one to initiate the process:

    Public Sub SelectDotNET(ByVal filter As SelectionFilterEnum)

        ' Initialize flag.
        bStillSelecting = True
        ' Create an InteractionEvents object.
        oInteractEvents = InventorApplication.CommandManager.CreateInteractionEvents

        ' Ensure interaction is enabled.
        oInteractEvents.InteractionDisabled = False
        ' Set a reference to the select events.
        oSelect = oInteractEvents.SelectEvents
        ' Set the filter using the value passed in.
        oSelect.AddSelectionFilter(filter)

        ' Start the InteractionEvents object.
        oInteractEvents.Start()

    End Sub

And then an event needs to be raised back to the caller

    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) Handles oSelect.OnSelect
        ' Get the selected item. If more than one thing was selected,
        ' just get the first item and ignore the rest.
        If JustSelectedEntities.Count > 0 Then
            _SelectedObject = JustSelectedEntities.Item(1)
        Else
            _SelectedObject = Nothing
        End If

        oInteractEvents.SetCursor(CursorTypeEnum.kCursorTypeDefault)
        ' Stop the InteractionEvents object.
        oInteractEvents.Stop()

        ' Clean up.
        oSelectEvents = Nothing
        oInteractEvents = Nothing

        RaiseEvent LocatedIT()
    End Sub
    Public Event LocatedIT()

0 Likes
Message 4 of 5

scottmoyse
Mentor
Mentor

thanks for posting this, for some reason i wasn't e-mailed about your post even though i am subscribed to this. I will forward this onto our programmer.

 

cheers

 

Scott


Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


RevOps Strategy Manager at Toolpath. New Zealand based.

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

0 Likes
Message 5 of 5

scottmoyse
Mentor
Mentor

by the way it does seem to work, but it is very very very slow and sometimes it just won't work. so far from ideal.


Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


RevOps Strategy Manager at Toolpath. New Zealand based.

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

0 Likes