Google Analytics (Hidden)

Monday, April 4, 2011

My first Revit API, Part One

My first Revit API, pt 1

For starters

So, I finally came to it. After nearly a year of lurking around in the deep dark depths of Revit’s Advanced Programming Interface (API) I took the plunge and had my first crash course in API.

First of all: I never ever did any programming before I started this. Not in Visual Basic, C# or even a Lisp routine for Autocad. My strengths, if any, lie within the normal use of Revit, with the UI (User Interface). I work my miracles at the front end, sort of speak. But, that side has it’s limitations, and that’s why I ultimately decided to cross over to the dark side…

Due to my complete lack of programming knowledge, I’m taking babysteps. I did find however that I have one big advantage over the “traditional” programmer: I know my way around in Revit. I know it’s functions, it’s language

and it’s quircks. That gives this puny mortal hope. This blog is about my experiences while trying to understand how Revit works under the hood.

HOWEVER: This blog is meant to give others like me some grip on working with the API. But it’s far from complete, and cannot be trusted to be accurate nor complete, since I know as little about this as you do… Do I need to further emphasize the fact that I cannot be held accountable for any damage, direct or indirectly resulting from reading this blog and/or referencing to it’s contents?

Now, since the “official” part is over, what do you need to start with API programming? First off:

  • A major dose of pain killers to rub off the headache of your first day off staring at a complete textstring madness. I for one settled on a few big scotches afterwards, but to each their own. Seriously though: this is heavy stuff. Do not try to squeeze it in between normal daily routine. Free up time!
  • You can start with buying half a dozen biblesized books about programming in C# or VB.NET, which will without a doubt give you serious suicide cravings. It’s like learning Revit in Chinese mode without a dictionary. But the Revit community also provides with a lot off resources. Pay special attention to Jeffrey Tamnik’s weblog, The Building Coder. If this guy can’t do it, it cannot be done. Or post at, since we have some great API guys too. Truth of the matter is, when you’re familiar with Revit, the code will make sense if you trust your instincts.
  • Install Visual Studio Express Edition. It’s free, easy to use (really) and has more capabilities then the native Revit program interface. Check out which version goes with the Revit version you want to program for. For instance, Revit 2011 works with Visual Studio 2008. Not all versions work the same so you need to be clear on this one.

Some context

My first day started with a brief history of programming, which I will spare you from. Let’s just say that, in this day and age, most of the programming languages are quite similar. Differences between C# (by the way, this is pronounced C Sharp) and VB (Visual Basic) are comparable to dialects: most of the time It’s quite the same, and every once in a while you will completely misunderstand the other language.

With all different languages that are floating around, thousands of parties writing software and re-inventing the wheel, there has to be some generalization. A Style Guide sort of speak. This is where .NET (pronounced Dot Net) comes in. Microsoft .NET is kind of like a huge pile of LEGO elements which you can pick from to put together your program. It offers standards for commands, actions, descriptions and everything else you need to build your software. Why does all Windows Software look and feel the same? Because it’s all compiled in .NET.

We could go into a heated argument that this creates a mass culture where nothing stands out. I, for one, am thrilled if the freaking thing works and don’t really care what it looks like. If I can use .NET to type in a simple textstring command in Visual Studio and it automatically creates a Pick File screen like the one below, who cares what it looks like?

Standard .NET functionality: Forms and screens.

So it comes down to this:

C# / VB = programming language

.NET = a standard interface which contains basic templates, commands, etc which allow a programmer to work faster, more accurate and gives an universal look and feel to the programmed software.

API = the part of a software product (in this case Revit) which contains all rules and commands specific to this software. It’s the portal between Revit and the outside world. Everything that comes into or gets out of Revit goes through the API.

Visual Studio = a piece of software that lets you write another piece of software. VS “knows” all three of the above, and ties them together. Using VS you can tie Commands from the Revit API (Place Component) into a Windows Form (such as the Open Form) using the C#.NET programming language.

Try wrapping your head around that one for a while before we continue. Took me a whole lunchhour…

Next Part: Visual Studio 2008...


  1. Keep it coming. I am making you do all the hard stuff so I can come to you with questions later. ;)

  2. Martjin, excellent post so far .. I'm hooked ;-)

  3. Really cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info! , Regards, servicenow training in hyderabad


  4. Thanks for posting this useful content, Good to know about new things here, Let me share this, . LINUX training in pune

  5. คาสิโนออนไลน์ที่น่าเชื่อถือและมีความเป็นมืออาชีพที่สุดในตอนนี้
    โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
    เพียงแค่คุณสมัคร สล็อตออนไลน์ กับทางทีมงานของเราเพียงเท่านั้น
    สมัครสล็อตออนไลน์ >>> Goldenslot
    สนใจร่วมสนุกกับ คาสิโนออนไลน์ คลิ๊กได้เลย
    มีทั้งคาสิโนออนไลน์ หวยออนไลน์ ฟุตบอลออนไลน์ สล็อตออนไลน์ และอื่นๆอีกมากมาย

  6. Need academic study help online? But worried about getting plagiarized content? At, you are assured to get 100% authentic and original study help solutions.

  7. Google started using site speed as a ranking signal in their algorithm way back in 2010, and it continues to serve as one of the many factors that determine where your website shows up in the search results. We help you WordPress Speed Optimization are Page Caching, PHP latest version, Image optimization and resizing, jquery update, Cache Preloading, Sitemap Preloading, GZIP Compression, Browser Caching, Database Optimization, Google Fonts Optimization, Lazyload, Minifying JS CSS HTML files, Deferring Unused JS/CSS, CDN setup, Mobile Detection, Stop unused CSS and JS file and many more optimization your WordPress website. So, your website super-fast loading within 1-5 seconds. WordPress Speed Optimization