2014-06-12 38 views
2

我试图将一个家族的拖放操作绑定到项目中并将其禁用。Revit API AddInCommandBinding for ID_PROCESS_DROP

我的代码是基于的Revit 2014 SDK示例DisableCommand

我的代码有.CanHaveBinding测试和我有一个显示成功或失败的对话框。当我运行命令时显示成功,但我仍然可以拖放drop family。有任何想法吗?

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!"); 
} 

回答

0

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