Skip to main content

revit-context-menu

Add Autodesk Revit right-click context menu entries with the Nice3point.Revit.Extensions fluent API. USE FOR: registering context menu items, submenus, and separators bound to command classes during application startup. DO NOT USE FOR: ribbon panels and buttons (use revit-ribbon).

跳到安装

来源信息

仓库
Nice3point/revit-skills
最近来源活动
2026年7月20日 20:20
检测到的 SKILL.md 语言
英语
星标
13
分支
3

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
revit-context-menu
description
Add Autodesk Revit right-click context menu entries with the Nice3point.Revit.Extensions fluent API. USE FOR: registering context menu items, submenus, and separators bound to command classes during application startup. DO NOT USE FOR: ribbon panels and buttons (use revit-ribbon).
license
MIT
# Revit Context Menu `ConfigureContextMenu` (from `Nice3point.Revit.Extensions`) wraps the raw context-menu registration into a fluent call. Register the menu once during application startup. ## When to use - Adding entries to Revit's right-click context menu, bound to command classes. ## When not to use - Building ribbon panels and buttons — use `revit-ribbon`. ## Workflow ### Step 1: Configure the menu `AddMenuItem<TCommand>` binds a menu item to a command type; `AddSeparator` inserts a divider; `AddSubMenu` nests a `ContextMenu`. ```csharp application.ConfigureContextMenu(menu => { menu.AddMenuItem<AnalyzeCommand>("Analyze selection"); menu.AddSeparator(); var exportMenu = new ContextMenu(); exportMenu.AddMenuItem<ExportCommand>("Export selection"); menu.AddSubMenu("Export", exportMenu); }); ``` Use the `ConfigureContextMenu(title, configuration)` overload to title the menu group. ### Step 2: Verify Right-click in Revit and confirm the items and submenu appear and each invokes its command. ## Validation - [ ] The menu is configured once during application startup. - [ ] Items bind to command types via `AddMenuItem<TCommand>`. - [ ] Submenus are built as a `ContextMenu` and added with `AddSubMenu`. ## Common Pitfalls | Pitfall | Correct approach | |----------------------------------------------------|-------------------------------------------------------------------| | Registering context menu items through the raw API | Use `ConfigureContextMenu` with `AddMenuItem<TCommand>`. | | Expecting `AddSubMenu` to take a lambda | Build a `ContextMenu` and pass it to `AddSubMenu(name, subMenu)`. | | `ConfigureContextMenu` not found | The `Nice3point.Revit.Extensions` package is not referenced. |
在 GitHub 查看