【问题标题】:Revit API AddInCommandBinding for ID_PROCESS_DROP用于 ID_PROCESS_DROP 的 Revit API AddInCommandBinding
【发布时间】:2014-08-03 08:49:01
【问题描述】:

我正在尝试将家庭的拖放绑定到项目中并禁用它。

我的代码基于 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!");
}

【问题讨论】:

    标签: c# api revit revit-api


    【解决方案1】:

    我认为您的方法(和类)可能需要是静态的 - 过去我曾在实例方法中发生过奇怪的事情。另外,我不确定您对该方法的实现究竟做了什么,但它可能需要返回一个 CommandData.Result 才能使命令完全完成

    【讨论】:

      【解决方案2】:

      试试这个

      dropBinding.Executed += dragDropDisable;
      

      【讨论】:

        猜你喜欢
        • 2020-04-20
        • 2020-12-06
        • 2017-01-14
        • 2016-10-24
        • 1970-01-01
        • 1970-01-01
        • 2023-03-22
        • 2020-06-19
        • 2013-01-07
        相关资源
        最近更新 更多