【问题标题】:How to call revit API from external thread?如何从外部线程调用 revit API?
【发布时间】:2015-12-08 13:57:59
【问题描述】:


我在 revit 的测试项目中,
当我创建事务时,由于 ComponentManager.Ribbon 的按钮的“ComponentManager_UIElementActivated”,
我有异常“不允许从在 API 上下文之外运行的外部应用程序启动事务”。

你有解决办法吗?

void ComponentManager_UIElementActivated(
      object sender,<br>
      adWin.UIElementActivatedEventArgs e)
{
Transaction trans = new Transaction(uidoc.Document); //Work good.<br>
trans.Start("ReTraceWall"); //It don't work, because i have  exception "Starting a transaction from an external application running outside of API context is not allowed."<br>
CommandRetraceWall.retracewall(uidoc); //function not called because there is exception before<br>
  trans.Commit();<br>
}


*

感谢您的帮助。
你有解决这个问题的样品吗?
Sample using ComponentManager.Ribbon

【问题讨论】:

    标签: exception button transactions ribbon


    【解决方案1】:

    我不知道您使用的是哪个 Revit 版本,但在 this post 中描述了与您类似的问题。你基本上有两个选择:

    • 在 Idling 事件中轮询作业
    • 使用外部事件

    这里不再赘述。

    顺便说一句,在提问之前,请在论坛中快速搜索一下,因为您的论坛可能已经有了答案:)

    Jeremy Tammik 是 Revit API 专家,他有一个 entire blog,您可能会觉得它也很有用。

    【讨论】:

      猜你喜欢
      • 2016-10-24
      • 1970-01-01
      • 2021-02-17
      • 1970-01-01
      • 1970-01-01
      • 2020-06-17
      • 2019-08-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多