Compiling the Revit 2023 SDK Samples

The first thing I do after installing the new release of Revit is compile the Revit SDK and set up RvtSamples to load the external commands. So, here we go again:

Update the RevitSdkSamples Repo

I installed the new SDK and performed a pretty exhaustive comparison with the previous version to ensure that I do not overwrite anything important in the RevitSdkSamples repository.

The advantage of maintaining a public repository for this is that changes can easily be tracked and I can share the steps that I take to compile the SDK samples and set up RvtSamples to load them.

I enjoyed the support and conversation with jmcouffin during this process, in his pull request #1 2023SDK samples. That was the first time anyone offered to help with this repository, by the way, so thank you very much indeed for that!

I compiled diff_2022_2023.txt listing the differences between the Revit 2023 SDK samples and previous versions, both in the directory structure and individual files.

Afaict from that analysis, three new samples were added:

We need to take a look at those asap. First things first, though: compile the SDK and set up RvtSamples.

Set the Revit API References

The first attempt at compiling SDKSamples.sln right out of the box produced 9544 error and 1168 warnings; the namespace Autodesk could not be found.

SDKSamples includes 199 solution projects, and I am not going to edit their references one by one, so I need to implement a batch update somehow.

Luckily, there is no need to do so either; searching globally for RevitAPI.dll, I find only 8 occurrences, in the targets files in the VSProps folder and in the ContextualAnalyticalModel.csproj. Apparently, the latter is an exception.

I ended up fixing the Revit API references by replacing variable expressions by a constant C:\Program Files\Autodesk\Revit 2023 in the following files:

With those modifications, I was able to successfully compile all 199 projects with zero errors.

Eliminate Processor Architecture Mismatch Warning

95 warnings remain. Most of those concern the everlasting processor architecture mismatch, e.g.:

I mentioned this warning when it appeared and have been fixing it in every release ever since:

I implemented the DisableMismatchWarning utility to help me do so, and make use of that now as well:

After running that over all samples, only 6 warnings remain.

Missing XML Comments

Two of the remaining six warnings are easy to fix, so let's do so:

I simply added placeholder XML documentation to both methods.

Targets and Rule Sets

The four remaining warnings seem unimportant and can be ignored:

Set Up RvtSamples

I added my local system path Y:/a/src/rvt/RevitSdkSamples/SDK/Samples/ in both RvtSamples.addin and RvtSamples.txt.

Some add-in file paths are not found, so I set the debugging flag in RvtSamples Application.cs:

  bool testClassName = true; // jeremy

The culprits are the usual suspects, all of them VB.NET samples, but strangely enough not all VB.NET samples, cf. revit_2023_sdk_samples_errors_warnings_2.txt.

DatumsModification Commands

RvtSamples.txt erroneously listed an external command named Command for the DatumsModification SDK sample. In fact, it defines no such command; instead, it implements three others:

I updated RvtSamples.txt accordingly.

ContextualAnalyticalModel Commands

ContextualAnalyticalModel defines 15 external commands:

RvtSamples.txt erroneously lists three others: AddRelation, UpdateRelation and BreakRelation.

I replaced them by AddAssociation and RemoveAssociation.

CivilAlignments Commands

The CivilAlignments sample defines two commands and tries to create menu entries named "Infrastructure Alignments" or both of them.

This causes Revit to throw an exception.

I fixed that by naming them 'Infrastructure Alignments CreateAlignmentStationLabelsCmd' and 'Infrastructure Alignments ShowPropertiesCmd', respectively.

Conclusion

I finished off by resetting the testClassName debug switch and creating the final RevitSdkSamples release 2023.0.0.3.

RvtSamples 2023