get addin to run in multiple instances of inventor

get addin to run in multiple instances of inventor

Anonymous
Not applicable
855 Views
3 Replies
Message 1 of 4

get addin to run in multiple instances of inventor

Anonymous
Not applicable

I've just converted a standalone application in to an inventor addin, I want to be able to run this addin in multiple instances of Inventor on the same computer. However when the app is running and I open the app in another instance, the original crashes and the new instance doesn't function correctly, I think the new instance of the app is refering to the original instance of Inventor and it might be somthing to do with the way i'm using the getactiveobject function. Should the below give we what I want? Or is there an alternative to getactiveobject.

 

        Try
            ' Attempt to get a reference to a running instance of Inventor
            InvApp = Marshal.GetActiveObject("Inventor.Application")


            Dim oDoc As AssemblyDocument = InvApp.ActiveEditDocument
        Catch
0 Likes
Accepted solutions (2)
856 Views
3 Replies
Replies (3)
Message 2 of 4

ruthsteed
Autodesk
Autodesk
Accepted solution
When your addin's Activate method is called, the first argument (IDispatch*) implements the interface ApplicationAddInSite. You can get the running Application object from there.


Ruth Steed
Inventor Development Team
Autodesk, Inc.

0 Likes
Message 3 of 4

Anonymous
Not applicable

Can i define this in another module and will it work in the same way or is it necessary to parse this through to the new module?

 

Currently trying and failing with this;

 

    Public Shared addInSiteObject As Inventor.ApplicationAddInSite

    Private Sub Export(sender As Object, e As EventArgs) Handles MyBase.Load

        System.Windows.Forms.Application.EnableVisualStyles()

        Try

            InvApp = addInSiteObject.Application

            Dim oDoc As AssemblyDocument = InvApp.ActiveEditDocument
        Catch
            MsgBox("64", 64, Title)
            Return
        End Try

...
0 Likes
Message 4 of 4

ruthsteed
Autodesk
Autodesk
Accepted solution
I'm not sure I understand the question. You should be able to hold on to the Application pointer and pass it between modules. I'm not sure how this would work with a public shared variable. Typically, you would use a public property on your Add-In object/main class and hold on to the Application as a private member on the class instance, but it should also work with a shared variable. Are you sure that the addInSiteObject has been set prior to the call to Export? In other words, is there a valid addInSitObject to get the Application from here?


Ruth Steed
Inventor Development Team
Autodesk, Inc.

0 Likes