Files
2026-02-23 16:57:09 +08:00

58 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using System.Diagnostics;
using Autodesk.Windows;
namespace DotNet.Revit.InvokeCommand
{
[Transaction(TransactionMode.Manual)]
public class CmdInvoke : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
// 调用Look up Snoop Db
// Look up Snoop Db 命令Id通过下方执行下方命令CmdInvokeTest控制台输出查询。
InvokeHelper.Invoke("CustomCtrl_%CustomCtrl_%CustomCtrl_%Add-Ins%Revit Lookup%Options%Snoop Db..");
/* 调用右键菜单 - 区域放大
右键菜单的 命令Id 可在Revit日志内进行查询..*/
InvokeHelper.Invoke("ID_ZOOM_IN");
return Result.Succeeded;
}
}
[Transaction(TransactionMode.Manual)]
public class CmdInvokeTest : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
// 当命令控件点击执行后触发事件...
ComponentManager.ItemExecuted += ComponentManager_ItemExecuted;
return Result.Succeeded;
}
void ComponentManager_ItemExecuted(object sender, Autodesk.Internal.Windows.RibbonItemExecutedEventArgs e)
{
if (e.Item == null)
return;
// 获取命令Id
var id = UIFramework.ControlHelper.GetCommandId(e.Item);
Debug.WriteLine(string.Format("Text: {0} ID: {1}", e.Item.Text, id));
}
}
}