Speed increases when moving mouse over inventor window

Speed increases when moving mouse over inventor window

JelteDeJong
Mentor Mentor
603 Views
5 Replies
Message 1 of 6

Speed increases when moving mouse over inventor window

JelteDeJong
Mentor
Mentor

I was looping over all ControlDefinition when i noticed something strange. If i move over the inventor window then my program becomes much faster. I did notice this before (on a addon that i maintain) but was never able to prove it. But now i could with the code below. (Its a class of a program that i use to write/test ilogic rules. For people who want to try it the complete program it can be found on github. )

 

Public Class ThisRule
    Sub Main()
        Dim doc As PartDocument = ThisDoc.Document
        Dim sw As Stopwatch = New Stopwatch()
        Dim list As List(Of Integer) = New List(Of Integer)()
        Dim i = 0
        For Each def As ControlDefinition In ThisApplication.CommandManager.ControlDefinitions

            i = i + 1
            list.Add(sw.ElapsedMilliseconds)
            If i = 25 Then

                Dim ave = list.Average()
                Console.SetCursorPosition(1, 1)
                Console.WriteLine(ave)
                list.Clear()
                i = 0
            End If
            sw.Restart()
        Next

    End Sub
end Class

 

 

i found for 25 iterations my computer needs on avarage:

  • 180 to 190 miliseconds when my mouse is not moving or not on the Inventor window.
  • 10 to 15 miliseconds when my mouse is moving over the inventor window.

That is a huge difference.

 

Did someone else notice this behaviour?

Is this a bug?

Can we exploit this to speed up long runing tasks. (like configurators)?

 

 

 

 

Jelte de Jong
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


Blog: hjalte.nl - github.com

0 Likes
604 Views
5 Replies
Replies (5)
Message 2 of 6

JhoelForshav
Mentor
Mentor

Hi @JelteDeJong 

This is a known behavior... see @BrianEkins response in this thred:

https://forums.autodesk.com/t5/inventor-customization/why-execution-is-faster-when-mouse-moving-on-s...

 

"This is a known behavior and is common with among all programs that support a COM API interface. What's happening is that Inventor has a single main thread that is handling all interaction with Inventor. This includes using the UI and also external API calls. Inventor is watching the UI and also watching for API calls to come in from the single thread. This is one of the biggest reasons that running an out-of-process program is much slower than running in-process. For some reason moving the mouse causes Inventor to more frequently handle the incoming API calls.

 

The solution to this is to use the Application.UserInterfaceManager.UserInteractionDisabled property. This blocks all interaction with the UI and allows Inventor to focus on the incoming API calls. You'll need to set it to True at the beginning and then back to False at the end so you can interact with Inventor after the program has finished running."

 

Message 3 of 6

JelteDeJong
Mentor
Mentor

Thanks for the response. I did not see that post form @BrianEkins . That explains why i see this on my test utility. It runs out of process. The strange thing is that i have seen this behaviour also in a addon that should be runing in process. Should I come to the conclusion that the addon is not running in process for some reason?

 

Jelte de Jong
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


Blog: hjalte.nl - github.com

0 Likes
Message 4 of 6

JhoelForshav
Mentor
Mentor

@JelteDeJong 

In this addin that is meant to run in process, are you always using the AddinSiteObject.Application as the Inventor.Application Object? I mean, if you've created a form for your addin, - does that form use that application object or do you obtain the application object like GetObject( , "Inventor.Application") or similar?

I believe if you always make sure to use the AddinSiteObject everything will be ran in process 🙂

0 Likes
Message 5 of 6

BrianEkins
Mentor
Mentor

I don't know of any cases where an add-in would be impacted by this. If you have one it would be interesting to see.

 

Something that I frequently do when I'm running an EXE is instead of moving the mouse around to speed things up I move into the inventor window and right-click to show the context menu.  This has the same effect and is much easier.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 6 of 6

JelteDeJong
Mentor
Mentor

Im still trying to figure this out. i searched the complete solution for the text "Inventor.Application". I did find it in the text but they where there as a fail save for the times we will run this code in purpose out of process. (for debuging we often start the addin as a executable) i cant explain that the addon look to run out of process...

 

Is there a way to test/check if the Inventor.Application object is running "In process" or "Out of process"?

Jelte de Jong
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


Blog: hjalte.nl - github.com

0 Likes