2014-06-12 74 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,以便命令完全完成