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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VolocyNazad.Revit.Context" Version="2025.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VolocyNazad.Revit.Context" Version="2025.0.9" />
                    
Directory.Packages.props
<PackageReference Include="VolocyNazad.Revit.Context" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VolocyNazad.Revit.Context --version 2025.0.9
                    
#r "nuget: VolocyNazad.Revit.Context, 2025.0.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VolocyNazad.Revit.Context@2025.0.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VolocyNazad.Revit.Context&version=2025.0.9
                    
Install as a Cake Addin
#tool nuget:?package=VolocyNazad.Revit.Context&version=2025.0.9
                    
Install as a Cake Tool

Revit.Context

Revit 2021.1.9, 2023, 2025 License: MIT VolocyNazad

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 the ApplicationInitialized event so that Application and 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 Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed