VolocyNazad.Revit.Context
2025.0.9
dotnet add package VolocyNazad.Revit.Context --version 2025.0.9
NuGet\Install-Package VolocyNazad.Revit.Context -Version 2025.0.9
<PackageReference Include="VolocyNazad.Revit.Context" Version="2025.0.9" />
<PackageVersion Include="VolocyNazad.Revit.Context" Version="2025.0.9" />
<PackageReference Include="VolocyNazad.Revit.Context" />
paket add VolocyNazad.Revit.Context --version 2025.0.9
#r "nuget: VolocyNazad.Revit.Context, 2025.0.9"
#:package VolocyNazad.Revit.Context@2025.0.9
#addin nuget:?package=VolocyNazad.Revit.Context&version=2025.0.9
#tool nuget:?package=VolocyNazad.Revit.Context&version=2025.0.9
Revit.Context
An implementation of the Context Object pattern for convenient access to Revit API context objects.
Revit.Context is a set of services for accessing the Revit API context with support for DI containerization.
Features
IRevitContext— an interface for accessing Revit API context objects:UIControlledApplication,ControlledApplication,Application,UIApplication,ActiveUIDocument,ActiveDocument.IRevitContextInitializer— an interface for initializing the context during add-in startup (OnStartup).RevitContext— the single implementation of both interfaces; it tracks theApplicationInitializedevent so thatApplicationand its derived properties (UIApplication,ActiveUIDocument,ActiveDocument) become available right after Revit starts, not only after a document is opened.- One-line DI registration via
AddRevitContext().
Installation
dotnet add package VolocyNazad.Revit.Context
Usage
Registering services in the DI container:
using Microsoft.Extensions.DependencyInjection;
using Revit.Context.DI;
services.AddRevitContext();
Initialization in IExternalApplication.OnStartup:
using Autodesk.Revit.UI;
using Revit.Context.Abstractions.Services;
public Result OnStartup(UIControlledApplication application)
{
var initializer = serviceProvider.GetRequiredService<IRevitContextInitializer>();
initializer.Initialize(application);
return Result.Succeeded;
}
Using the context in any service:
using Revit.Context.Abstractions.Services;
public sealed class MyService(IRevitContext context)
{
public void DoSomething()
{
var doc = context.ActiveDocument;
var uiApp = context.UIApplication;
// ...
}
}
Supported Revit versions
The package is built and tested for Revit 2021.1.9, 2023.0.0, and 2025.0.0. Revit 2021 and 2023 target net48; Revit 2025 targets net8.0-windows.
Requirements
- .NET SDK 10.0.103+ (see
global.json) - Revit API (package
Revit_All_Main_Versions_API_x64)
License
MIT, see LICENSE.md.
Development documentation
Contributing
Read CONTRIBUTING.md before submitting changes.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
-
net8.0-windows7.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.11)
- Revit_All_Main_Versions_API_x64 (>= 2025.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on VolocyNazad.Revit.Context:
| Package | Downloads |
|---|---|
|
VolocyNazad.Revit.TransactionMemoryCache
Revit transaction cache management. |
|
|
VolocyNazad.Revit.MediatR
Revit MediatR. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2025.0.9 | 103 | 9/14/2026 |
| 2025.0.8 | 132 | 9/6/2026 |
| 2025.0.7 | 143 | 8/13/2026 |
| 2025.0.6 | 145 | 6/11/2026 |
| 2025.0.5 | 130 | 6/8/2026 |
| 2023.0.9 | 101 | 9/14/2026 |
| 2023.0.8 | 128 | 9/6/2026 |
| 2023.0.7 | 127 | 8/13/2026 |
| 2023.0.6 | 143 | 6/11/2026 |
| 2023.0.5 | 118 | 6/8/2026 |
| 2021.0.9 | 95 | 9/14/2026 |
| 2021.0.8 | 124 | 9/6/2026 |
| 2021.0.7 | 125 | 8/13/2026 |
| 2021.0.6 | 157 | 6/11/2026 |
| 2021.0.5 | 128 | 6/8/2026 |