我正在尝试将一个族的拖/放绑定(bind)到项目中并禁用它。
我的代码基于 Revit 2014 SDK 示例 DisableCommand
我的代码有 .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!");
}
最佳答案
我认为您的方法(和类)可能需要是静态的——我过去曾遇到过实例方法发生过奇怪的事情。此外,我不确定您对该方法的实现究竟做了什么,但它可能需要返回一个 CommandData.Result 才能使命令完全完成
关于c# - ID_PROCESS_DROP 的 Revit API AddInCommandBinding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24194379/