Revit API AddInCommandBinding for ID_PROCESS_DROP

本文关键字:PROCESS DROP ID for API AddInCommandBinding Revit | 更新日期: 2023-09-27 18:08:28

我试图将一个家庭的拖放绑定到项目中并禁用它。

我的代码是基于Revit 2014 SDK样本禁用命令

我的代码有。canhavebinding测试,我有一个显示成功或失败的对话框。当我运行命令时,它显示成功,但我仍然可以拖放家庭。什么好主意吗?

RevitCommandId commandId2 = RevitCommandId.LookupCommandId("ID_PROCESS_DROP"); 
    if (!commandId2.CanHaveBinding)
    {
        TaskDialog.Show("Error", "Drag/Drop cannot be overridden.");
    }
    else
    {
        TaskDialog.Show("Success", "Drag/Drop can be overridden.");
    }
try
{
    AddInCommandBinding dropBinding = uiapp.CreateAddInCommandBinding(commandId2);
    dropBinding.Executed += new EventHandler<Autodesk.Revit.UI.Events.ExecutedEventArgs>(dragDropDisable);
}
catch (Exception ex)
{
     Console.WriteLine("Error: {0}",ex.ToString());
}
    private void dragDropDisable( object sender, Autodesk.Revit.UI.Events.ExecutedEventArgs args)
{
TaskDialog.Show("Disabled", "Never Drag/Drop families into your project!");
}

Revit API AddInCommandBinding for ID_PROCESS_DROP

我认为你的方法(和类)可能需要是静态的-我有奇怪的事情发生与实例方法在过去。此外,我不确定你的方法的实现究竟是什么,但它可能需要返回一个CommandData。结果,以便命令完全完成

试试这个

dropBinding.Executed += dragDropDisable;