Tuna.Revit.Infrastructure
1.3.23
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Framework 4.5.2
This package targets .NET Framework 4.5.2. The package is compatible with this framework or higher.
dotnet add package Tuna.Revit.Infrastructure --version 1.3.23
NuGet\Install-Package Tuna.Revit.Infrastructure -Version 1.3.23
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="Tuna.Revit.Infrastructure" Version="1.3.23" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tuna.Revit.Infrastructure" Version="1.3.23" />
<PackageReference Include="Tuna.Revit.Infrastructure" />
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 Tuna.Revit.Infrastructure --version 1.3.23
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Tuna.Revit.Infrastructure, 1.3.23"
#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 Tuna.Revit.Infrastructure@1.3.23
#: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=Tuna.Revit.Infrastructure&version=1.3.23
#tool nuget:?package=Tuna.Revit.Infrastructure&version=1.3.23
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Tuna.Revit.Infrastructure
概述
Tuna.Revit.Infrastructure 提供构建 Revit 插件的基础设施与抽象,包括应用程序与命令的基类、命令上下文与执行结果、宿主应用上下文等,帮助你以一致的方式组织插件代码。
功能亮点
- TunaApplication:统一应用生命周期(OnStartup/OnShutdown),集成资源注入与 Host 维护
- TunaCommand:统一命令执行入口,内置可用性检查与结果处理
- CommandContext/DocumentContext:封装当前文档与 UI 上下文
- CommandResult 与辅助扩展:标准化返回状态、消息与元素集合
- HostApplication/HostApplicationContext:集中维护 UIControlledApplication/UIApplication/Application/文档集合
安装
- NuGet 包:
Tuna.Revit.Infrastructure - 可与
Tuna.Revit.Extensions一同使用,按需引用
快速上手
using Autodesk.Revit.UI;
using Tuna.Revit.Infrastructure.ApplicationServices;
using Tuna.Revit.Infrastructure.Commands;
namespace Samples
{
/// <summary>
/// 示例应用:继承 TunaApplication
/// </summary>
public class SampleApplication : TunaApplication
{
/// <summary>
/// 初始化组件(注册 Ribbon、外部事件等)
/// </summary>
public override void InitailizeComponents()
{
// 此处可进行菜单注册、事件初始化等
}
}
/// <summary>
/// 示例命令:继承 TunaCommand
/// </summary>
public class SampleCommand : TunaCommand
{
/// <summary>
/// 执行实际业务逻辑,并返回标准化结果
/// </summary>
public override CommandResult Execute()
{
// 使用 Host 与 CommandContext 访问当前应用与文档环境
// var doc = CommandContext.ActivedDocument?.Document;
return this.Succeeded();
}
/// <summary>
/// 可选:决定命令是否可用
/// </summary>
public override bool CanExecute() => true;
}
}
关键类型
- ApplicationServices
- HostApplication:维护全局应用实例列表与上下文
- HostApplicationContext:封装 UIControlledApplication/UIApplication/Application/文档集合
- ITunaApplication/ITunaApplicationIdentity:应用接口与标识
- Commands
- TunaCommand:命令基类,统一执行与可用性
- ICommandContext/IDocumentContextProvider:命令上下文接口
- CommandContext/DocumentContext:具体实现
- CommandResult/CommandResultExtensions:结果对象与 helper
在实际项目中,你只需继承 TunaApplication 与 TunaCommand,按需使用上下文与结果,即可快速搭建插件框架。
| 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. |
| .NET Framework | net452 is compatible. net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 is compatible. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.5.2
- Tuna.Runtime (>= 1.0.0.1)
-
.NETFramework 4.6
- Tuna.Runtime (>= 1.0.0.1)
-
.NETFramework 4.7
- Tuna.Runtime (>= 1.0.0.1)
-
.NETFramework 4.8
- Tuna.Runtime (>= 1.0.0.1)
-
net8.0-windows7.0
- Tuna.Runtime (>= 1.0.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.