autodesk-forgerevit-apiautodesk-designautomationautodesk-data-management

Revit API ConvertCloudGUIDsToCloudPath returns connection errors


There is a possibility this is an outage, but nothing is reported on the Autodesk health page at the time of this writing.

EDITED 3/6/2023 to separate the two different issues after solving 1 of 2.

I have used the Revit API method ConvertCloudGUIDsToCloudPath on multiple versions of Revit for years. Today I am experience problems with it that I can't overcome. I am testing in a local Windows environment, a couple of Windows virtual machines, and in a Design Automation app bundle. Testing has been done on ACC and BIM 360 projects in Revit versions 2020, 2022, and 2023.

In all tests today, one of two exceptions is returned, either CentralModelMissingException or RevitServerCommunicationException.

Issue 1, the RevitServerCommunicationException was solved by using "US" or the Revit API variable ModelPathUtils.CloudRegionUS instead of "CloudRegionUS" in the region field. Resolution of Issue 1 resolved by DesignAutomation problems, and the problems with the macro code below.

Issue 2, CentralModelMissingException is still outstanding

  1. example from Revit 2020 running on a local Windows machine

Autodesk.Revit.Exceptions.CentralModelMissingException: The central model is missing. at Autodesk.Revit.DB.ModelPathUtils.ConvertCloudGUIDsToCloudPath(Guid projectId, Guid modelId)

  1. example from Revit 2023 with stack trace, also on a local Windows machine

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().

Model GUIDs are coming from the Data Management API response to GET projects/:project_id/folders/:folder_id/contents, in the item's included.attributes.extension.data.modelGuid.

Project GUIDs are coming from included.attributes.extension.data.projectGuid from the same Data Management API response.

Region is set as described for Issue 1 resolution above when in Revit 2021+.

The user on the respective local or virtual Windows machine has access to the project, and the model can be opened via the Revit UI on the given machine shortly after the API failure message is thrown.

Edited to Add Macros. I have replicated (and solved) Issue 1 in Revit 2023 and 2024 with a pair of macros. On the Document macro, I get the GUIDs from an open cloud model (An Autodesk sample model saved a cloud model in an ACC project, then collaboration enabled). After closing the sample model, I run the Application macro to try to re-open it via the API. Consistently getting the exception below.

Document Macro Code

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);
}

Application Macro Code

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);
    }
}

Exception Text

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

Has something changed about the APIs? Is there an outage?


Solution

  • Issue 1 Answer

    Instead of using a string for region "CloudRegionUS", use the API variable ModelPathUtils.CloudRegionUS. The variable's string value is actually "US". This seems to have been the issue.

    I'm not sure when this changed. A few months ago the longer string value above worked just fine. However, using the variable or the shorter "US" string now works. I will implement the API variable since it will probably be more stable over time.

    Issue 2 Answer

    We had an application that was mistakenly sending the wrong project identifier as the Project GUID.