Multiple running instances of Inventor and the API

Multiple running instances of Inventor and the API

Anonymous
Not applicable
926 Views
3 Replies
Message 1 of 4

Multiple running instances of Inventor and the API

Anonymous
Not applicable

Hi,

 

Haha gulp I have been trying to figure out why a particular code didnt work as it happens it dose which made searching for an error very hard. The problem was that my code couldnt select a document because there were multiple instances of inventor open this understandable confusses the vb.net/ Inventor API. How canb I handle a situation where multiple instances of inventor are open?

 

The code that dose work as example bellow:

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim invApp As Inventor.Application
        invApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")

        Dim Doc As Document
        Doc = invApp.ActiveDocument

        ' Update or create the custom iProperty. 
        UpdateCustomiProperty(Doc, "Test", "Some Text")

    End Sub

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

Owner2229
Advisor
Advisor

Hi, are you ussing this code from an Add-In or standalone application?

 

If it is Add-In, you should get the active Inventor from StandardAddInServer.vb.

 

Otherwise, are you starting the Inventor instances from your app or you just want to catch them?

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi,

 

This is a standalone application...(its own exe file)

0 Likes
Message 4 of 4

JamieVJohnson2
Collaborator
Collaborator

You problem has a simple solution.  get inventor app, store it as a global public variable for the entire application, all programs that want to get the inventor app, must run the one same routine that checks for its existence before getting another one. 

 

I have divided my routines into 2 levels, entry, and processing.  entry level routines, get the app and make sure its available, processing apps, assume the global variable is fine.  entry level routines are also responsible for calling 'close' on the inventor app.

 

my problem is when I want to get ALL instances of inventor apps (at times I could have several with files showing, some without files showing, and some with and without files hidden, and some apps that only show up in windows task manager as background processes).  I'm working on that one.

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes