如何诊断Design Automation加载Revit文档时的‘内部错误’?
问题描述
我有一款适配Revit 2023的插件,可在Design Automation中正常运行,但部分输入文件会触发如下错误:
[05/17/2023 21:59:55] Initialize and get RCE: (VersionBuild) 23.1.20.50 (VersionNumber) 2023 (SubVersionNumber) 2023.1.20 [05/17/2023 22:00:08] Autodesk.Revit.Exceptions.InternalException: An internal error has occurred. [05/17/2023 22:00:08] at Autodesk.Revit.ApplicationServices.Application.OpenDocumentFile(ModelPath modelPath, OpenOptions openOptions) [05/17/2023 22:00:08] at DesignAutomationFramework.DesignAutomationData..ctor(Application revitApp, String mainModelPath) [05/17/2023 22:00:08] at DesignAutomationFramework.DesignAutomationReadyEventArgs..ctor(Application revitApp, String mainModelPath) [05/17/2023 22:00:08] at DesignAutomationFramework.DesignAutomationBridge.SetDesignAutomationReady(Application revitApp, String mainModelPath) [05/17/2023 22:00:08] at RevitCoreEngineTest.RceConsoleApplication.Program.UserMain(CommandLineArgs cl) [05/17/2023 22:00:14] RESULT: Failure - Result of running user app is failure [05/17/2023 22:00:14] Finished running. Process will return: TestError [05/17/2023 22:00:14] ====== Revit finished running: revitcoreconsole ====== [05/17/2023 22:00:16] End Revit Core Engine standard output dump. [05/17/2023 22:00:16] Error: Application revitcoreconsole.exe exits with code 4 which indicates an error. [05/17/2023 22:00:16] End script phase. [05/17/2023 22:00:16] Error: An unexpected error happened during phase CoreEngineExecution of job. [05/17/2023 22:00:17] Job finished with result FailedExecution
这些文件可在桌面版Revit 2023中正常加载,请问排查该问题的最佳方式是什么?
排查步骤
- 检查文件依赖与链接:Design Automation环境无桌面交互,部分文件可能依赖外部资源(如CAD链接、族库),桌面版会自动处理或提示,但Revit Core Engine(RCE)可能因找不到依赖直接报错。需确保所有外部资源已打包上传,或在代码中设置正确的路径映射。
- 启用详细日志:在Design Automation作业中开启Revit详细日志,通过添加
/l参数指定日志文件路径,日志会包含文件加载时的具体错误细节,比如缺失的族、损坏的元素等。 - 模拟RCE环境测试:在本地使用
revitcoreconsole.exe(Revit安装目录下的工具)加载问题文件,模拟Design Automation的无界面环境,可在本地复现错误,避免反复提交作业调试。 - 检查文件版本兼容性:确认问题文件是否由更高版本Revit创建后保存为2023格式,或包含2023.1.20版本不支持的新特性。桌面版Revit可能向下兼容,但RCE对版本特性的支持更严格。
- 修复隐性文件损坏:即使桌面版能打开,部分文件可能存在隐性损坏。在桌面版中执行
文件 -> 另存为 -> 清理旧版本,或运行审核 -> 检查模型修复潜在问题后,再上传到Design Automation测试。 - 捕获并处理异常:在插件代码中对
OpenDocumentFile方法添加异常捕获,尝试使用不同的OpenOptions(如忽略警告、跳过损坏元素),并记录详细的异常信息,帮助定位问题。
内容的提问来源于stack exchange,提问作者Tim Jones
相关产品推荐
相关产品推荐

