I just finished working with a customer that was having a problem accessing certain functionality in the API. He had written an initial prototype in VBA that worked as expected but then when he started to convert the program to .Net some of the Inventor API objects he was using weren’t available. The reason is that he was using an old .Net interop.
The Inventor API is exposed using Microsoft’s COM technology. The contents of the API (it’s objects, methods, properties, and events) are described in a file known as a type library. When you use VBA it directly references this type library to know what’s in Inventor’s API and uses this to support Intellisense and to be able to compile and run the program. VB.Net and C# are .Net based languages and don’t support directly calling a COM API. To provide support for COM API’s .Net supports the creation of an interop library that serves as a translation layer between COM and .Net. The Interop provides the same functionality to VB.Net or C# that the type library does to VBA. It describes all of the objects and functions in the Inventor API and converts the .Net API call into a native COM call. As of the last few .Net releases this technology works very good and in almost all cases makes it completely transparent that you’re not working directly with the COM API.
When you create a new .Net or C# program to work with Inventor you need to add a reference to Inventor’s COM interop in order to have access to the API. You do this by using the References command in Visual Studio. In the dialog, use the “Browse” option to the left and then click the “Browse…” button at the bottom of the dialog.
Browse to “C:\Programs Files\Autodesk\Inventor XXXX\Bin\Public Assemblies”, (where XXXX is the version of Inventor you want to use) and select “autodesk.inventor.interop.dll”.
Your program is now dependent on the interop for that version of Inventor. Let’s say that you create a reference to Inventor 2014 and then later you uninstall Inventor and install Inventor 2015. The API is backward compatible so when you installed Inventor 2015 it installed the interop for 2015 but also installed interops for several previous versions so programs dependent on those older version will still continue to work. But it your program needs to use some functionality that is new in Inventor 2015 you need to change the reference to the newer interop where this new functionality is defined.
You can see what references an existing program has in the Solution Explorer in Visual Studio. By default they’re not shown but by clicking the “Show All Files” button a new “References” folder will appear in the tree, as shown below.
You can see more information about a specific reference by selecting it and looking in the Properties window, as shown below. In this case I’ve selected the “autodesk.inventor.interop” and it’s showing me that it’s version 22.214.171.124.
The version numbers are confusing because they don’t directly correlate with the public version of Inventor. Here’s a table showing the public version, the corresponding software version, and the internal development name.
|Public Version||Software Version||Internal Name|