Any way to check if Inventor session is being run non-interactively

Any way to check if Inventor session is being run non-interactively

Maxim-CADman77
Advisor Advisor
105 Views
3 Replies
Message 1 of 4

Any way to check if Inventor session is being run non-interactively

Maxim-CADman77
Advisor
Advisor

That's it:
I'd like to know if there any way to check if current Inventor session is runing non-interactively (ex. initiated by Task Scheduler)?

Dear, MjDeck, maybe you could clarify?

Context:
I'd like my Add-In not generate any messages (or even don't start at all) when Inventor is a part of TaskScheduler workflow.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
106 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor

You can try property: ThisApplication.Visible. It can work in common cases, but I don't test for example what happens when application is minimized and some event occurs.

0 Likes
Message 3 of 4

Maxim-CADman77
Advisor
Advisor

Seems like Inventor is normally not visible at the moment of Add-In initialization (except when Add-In is manually loaded to already running Inventor).

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 4 of 4

Michael.Navara
Advisor
Advisor
  • You need to check Visible property directly before you display the message. Also you can check property SilentOperation.
  • Usually I use PromptMessage instead of MessageBox because it respects the SilentOperation automatically.

 

  • Show any blocking UI during AddIn start is not good idea. If you want to inform user about anything when the AddIn starts, wait, until the application fully starts. Event OnReady and property Ready is good to determine if you want to display message directly or wait.

Incomplete sample of members mentioned above:

   Class MyAddInServer
       Implements ApplicationAddInServer

       Private _applicationEvents As ApplicationEvents
       Public Property ThisApplication As Inventor.Application
       Private ActivateMessage As String

       Public Sub Activate(addInSiteObject As ApplicationAddInSite, firstTime As Boolean) Implements ApplicationAddInServer.Activate
           ThisApplication = addInSiteObject.Application
           _applicationEvents = ThisApplication.ApplicationEvents

           ActivateMessage = "Something you want to display to the user"
           If ThisApplication.Ready Then
               ShowMessage()
           Else
               AddHandler _applicationEvents.OnReady, AddressOf ApplicationEvents_OnReady
           End If
       End Sub

       Private Sub ApplicationEvents_OnReady(beforeOrAfter As EventTimingEnum, context As NameValueMap, <Out> ByRef handlingCode As HandlingCodeEnum)

           handlingCode = HandlingCodeEnum.kEventNotHandled

           'Run event handler just once
           RemoveHandler _applicationEvents.OnReady, AddressOf ApplicationEvents_OnReady

           ShowMessage()

       End Sub

       Private Sub ShowMessage()
           'Use PromptMessage instead of MessageBox
           ThisApplication.CommandManager.PromptMessage(ActivateMessage, 0)
       End Sub

 

0 Likes