The Revit 2020 FCS, API and SDK

Revit 2020 has been released, and we go through the same procedure as every year, looking at the DevDays online presentation highlighting the API news, getting the system requirements set up, installing, compiling the Revit SDK samples and setting up RvtSamples to load them:

RvtSamples loaded all Revit 2020 external commands

Revit 2020 First Customer Shipment

Look at the overview by Harlan Brumm on What's New in Revit 2020 from an end user point of view.

Revit 2020 DevDays Online

Turning toward the programming side of things, we held a series of DevDays online presentations presenting previews of new Forge features and desktop API updates in February and March, including one of special interest for us here, covering What's New in the Revit 2020 API. Here are the recordings:

Forge sessions:

Desktop product sessions on the ADN page:

Oops, I just noticed that the three links above all point to the same place on the restricted ADN web site.

Here are two publicly accessible Dropbox pointers for non-members to the Revit related topics:

Update: The 54-minute Revit DevDays Webinar Recording is now also available in the Autodesk DevTV Youtube channel:

Discover the product and API changes and enhancements of Revit, Civil 3D and InfraWorks 2020, including the Forge Design Automation for Revit API.

Setting up Windows 10

With that public stuff out of the way, I now turn to my personal experiences preparing for and setting up Revit 2020 and its SDK.

I initially tried to install Revit 2020 on the same virtual Windows machine that I used for the past few versions.

The initial download step produced an executable Revit_2020_G1_Win_64bit_wi_en-US_Setup_webinstall.exe.

Unfortunately, however, when attempting to run it, it rejected installation on Windows 8.1:

Revit 2020 rejects Windows 8.1

I am forced to finally move on, set up a new virtual machine and update to Windows 10, ending up with the pro version 1803 from Aug 2018.

I used the Windows 10 installation ISO from www.microsoft.com, producing Win10_1809Oct_v2_EnglishInternational_x64.iso on my local machine, and a product key from MSDN subscriptions using my hotmail account, which led me on to my.visualstudio.com/ProductKeys.

Installing Revit 2020 and the New SDK

Once I had the new virtual machine set up, the Revit 2020 product installation was straightforward.

I searched for the SDK installation executable in the product installation files with no success.

Therefore, I launched the Revit SDK installation via Setup.exe > Tools and Utilities instead.

That downloaded the executable to its habitual location:

I installed the SDK to my local machine.

In order to explore it in more depth, however, I need to install Visual Studio on the new machine as well.

Visual Studio 2015 and .NET 4.7

First, I checked for updated development requirements in the new Revit online help files at help.autodesk.com/view/RVT/2020/ENU/ in the developer guide section on development requirements.

It mentions Microsoft Visual Studio 2015 Professional, so I grabbed that from MSDN as well.

Visual Studio 2015 includes the .NET 4.5 developer pack, but not the version 4.7 required by the Revit 2020 API.

When I try to load the SDK samples solution SDKSamples.sln into Visual Studio, it asks whether it should modify all the project settings from .NET 4.7 to 4.5.

No, it should not!

I installed the .NET 4.7.2 developer pack and tried again, with the same result: still cannot build SDKSamples.sln.

After several other attempts and test building of simple console applications to ensure the framework was in place, I realised that the .NET 4.7.2 developer pack does not satisfy Visual Studio's request for the 4.7 developer pack.

After installing the .NET 4.7 developer pack (with no suffix, i.e., .0), once more restarting Windows and implementing another test console app using 4.7.0, I can finally load all the SDK samples with SDKSamples.sln.

Compiling the Revit 2020 SDK Samples

After I was finally able to load the SDK samples solution into Visual Studio without all projects being set back to .NET 4.5, I started the first compilation run.

It produced 17 errors and 38 warnings, cf. revit_2020_sdk_samples_errors_warnings_1.txt.

The first error CS1591 complains about a Missing XML comment for publicly visible type or member in the Custom2DExporter project.

A newly added project in this version, very exciting topic, let's discuss it in depth asap, first get this error fixed, though.

In fact, the Custom2DExporter project is set to Treat warnings as errors, so we can start by turning that off for the moment. That helps, and reduces the error count.

We now have 9 errors and 46 warnings, cf. revit_2020_sdk_samples_errors_warnings_2.txt.

Modifying the Treat warnings as errors setting to 'None' for the PathOfTravel, RebarFreeForm and SampleCommandsSteelElements projects as well reduces the errors to one single one:

Well, yes, I don't have Microsoft Office installed on my virtual machine, so that makes sense.

On the other hand, of course, the number of warnings are now higher: 1 error and 54 warnings, cf. revit_2020_sdk_samples_errors_warnings_3.txt.

For a quick fix, I temporarily unloaded the PointCurveCreation project.

That leads to 0 errors, 52 warnings, 189 projects succeeded, 0 failed, 0 skipped, cf. revit_2020_sdk_samples_errors_warnings_4.txt.

Later, I noticed that the Excel Interop DLL is already present as a component in several other Revit SDK samples, e.g., in:

I therefore reloaded the PointCurveCreation project again, added a reference by browsing to the existing DLL, and now have

0 errors, 52 warnings, 190 projects succeeded, 0 failed, 0 skipped, cf. revit_2020_sdk_samples_errors_warnings_5.txt.

Many of the warnings refer to an architecture mismatch:

Happily, I implemented a fix for that years ago, cf. my DisableMismatchWarning utility in its GitHub repository. I ran DisableMismatchWarning.exe in the SDK Samples installation folder, and that reduced the number substantially to

0 errors, 21 warnings, 190 projects succeeded, 0 failed, 0 skipped, cf. revit_2020_sdk_samples_errors_warnings_6.txt.

Later, I found a much simpler solution to the Missing XML comment warning in Custom2DExporter, PathOfTravel, RebarFreeForm and SampleCommandsSteelElements projects: simply uncheck the box in the build setting requesting the generation of an XML documentation file. After that, the Treat warnings as errors setting can be safely turned back on again. That reduce the number further to

0 errors, 5 warnings, 190 projects succeeded, 0 failed, 0 skipped, cf. revit_2020_sdk_samples_errors_warnings_7.txt.

These remaining warnings are due to some weird settings in the project files that I will ignore for now.

Setting up RvtSamples

Next, I set up RvtSamples to load most of the SDK external commands.

RvtSamples is an external application that creates a menu and populates it with entries for all the external commands defined by the Revit SDK, making them accessible with one single click and saving me the effort of installing each and every sample command individually with its own add-in manifest.

In order to do so, RvtSamples reads an input text file, RvtSamples.txt, that defines the location of all the external command assembly DLLs and the names of the .NET classes they contain implementing the external commands.

First of all, I edit that input text file.

It is initially set to the default installation location:

I replace that globally by my local installation folder C:\a\lib\revit\2020\SDK\Samples\... 234 occurrences are replaced.

Next, I edit the RvtSamples add-in manifest, RvtSamples.addin, to point to the location of the RvtSamples DLL itself:

<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
  <AddIn Type="Application">
    <Name>RvtSamples External Application</Name>
    <Assembly>C:\...\Samples\RvtSamples\CS\bin\Debug\RvtSamples.dll</Assembly>
    <ClientId>42cb0a70-2ee7-4e64-a42d-87b9cdcc41c8</ClientId>
    <FullClassName>RvtSamples.Application</FullClassName>
    <VendorId>ADSK</VendorId>
    <VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
  </AddIn>
</RevitAddIns>

It needs to be copied to the Revit 2020 Add-Ins folder in order for Revit to pick it up and load it:

As usual, after that, a whole bunch of errors occur and need to be handled.

The first error I see says:

This and similar errors have shown up every single year and affect most of the VB.NET samples.

In this case, the RvtSamples.txt input file searches for:

This file does not exist. Instead, for some reason, the assembly DLL is located one level higher:

As a quick stop-gap fix, I globally replaced all occurrences of \VB.NET\bin\Debug* by \VB.NET\bin*. As you will notice later, some of these replacements were erroneous.

Next errors:

ElementViewer.dll really is located in the bin\debug subdirectory, so I changed that back again.

Hmmm. Fixed some of those...

Next test run...

Well, no wonder. The external command defined by the DatumsModification add-in is not named Command at all.

Instead, it defines three external commands named DatumStyleModification, DatumAlignment and DatumPropagation.

Therefore, the single erroneous entry for one external command for this add-in needs to be replaced by three new ones.

This sample can never have been loaded by RvtSamples.

Anyway, I fixed all the errors, it seems, and can now load RvtSamples and successfully process its input file in Revit 2020:

RvtSamples loaded all Revit 2020 external commands

Here are my versions of the files I modified to get it up and running, in case they are of use:

I wish you easy sailing, much fun and success setting up and exploring Revit 2020 yourself!