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 weekend over Il Chapütschin (3386 m) and La Sella (3584 m) in the Swiss Engadin. Here I am on the first summit:
The panorama is grandiose:
We arrive back at the hut tired and happy:
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
- Remove obsolete Collections namespace and RoomCreationData class
- TopographySurface namespace changed
- Some unit API changes
- Initial Revit 2014 version
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:
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:
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:
- 'Autodesk.Revit.DB.Document' does not contain a definition for 'ProjectUnit' and no extension method 'ProjectUnit' accepting a first argument of type 'Autodesk.Revit.DB.Document' could be found (are you missing a using directive or an assembly reference?)
- 'Autodesk.Revit.DB.FormatOptions' does not contain a definition for 'Units' and no extension method 'Units' accepting a first argument of type 'Autodesk.Revit.DB.FormatOptions' could be found (are you missing a using directive or an assembly reference?)
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.