Getting Inventor Object in NET Core

Getting Inventor Object in NET Core

SometimesInventorMakesMeAngry
Advocate Advocate
2,553 Views
2 Replies
Message 1 of 3

Getting Inventor Object in NET Core

SometimesInventorMakesMeAngry
Advocate
Advocate

Is it possible to get the active Inventor object in NET Core? Marshal.GetActiveObject is no longer supported.

0 Likes
Accepted solutions (2)
2,554 Views
2 Replies
Replies (2)
Message 2 of 3

pockybum522
Enthusiast
Enthusiast
Accepted solution

https://paste.mod.gg/akecoraguh.cs

 

Let me know if you have any questions.

 

This is tested in a .net 5 project (Which is .net core, and is the only version of .net going forward.)

 

The only thing I did was reference the usual Inventor interop DLL in my project, as shown below.

 

The MarshalForCore code is not mine, found it in the AutoCAD forums, I think.

 

pockybum522_0-1610047319318.png

 

Message 3 of 3

pockybum522
Enthusiast
Enthusiast
Accepted solution

Here's a new version that can handle getting a reference to multiple inventor objects by using the Running Object table.

 

It will also warn if there's Instances open that don't have a unique ROT reference, which happens if multiple instances are open but one doesn't have a document open or two instances have the same document open, as the ROT reference is based on the document.

 

Note that if there's only one instance open and it has no document, this can get a reference to it, since it uses the old marshalling.