The Software Development Toolkit (SDK) provides extensive .NET code samples and documentation to help you get started developing with the Revit API.
$ dotnet add package Autodesk.Revit.Sdk.RefsRevit SDK refs assemblies.
Only metadata from assemblies by Refasmer.
Add project configurations with revit versions in name
<PropertyGroup>
<RevitVersion Condition="'$(RevitVersion)' == ''">2016</RevitVersion> <!-- set default revit version -->
<TargetFramework Condition="'$(TargetFramework)' == ''">net45</TargetFramework> <!-- set default target framework -->
<Configurations>Debug;Release;D2016;D2017;D2018;D2019;D2020;D2021;D2022;D2023;D2024;D2025;D2026</Configurations>
</PropertyGroup>
Add package reference
<ItemGroup>
<!-- package reference with revit dlls -->
<PackageReference Include="Autodesk.Revit.Sdk.Refs" Version="*" />
<PackageReference Include="Autodesk.Revit.Sdk.Refs.$(RevitVersion)" Version="*" />
</ItemGroup>
See sample project in this folder.
You should compile the Debug configuration.
Other configurations needs to help write code with constants.
dotnet build -c <Configuration> -p:RevitVersion=<RevitVersion>
DotNetBuild(s => s
.DisableNoRestore()
.SetProjectFile(<ProjectName>)
.SetConfiguration(<Configuration>)
.SetProperty("RevitVersion", (int) <RevitVersion>));
This constants defined to all supports revit version.
REVIT<RevitVersion>
REVIT<RevitVersion>_OR_GREATER
#if REVIT<RevitVersion>
// This code will be available for the specified version
#endif
#if REVIT<RevitVersion>_OR_GREATER
// This code will be available for all versions greater than specified
#endif