Open a specific version of Inventor using C#

Open a specific version of Inventor using C#

vsonare_18
Observer Observer
640 Views
1 Reply
Message 1 of 2

Open a specific version of Inventor using C#

vsonare_18
Observer
Observer

Hi,

I'm new to Inventor API and currently working on a stand-alone application, and I'm writing it in C#. Here is the scenario:
My machine has multiple versions of Inventor installed (2021, 2022 & 2024). And I want to launch a specific version of inventor.

Currently I am using following code to launch inventor:

try
{
     inventorApp =(Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");
}
catch
{
     Type inventorAppType = System.Type.GetTypeFromProgID("Inventor.Application");
     inventorApp = System.Activator.CreateInstance(inventorAppType) as Inventor.Application;
}
inventorApp.Visible = false;

 

Above code launches Inventor 2024 by default but I want to launch Inventor 2021 and it should run as background process.

 

Please help me out.

Thanks a lot.

0 Likes
641 Views
1 Reply
Reply (1)
Message 2 of 2

JelteDeJong
Mentor
Mentor

why not start Inventor like a regular application and then try to get the object? Something like this:

System.Diagnostics.Process.Start("c:\Path\to\Inventor20XX.exe");
var inventorApp =(Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");

 

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