Historical Commentary (skip unless you're bored!)
It's strange to see, looking back, how the API grows in tandem with each product.
In the AutoCAD world, there was LISP pretty darn close to the beginning (I wasn't there - so I can't rattle off the exact version number it appeared like some of my compatriots can). And look AutoCAD now - there's LISP, VBA, ARX and AutoCAD.NET (and that's an over simplification as well as leaving out some of the more obscure APIs).
In Autodesk Inventor, the API (C++ and COM/VBA) came out around Inventor 5.0 (roughly?) - and has gone from under-powered to very powerful (dropping the C++ support along the way).
Revit went from no API to a Microsoft.NET API... A sort of "walled-garden" which somehow still seemed to exclude the masses of people who might be interested in automation.
Well - all that is about it change - sort of. Revit 2009 introduces Microsoft VSTA - that's Visual Studio Tools for Applications - the next generation follow-on to VBA (Visual Basic for Applications).
Autodesk talks a lot about "democratizing technology" - and nothing has democratized programming like VBA (and LISP). It really enabled technically savvy people to experiment with programming in a friendly environment, which was tightly tied to the CAD system. VSTA should do the same thing - although it's got its differences.
But weren't there already free ways to...?
For a while, there was a price obstacle - if you wanted to develop for Revit, most people thought you needed to fork out $800-$1200 USD for Microsoft Visual Studio. While there were technically other low-cost options, it was a conceptual barrier as much as anything.
In 2005, Microsoft introduced the free "Express Edition" of Visual Studio, which enabled users to develop software without the upfront costs (with some limitations - like limited or no ability to debug things at runtime - an invaluable capability).
I would still argue, however, that there were significant hurdles there - whether it was getting Visual Studio loaded, or the arcane way that Revit external applications are included into Revit via a REVIT.INI file. VSTA will remove many of the logistical obstacles.
It's Like VBA!
VSTA (once installed - it's one of the "Additional Products" available on the Revit DVD) - enables you to write and run "Macros". You develop inside of the VSTA IDE (Integrated Development Environment) - a nice, light version of Visual Studio which provides Intellisense (where you just need to type the first letter or two and it offers you all the choices for what you were trying to do). Like VBA, you're able to step through or set breakpoints in your projects to debug them.
Also like VBA, the macros can be stored either externally or within a document. The document approach lets the code travel with your Revit model! There are some neat things that you can do with that (so long as you're not worried about your code getting away from you).
It's Not Like VBA!
Here's where things get different...
The language is not exactly like Visual Basic / VBA. You write your macros using your choice of either Visual Basic.NET or C# (pronounced C-Sharp).
While Visual Basic.NET is incrementally more challenging than VBA - the good news is that there are many books, courses, and online content to help you. The great part about including C# as well is that there is also a wealth of online content (as well as Revit SDK samples) in C# - and these samples can typically be pasted in with only minor modifications - so VSTA is not a "second-class citizen" as VBA sometimes was.
The Content is the Same...
One key thing to understand - it's all the same Revit API. With only minor differences, the API that is available in VSTA is exactly what is available to traditional Microsoft.NET developers for Revit applications - so there's very little holding you back.
Here Comes the Neighborhood
When anything gets "democratized" like this - there's an occasional sense of unease amongst the previous members of the exclusive club - that it's not quite as special now that everyone can do it. I personally am fighting this off - on the theory that this will accelerate the Revit API development going forward. The more users who are interested and aware of what the Revit API can do, the more attention Autodesk will pay to extending their capabilities.
Where to Get Started?
There are several areas to learn about to begin your quest:
- VSTA itself
- Visual Basic.NET or C# Language
- Revit API development (general)
VSTA - there have been some AU sessions on VSTA in the past, which you can access at AU Online if you attended those AUs. You can also visit the Microsoft VSTA developer center (although take note that Revit 2009 ships with VSTA 1.0 (which corresponds to Visual Studio 2005) - Microsoft is currently touting the forthcoming VSTA 2.0 / Visual Studio 2008).
Visual Basic.NET - There are probably hundreds of books and tens of thousands of online articles and other content... You have to pick what works for you.
Revit API development - You can download the Revit SDK from here. (although the 2009 link is not posted as of this writing). This will include samples (both traditional, as well as some VSTA). Finally, Autodesk Developer Network has published one of its DeveloperTV episodes on the same site to give you a brief overview of Revit development.
Online/In-Person classes - Avatech Solutions (who I work for) is considering providing online and in-person classes for people who want to learn to program Revit using VSTA. If you're interested in something like this, contact us at ( devfeedback (at) avat.com ).
To all you VBA developers or otherwise talented tinkerers - welcome to the world of Revit development!
Thursday, February 28, 2008
Historical Commentary (skip unless you're bored!)