Revit API ConvertCloudGUIDsToCloudPath调用异常问题求助
ConvertCloudGUIDsToCloudPath 异常问题排查 背景
多年在多版本Revit中使用ConvertCloudGUIDsToCloudPath方法,近期遇到无法解决的异常问题。测试环境覆盖本地Windows、多台Windows虚拟机及Design Automation应用包,涉及Revit 2020、2022、2023版本的ACC与BIM 360项目,测试过程中仅返回两种异常:CentralModelMissingException或RevitServerCommunicationException。
已解决问题:RevitServerCommunicationException
将区域字段从"CloudRegionUS"改为"US",或直接使用Revit API内置变量ModelPathUtils.CloudRegionUS,即可解决该异常,已修复Design Automation及宏代码中的对应问题。
未解决问题:CentralModelMissingException
该异常仍持续出现,不同版本环境下的异常信息如下:
- Revit 2020本地环境异常信息:
Autodesk.Revit.Exceptions.CentralModelMissingException: The central model is missing. at Autodesk.Revit.DB.ModelPathUtils.ConvertCloudGUIDsToCloudPath(Guid projectId, Guid modelId)
- Revit 2023本地环境异常堆栈信息:
Autodesk.Revit.Exceptions.CentralModelMissingException: The central model is missing.
at Autodesk.Revit.DB.ModelPathUtils.ConvertCloudGUIDsToCloudPath(String region, Guid projectGuid, Guid modelGuid)
at ..DocumentOpenFromCloud.Run()
at ...<>c__DisplayClass11_1.b__2()
at Revit.Async.RevitTask.<>c__DisplayClass20_0.b__0(UIApplication app)
at Revit.Async.Extensions.ExternalEventResultHandlerExtensions.Wait[TResult](IExternalEventResultHandler'1 resultHandler, Func'1 function)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Revit.Async.Entities.FutureExternalEvent.d__30'2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at ...d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at .<CUSTOM NAMESPACE 2>.'2.d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at .<CUSTOM NAMESPACE 3>.App.d__9.MoveNext()
关键信息说明
- 模型GUID与项目GUID均来自Data Management API的
GET projects/:project_id/folders/:folder_id/contents响应,分别对应included.attributes.extension.data.modelGuid和included.attributes.extension.data.projectGuid。 - Revit 2021+版本已按已解决问题的方法设置区域参数。
- 测试机器上的用户拥有对应项目的访问权限,API报错后可通过Revit UI正常打开目标模型。
宏代码测试补充
在Revit 2023、2024中通过宏复现并解决了RevitServerCommunicationException,但运行应用宏时仍出现异常。
文档宏代码
public void GetCloudGuids() { var modelPath = this.Document.GetCloudModelPath(); var projectGuid = modelPath.GetProjectGUID(); var modelGuid = modelPath.GetModelGUID(); string message = "Project GUID: " + projectGuid + "; Model GUID: " + modelGuid + "."; using (TextWriter tw = new StreamWriter("C:\\macro-tests\\cloud-guids.txt")) { tw.WriteLine(message); tw.Close(); } TaskDialog.Show("Model Cloud GUIDs", message); }
应用宏代码
public void OpenCloudModel() { // Issue 1, this was set to "CloudRegionUS" string region = ModelPathUtils.CloudRegionUS; var projectGuid = new Guid("<GUID copied from cloud-guids.txt>"); var modelGuid = new Guid("<GUID copied from cloud-guids.txt>"); try { var modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(region, projectGuid, modelGuid); TaskDialog.Show("Model Path", "Got model path."); if (modelPath.CloudPath) { using (var openOptions = new OpenOptions()) using (var worksetConfig = new WorksetConfiguration(WorksetConfigurationOption.OpenAllWorksets)) using (var defaultCallback = new DefaultOpenFromCloudCallback()) { openOptions.SetOpenWorksetsConfiguration(worksetConfig); var CurrentDocument = this.Application.OpenDocumentFile(modelPath, openOptions, defaultCallback); } } } catch (Exception ex) { using (TextWriter tw = new StreamWriter("C:\\macro-tests\\open-exception.txt")) { tw.WriteLine(ex.ToString()); tw.Close(); } TaskDialog.Show("Could not open cloud document", ex.Message); } }
应用宏异常文本
Autodesk.Revit.Exceptions.RevitServerCommunicationException: The central server could not be reached. at Autodesk.Revit.DB.ModelPathUtils.ConvertCloudGUIDsToCloudPath(String region, Guid projectGuid, Guid modelGuid) at CloudModels.ThisApplication.OpenCloudModel() in c:\ProgramData\Autodesk\Revit\Macros\2024\Revit\AppHookup\CloudModels\Source\CloudModels\ThisApplication.cs:line 48
疑问
ConvertCloudGUIDsToCloudPathAPI是否存在未公开的变更?- 是否存在Autodesk云服务中断情况?
内容的提问来源于stack exchange,提问作者Kristen Schulte

