Once again, I document my compilation, adaptation and installation of the Revit SDK samples and the RvtSamples external application loading them all:
RvtSamples.txt
Compiling the Revit SDK Samples updated for each new major release was once a major undertaking due to hundreds of compiler errors.
In the last couple of years, happily, it became much easier.
This time around, it was a bit trickier again.
Happily, I documented the hassle involved in compiling the initial Revit 2021 SDK samples in full detail and was able to quite easily repeat those steps.
The main problem is very basic and not hard to fix at all: the references to the Revit API assemblies in each of the 190 sample projects is set up for different developers' specific environments using local file paths instead of an absolute path.
All you need to do is to hunt them all down and point them all to the official Revit installation location C:\Program Files\Autodesk\Revit 2021.
This needs to be done not only in csproj
and vbproj
files, but also in target
ones.
Again, I copied the original state of the Revit 2021.1 SDK to the RevitSdkSamples GitHub repository before analysing the problem and applying the fixes, so you can easily retrace my steps or download the final results of my fixes and save yourself the effort of reinventing this particular wheel.
Here is a list of some of my commits, releases, and error logs:
I performed the following steps to locate the API assemblies and update the references to the Revit API assembly DLLs to point to the absolute Revit.exe folder:
HintPath
in SDKSamples.targetsHintPath
settings in individual project filesHintPath
in SDKSamples.VB.targetsHintPath
in SDKSamples.Steel.targetsThat enabled the first successful compilation, still producing a bunch of warnings, though:
Most of the warnings concern the ever-recurring architecture mismatch issue and can be resolved using my DisableMismatchWarning.exe utility implemented back in 2013 and available from the DisableMismatchWarning GitHub repository.
After that, I set up the RvtSamples external application to locate and load all the Revit SDK sample external commands:
Turned off RvtSamples external command class name test
Release 2021.0.0.2 – 190 projects succeeded, 0 errors and 5 warnings
I will leave the remaining five warnings in there for now.
One great advantage of the GitHub repository management is that you can very easily analyse the differences between the different releases to determine the exact changes that I applied, e.g., between 2021.1.0.0 and 2021.1.0.2.
One new SDK sample was added in the Revit 2021.1 SDK.
CivilAlignments implements an external command and an external application demonstrating the use of the API for finding, property querying and annotating of infrastructure alignment elements:
Instructions:
Open CivilAlignments_BridgeSample.rvt. It is a metric project, to demonstrate necessary unit conversions to feet. The project contains an alignment. The project also contains two special Arrowhead styles, Major Station Arrowhead and Minor Station Arrowhead, which are necessary for proper setup of the major and minor alignment station label set types. Other projects can be used, as long as they contain an alignment and have the aforementioned arrowhead styles defined.