17 Oct 2022

Design Automation API Supports Revit Cloud Model

We are thrilled to announce the release of Revit Cloud Model support for Design Automation API!

This is the feature that many customers have been waiting for. Till now, the access to Revit model through Design Automation was limited to a "published" model(s). You will need to "download/upload" a copy of .rvt file(s) to/from Design Automation environment in order for an add-in to process. With this enhancement, you are able to access a Revit model in the cloud directly, including both US and EMEA region. The enhancement works with both workshared and non-workshared cloud models. The supported versions are Revit 2022 and later.   

As to the Design Automation API, there is no changes for this enhancement. The main work that you would need to do is inside your Revit plugin. We list key points below:  

  • Open Revit Cloud Model

Directly opening a cloud model greatly simplifies the process of accessing a model. Instead of downloading a Revit model to the Revit Design Automation Engine by the input url, you simply pass the information including Region, ProjectGuid, ModelGuid from workitem, then open the Revit Cloud Model:            

        var cloudModelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(inputParams.Region, inputParams.ProjectGuid, inputParams.ModelGuid);
        Document doc = rvtApp.OpenDocumentFile(cloudModelPath, new OpenOptions());
  • Save Revit Cloud Model

Again, there is no need to upload the result Revit file to a storage by output url. You can use the following code to save the current modification to the Cloud Model directly: 

         if (doc.IsWorkshared) // work-shared/C4R model
         {
            SynchronizeWithCentralOptions swc = new SynchronizeWithCentralOptions();
            swc.SetRelinquishOptions(new RelinquishOptions(true));
            doc.SynchronizeWithCentral(new TransactWithCentralOptions(), swc);
         }
         else
         {
            // Single user cloud model
            doc.SaveCloudModel();
         }

Note: You can synchronize your change with central. But there is no Revit API to publish the workshared cloud model currently. If you need to publish, you can use Data Management API Publish Model Command. Check the workflow. We are going to show the details in the sample later.

  • Create Revit Cloud Model

You can create a new Revit workshared cloud model directly from Revit plugin. This will be very useful if you want to automate a setup process. The code snippet below demonstrates the usage. Note: Document.SaveAsCloudModel() supports Revit workshared cloud model since the version 2022.

         Document newDoc = data.RevitApp.NewProjectDocument(UnitSystem.Imperial);
         this.AddWalls(newDoc);
         var cloudModelLocation = CloudModelLocation.Parse("CloudModelLocation.json");
         newDoc.EnableWorksharing("Shared Levels and Grids", "Workset1");
         newDoc.SaveAsCloudModel(cloudModelLocation.AccountId, cloudModelLocation.ProjectId, cloudModelLocation.FolderId, "newRCWModel.rvt");

 

Besides the above changes that  you need to do within Revit plugin, to access cloud models using Design Automation, you need to provide the user context through a special workitem argument; adsk3LeggedToken, scope=code:all needs to be added to your authorization call (see the code snippet below). When this token is provided in the argument, the user context can be derived and the Revit Cloud Model APIs will be enabled within Design Automation.

        {
            inputXls: {
                url: "XXXXXXXXXX"
            },
            onComplete: {
                verb: "post",
                    url: designAutomation.webhook_url
            },
            adsk3LeggedToken: access_token
        }

 

Documentation

Github

This sample demonstrates the usage of Revit cloud model access through Design Automation. This is a modified version of the existing excel export/import sample that works with non-cloud model. We will blog about the details soon.    
 

If you have any questions, please contact us through our support channel

 

Related Article