Migrating The Building Coder Samples to Revit 2014

I started migrating The Building Coder samples to Revit 2014. Funnily enough, on the exact same date as last year for the previous version.

The changes are very small this time around.

Furthermore, I am well prepared, since I recently intentionally eliminated all compiler warnings and deprecated calls compiling the code for Revit 2013.

First, however, a picture or three from my ski tour last wekend over Il Chapütschin (3386 m) and La Sella (3584 m) in the Swiss Engadin. Here I am on the first summit:

Il Chapütschin

The panorama is grandiose:

Mountain panorama around Il Chapütschin

We arrive back at the hut tired and happy:

Coffee in the hut

Migrating The Building Coder Samples to Revit 2014

Back at the desk and steeped in the Revit API, Here is what I have done so far to migrate The Building Coder samples from Revit 2013 to Revit 2014:

Update the Revit API Assembly References

Every Revit add-in needs to reference the API assemblies.

They now live in the main Revit installation folder, together with Revit.exe.

In my case, this folder is "C:\Program Files\Autodesk\Revit Architecture 2014", and I am referencing the three assemblies RevitAPI, RevitAPIUI and UIFrameworkServices.

Just updating the references and recompiling generated 5 errors and 3 warnings.

Remove Obsolete Collections Namespace and RoomCreationData Class

Four of the five errors say "The type or namespace name 'Collections' does not exist in the namespace 'Autodesk.Revit' (are you missing an assembly reference?)".

To my surprise, I did indeed have several obsolete statements like this left over from previous versions:

using Autodesk.Revit.Collections;

They were actually not required at all by the Revit 2013 compilation, just left over from still older versions.

The fifth warning is similar, saying "The type or namespace name 'RoomCreationData' does not exist in the namespace 'Autodesk.Revit.Creation' (are you missing an assembly reference?)", and could also be resolved simply by removing this obsolete using statement:

using RoomCreationData
  = Autodesk.Revit.Creation.RoomCreationData;

Removing these erroneous using statements enables the compilation proper to execute and raises the number of problems reported to 3 errors and 108 warnings.

Just three errors! Looking good...

TopographySurface Namespace Changed

Now we hit some real errors caused by slight shifts and redefinitions in the API.

The first error is in CmdLandXml.cs:

  TopographySurface surface
    = doc.Create.NewTopographySurface( pts );

It says "The type or namespace name 'TopographySurface' could not be found (are you missing a using directive or an assembly reference?)".

The TopographySurface class apparently moved from one namespace to another. In Revit 2013, it lived in Autodesk.Revit.DB.

This is easily remedied by placing the cursor over the offending class name and pressing Ctrl + '.', which brings up a menu listing the fully qualified class name and offering to automatically correct the error for you:

Using Ctrl + '.'

Some Unit API Changes

The other two errors refer to units, one of the few areas seriously modified in the Revit 2014 API, and say:

They are caused by the following lines in ParameterUnitConverter.cs:

  FormatOptions fo = document.ProjectUnit
    .get_FormatOptions( ut );
  DisplayUnitType dut = fo.Units;

They are easily fixed by using the following new methods and properties:

  FormatOptions fo = document.GetUnits()
    .GetFormatOptions( ut );
  DisplayUnitType dut = fo.DisplayUnits;

We are left with zero errors and 111 warnings, which we will leave to deal with another day.

Initial Revit 2014 Version

So here is the result, the very first version 2014.0.100.2 of The Building Coder samples for Revit 2014.

To compare with the last version for Revit 2013, look at the version 2013.0.100.2 that I provided after eliminating all compiler warnings and deprecated calls.