To program Inventor you need to use some type of programming language. The good and the bad news is that there are a lot of choices. It’s good because it provides flexibility for everyone to choose something they like and best fits their requirements. It’s bad because you have to make a choice and if you’re new to all of this you may not know what to look for in making that choice. Discussing computer languages can be a dangerous topic because people tend to have strong opinions and can be passionate about their language of choice. In reading any of the following, just remember that it’s my opinion.
For learning Inventor’s API, I believe you should use Inventor's VBA (Visual Basic for Applications). I’m not saying it’s the best language to use when writing applications for Inventor, but I think it is the best for learning and experimenting with the API.
When programming Inventor, Inventor doesn’t care which language you use. Inventor exposes its programming interface using Microsoft technology called COM Automation. This technology provides a formalized way to describe the details of a programming interface in a generic way. When you call an Inventor API function the call goes through this Automation interface and when Inventor receives the call it doesn’t even know what programming language the call came from. The only language requirement when programming Inventor is that it supports COM Automation, which most languages do.
My reason for recommending VBA is because VBA was designed specifically for programming COM Automation interfaces. Because of this there are two big advantages to using VBA; the Object Browser and debugging. The Object Browser is a tool within VBA that allows you to look at the objects and functions provided by an API. Other languages also provide object browsing functionality but they don’t work as well as the VBA browser for viewing COM Automation interfaces. As far as debugging, almost all languages support the ability to debug your programs; however VBA supports better debugging a COM Automation interface by allowing you to view more details about objects. Another point in VBA’s favor is that’s it integrated with Inventor, which means if you have Inventor you have VBA. This integration also makes it easier to access Inventor’s API than when using any other language. One other advantage is that the API samples in the online help are currently all written in VBA.
All of the reasons I’ve listed above make VBA an easier language to use when learning the API and even later when prototyping and investigating the capabilities of the API. No matter what your programming experience and language preferences I highly recommend gaining a basic understanding of VBA because I believe it will benefit your overall programming efficiency when programming Inventor’s API. You can think of VBA as a style of pseudo-code that you can run and test. The API principles you learn with VBA aren't language specific and are easily transferred to any other language.
Even with the advantages of using VBA discussed above, I don’t recommend VBA for writing an Application. It's ok for small macros but for larger work there are better choices. All languages have pros and cons and VBA’s cons don’t make it the best language for writing applications. My current personal choice for writing applications is Visual Basic .Net, which Visual Basic 2008 is the most current version. My choice of Visual Basic over most of the other available languages is primarily personal preference but there are a couple of reasons I would also recommend it to a newer programmer. First, it provides an easier upgrade path from VBA and second, I believe it is easier to use than the other languages.
One version of Visual Basic worth spending a little time discussing here is Visual Basic 6. Many of the existing larger samples provided with Inventor's SDK were written using VB 6. This is an older version of the Visual Basic language and has many of the same advantages as VBA since it uses the same underlying engine. It was made to program COM Automation types of programming interfaces and has the same object browser and debugging support that VBA has. A big problem with VB 6 is that it has been discontinued and is no longer available from Microsoft. It also does not support writing applications for 64 bit Windows. If you’re going to make the effort to learn a programming language it doesn’t seem very good to spend your time learning and writing a lot of code with an obsolete language. Becuase of that I can’t recommend using VB 6.
The .Net languages, C# and Visual Basic, both support COM Automation programming. Even though they both have the object browser tool and support debugging they don't work as well as they do in VBA. However, they have a lot of other advantages over VBA (and VB 6) that makes them a better choice for larger application development. Whether you choose Visual Basic or C# is really just personal preference.
The other popular language, primarily with professional developers, is Visual C++. Visual C++ is a very powerful language but is also difficult to learn and use. It supports programming a COM Automation interface but is significantly harder than either Visual Basic or C# to use. If you choose to use Visual C++ you can expect a higher learning curve and longer development times.
Finally, there are a few fringe languages. Some of these have been around for a long time, (i.e. Delphi), and others are relatively new (i.e. Python). As I said earlier, Inventor doesn’t know or care what language you’re using and you can use whatever you choose. However, you’ll have a hard time finding any samples or support when using these languages. For me, they’re interesting to look at but at this point I would be hesitant to begin a large development project using any of them.
No matter what language you choose I still recommend using VBA for prototyping investigating the API. For the rest of this series of articles I’ll be using VBA to demonstrate the use of the API. Where there are actual differences when using other languages with Inventor’s API, I’ll try and have code that demonstrates those differences and what’s needed in the various languages to get things to work.