问题处理
在子窗体创建外部事件会报错,只能在父窗体创建然后传入子窗体。
使用外部事件和外部命令的时候需要revitAPI提供的外部环境,在调用子界面的时候继承IExternalCommand的类可能结束了。
解释
API events - behavioral change
Although the Revit API has never officially supported such a work-flow it is now enforced that registering to and unregistering from events must happen while executing on the main thread. An exception will be thrown if an external application attempts to register to (or unregister from) events from outside of valid API context.
在以前的Revit版本中, 我们可以在一个非模态对话框中注册或者注销一个事件,但是Revit 2016做了一些改变,不再允许这样做,凡是在非Revit主线程里面的注册或者注销事件,系统会抛出异常,如果您没有捕获这个异常,将会导致系统崩溃。
使用模态对话框,或者尽量保证事件在ExternalCommand的Execute函数或者ExternalApplication的OnStartup函数里面注册。
如果一定要使用非模态对话框,那么请使用ExternalEvent事件的Raise函数,强迫程序进入Revit主线程,然后在里面进行注册事件。
下面是一些废话,因为csdn需要至少10行10个字
下面是一些废话,因为csdn需要至少10行10个字
下面是一些废话,因为csdn需要至少10行10个字
下面是一些废话,因为csdn需要至少10行10个字
下面是一些废话,因为csdn需要至少10行10个字
7925bac8-0597-4fbf-8d23-8b2762e91338