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