Compiling the Revit 2015 SDK and Migrating Bc Samples

As I announced yesterday, Revit 2015 was released last week, the Revit SDK was posted and updated, RevitLookup for Revit 2015 is available on GitHub, the DevDays Online presentation on the new API functionality is available, and I migrated The Building Coder samples to Revit 2015.

After doing so, I went out and spent a few hours on a hill enjoying the full moon – enjoying nature, some time, some space for myself – ca. 380.000 km of space in the direction of the moon, a bit more in some other directions :-) This picture was taken by my friend Anja the day before:

The almost full moon in April 2014

Here is an overview of the steps I took, some of which you probably need to take as well to set yourself up ship-shape for Revit 2015 add-in development:

For more details and other approaches, please refer back to my description of the steps to achieve more or less the same goals when compiling the Revit 2014 SDK. You can bet I did some of it differently last time around.

By the way, the good news is that it is much simpler this time, and getting simpler every release.

Download, Compile and Install RevitLookup

All you need to do for RevitLookup is clone the RevitLookup GitHub repository, compile and install as usual.

Compiling the Revit 2015 SDK

Before migrating The Building Coder samples, I downloaded and compiled the updated Revit 2015 SDK from the Revit Developer Centre:

The Revit SDK includes a master Visual Studio solution file SDKSamples2015.sln, so you basically just have to open that in Visual Studio 2012 and say 'build all'.

There is one small issue to deal with first, though: where are your Revit API assemblies located, and where do the Visual Studio project files expect them to be?

The latter is defined by the HintPath tag in the project files. Go take a look in one of them with a text editor, e.g. Notepad.

I currently only have Revit Architecture 2015 installed, and the SDK apparently assumes by default that you have Revit One-box installed, so I needed to update all the Revit API references – or find another solution to ensure they are found.

The most stupid approach would be to go and manually edit each and every one of the over hundred Revit SDK project files using the Visual Studio IDE.

A less stupid approach would be to edit all the project files globally in an editor, e.g. using search and replace functionality to modify the HintPath tag value.

This can also be done for you fully programmatically, e.g. by my jhint utility, or using the RevitAPIDllsPathUpdater.exe utility provided in the Revit SDK.

I implemented jhint back in the year 2008, to process the Revit 2009 SDK project files.

Yet another option, and possibly the most elegant of all, is to simply copy the Revit API assemblies into the expected locations and avoid modifying any project files at all, as I explained when updating the API assembly references for the Autodesk Building Design Suite Ultimate 2013.

That is what I did this time around, after checking the current values of the HintPath tags using jhint.exe.

I thus executed the following commands to discover the required assembly reference paths and ensure that they are found where expected:

  cd C:\a\lib\revit\2015\SDK\Samples

  jhint -v -r *proj | sort | uniq

  cd C:\Program Files\Autodesk\Revit Architecture 2015

  cp RevitAddInUtility.dll RevitAPI.dll RevitAPIIFC.dll
    RevitAPIUI.dll "..\Revit 2015"

Setting up RvtSamples

If you want to run and test any of the SDK samples, you again have a choice between the laborious approach and the automated one.

It would be rather laborious to install a separate add-in manifest for each of the over hundred external commands defined by the Revit SDK samples.

You can save yourself the effort by installing one single external application instead, RvtSamples.

It reads a text file defining the path and external command implementation name of each of the samples and sets up one big menu of them all for you.

As always, I added the add-in manifest RvtSamples.addin and the input text file RvtSamples.txt to the RvtSamples project files to make them easier to open and manipulate.

In RvtSamples.txt, I replaced the default Revit SDK installation location by my personal installation folder, i.e. search and replace globally

  C:\Revit 2015 SDK\
  -->
  C:\a\lib\revit\2015\SDK\

That was it, and here is the ribbon panel containing the RvtSamples top level menu:

RvtSamples in Revit 2015

Migrating The Building Coder Samples

We should be pretty well set for the migration, having already future proofed The Building Coder samples.

All I have to do is perform the same steps I already described for the migration of RevitLookup to Revit 2015:

As expected, an error is generated in the CmdSheetSize.cs module:

The TitleBlocks property was declared deprecated in the Revit 2014 API, and removed in Revit 2015, so we now have no choice but to remove it.

The replacement code using a filtered element collector is already in place, and has been so for years now.

That done, the project compiles successfully, still generating 72 warnings.

I will happily leave them in for now.

In order to test the samples, we need to update the RvtSamples include file BcSamples.txt, and adapt RvtSamples.txt to refer to and include it.

I added the following line to the end of RvtSamples.txt:

  #include C:\a\lib\revit\2015\bc\BcSamples.txt

In BcSamples.txt, I updated the paths referring to all the external commands we define, just like above for RvtSamples.txt itself, by globally replacing the 110 occurrences of the old root path by the new:

  C:\a\lib\revit\2014\bc\
  -->
  C:\a\lib\revit\2015\bc\

Starting up Revit 2015 and looking at the menu generated by the RvtSamples external application, you now see the two entries with over one hundred sub-entries added by The Building Coder samples via the BcSamples.txt include file:

RvtSamples including The Building Coder samples for Revit 2015

Download The Building Coder Samples

The complete source code, Visual Studio solution and RvtSamples include file is provided in The Building Coder samples GitHub repository.

The version discussed above is release 2015.0.109.0.

I wish you good luck, lots of fun and zero hassles getting started with Revit 2015 and migrating your applications.