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