一.起因 自己在写revit二开时,有一个Winform窗体按钮点击事件需要 触发调用事务进行处理,结果出现“异常“Starting a transaction from an external application running outside of API context is not allowe“” 其实这是 上面异常是Revit的一种保护机制,创建的非模态对话框Form1后,在Form1未关闭的状态下,Revit认为是处于非API的上下文环境,所以异常弹出来了. 在非模态对话…
不能在revit提供的api外部使用事务,解决此方法, 1.把button里要实现的功能写到外部事件IExternalEventHandler中,注册外部事件,在button事件中.raise()使用. public class NewWall : IExternalEventHandler { public void Execute(UIApplication app) { “”比如说创建墙的代码” } public stri…