Open Select Projects Dialog Box after Add-ins Loaded

ngnam1988
Advocate
Advocate

Open Select Projects Dialog Box after Add-ins Loaded

ngnam1988
Advocate
Advocate

Dears,

I'm working with our client's add-ins. They're set active a project after Inventor started and Add-ins loaded. Please help me the VB.NET Code that can open select project dialog box after everything loaded (Or set my project active after everything loaded). I'm coding in VS.

Thank you very much!

0 Likes
Reply
356 Views
5 Replies
Replies (5)

JelteDeJong
Mentor
Mentor

You can use the ApplicationEvents.OnReady(..) event. The OnReady event notifies your addin when Inventor has completely initialized and is ready for interactive use.

In the event handler, you can set the project file. Your addin class would look something like this:

Public Class StandardAddInServer
    Implements Inventor.ApplicationAddInServer

    Private _appEvents As ApplicationEvents
    Private _inventor As Inventor.Application
    Private _designProjectName As String = "ProjectName"

    Public Sub Activate(AddInSiteObject As ApplicationAddInSite, FirstTime As Boolean) Implements ApplicationAddInServer.Activate
        _inventor = AddInSiteObject.Application
        _appEvents = _inventor.ApplicationEvents

        AddHandler _appEvents.OnReady, AddressOf AppEvents_OnReady
    End Sub

    Private Sub AppEvents_OnReady(BeforeOrAfter As EventTimingEnum, Context As NameValueMap, ByRef HandlingCode As HandlingCodeEnum)
        Dim designProjects = _inventor.DesignProjectManager.DesignProjects
        designProjects.ItemByName(_designProjectName).Activate()
    End Sub

 

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

ngnam1988
Advocate
Advocate

Thanks @JelteDeJong 
Your code take the very good result - But when we active the client's addin the project reactive to client's project.
I mean we're using 2 Addins (one of our client, one of ourself)  - The client's addin always active their project after Inventor started (That I can't change because we haven't source code). I wanna change project after everything loaded (auto open project dialog or auto active our project). Could you please help me. Thanks!

0 Likes

jjstr8
Collaborator
Collaborator

@ngnam1988 :  If you have no use for the client's addin project file, I would just overwrite it with your preferred project file.

0 Likes

ngnam1988
Advocate
Advocate

Hi @jjstr8 

Actually I don't need the client's default project for working. But with out it, the client's add-in can't load so that why I only need the dialog project box prompt after everything loaded, so we'll active our project for current job. Could you share your code, so I can try it. Thanks

0 Likes

jjstr8
Collaborator
Collaborator
There's no code. It seemed like you're only using one project file. If so, save it under the client's add-in project file name. When the client's add-in loads that project file, it will actually have your project file settings. I'm not sure of any options if you're using multiple project files and the client's add-in does not load automatically on startup.
0 Likes