Revit API Flavours

Maher raised an interesting question regarding the different flavours of the Revit API:

Question: I have a few questions on Revit MEP, Arch, and Structure in general. What are the major highlights of each API? I downloaded the SDK and tried to read through. But could not get my head around it as it is very overwhelming. It would be great if you could post something in the difference between these three flavours both in terms of API and in general use. They seem to do the same thing in many cases. I am confused.

Answer: By far the major part of the Revit API is identical for the three flavours, and to get started with it you need not worry about the differences. All the basic functionality and most objects that I have ever had occasion to use are provided in all three flavours.

If you try to access a property that is not available in the particular flavour of Revit that your application is running in, the property will generally simply return a null value or sometimes throw an exception, as Shifali is currently painfully discovering, being unable to access the gbXML settings in Revit Architecture.

You can check what flavour you are running in by querying the application object as demonstrated by the Revit API introduction labs sample command Lab1_2_CommandArguments:

  Application app = commandData.Application;
  Document doc = app.ActiveDocument;
  View view = commandData.View;
  string s = "Application = " + app.VersionName;
  s += "\r\nVersion = " + app.VersionNumber;
  s += "\r\nDocument path = " + doc.PathName;
  s += "\r\nDocument title = " + doc.Title;
  s += "\r\nView name = " + view.Name;
  LabUtils.InfoMsg( s );

In the Revit 2010 API, new LanguageType and ProductType enumerations and corresponding properties on the application object were introduced to enable an add-in to query and analyse the underlying product and user interface language without resorting to any string comparisons:

  LanguageType lt = app.Language;
  ProductType pt = app.Product;

We have previously taken a deeper look at the Revit Structure and MEP APIs and mentioned some of the specific features of each.

The easiest way that I can think of to see the exact differences between the three flavours of the Revit API is to look at the class diagram in the Revit SDK provided in "Revit API Class Diagram.png". It shows all of the namespaces and classes defined in the Revit API and colour codes them into various groups, including separate groups for the three product flavours.

The developer guide in the document "Revit 2010 API Developer Guide.pdf" also includes the three separate chapters dealing with the API specifics of each flavour:

  1. Revit Architecture
    23.1   Rooms
    23.2   Energy Data
  2. Revit Structure
    24.1   Structural Model Elements
    24.2   AnalyticalModel
    24.3   Loads
    24.4   Analysis Link
  3. Revit MEP
    25.1   MEP Element Creation
    25.2   Connectors
    25.3   Family Creation