Revit 2021 Cloud Model API

A nice big egg has been laid just in time for Easter, with the beautiful springtime in full bloom:

Revit 2021

Revit 2021 has now been released with numerous powerful new features.

The corresponding Revit 2021 SDK is available from the Revit Developer Centre:

BIM 360 Docs Folder Permission API

Before we dive into one of the important Revit 2021 API enhancements, here is a brief note to point out that the BIM 360 Docs Folder Permission API has been released.

Revit 2021 Multi-Region Cloud Model API

I am honoured and grateful to present the following explanation of how to use the updated Revit 2021 Cloud Model API with multi-region projects and models by Phil Xia, Team Manager, Autodesk.

Revit 2021 includes support for multi-region cloud models.

Autodesk provides two different BIM 360 web portals and regions with different URLs for that:

Now you can save your Revit cloud models to either of these two.

Cloud Model API

Revit 2021 combines the BIM 360 accounts of the current login user from different regions together in all cloud models entrances:

So, Revit users can create (upload and saveas) cloud models, authoring models from different regions in one Revit session.

Cloud Model API Changes

The new ModelPath property Region returns the region of the BIM 360 account and project which contains this model.

Cloud Model API changes:

How to Open a Cloud Model

The region argument for ConvertCloudGUIDsToCloudPath is a string type and should be either "US" or "EMEA", depending on which BIM 360 region account and project the model is stored in.

Depending on where the cloud model is stored, provide the appropriate region argument "US" or "EMEA", respectively.

To convert a valid CloudPath with the Revit API call ModelPathUtils.ConvertCloudGUIDsToCloudPath, you need to register a Forge application and use the Forge Data Management API to get the project Guid and model Guid as the two other arguments.

The Forge DM API reference on GET hubs shows how to list the hubs your Forge application can access.

Here is the response body of the list hubs API:

  {
    "type": "hubs",
    "id": "b.6bdabd18-6096-492b-966e-86492a4bb660",
    "attributes": {
      "name": "Wookong_EU",
      "extension": {
        "type": "hubs:autodesk.bim360:Account",
        "version": "1.0",
        "schema": {
          "href": "https://developer.api.autodesk.com/schema/v1/versions/hubs:autodesk.bim360:Account-1.0"
        },
        "data": {}
      },
      "region": "EMEA"
    },
    "links": {
      "self": {
        "href": "https://developer.api.autodesk.com/project/v1/hubs/b.6bdabd18-6096-492b-966e-86492a4bb660"
      }
    },
    "relationships": {
      "projects": {
        "links": {
          "related": {
            "href": "http://developer.api.autodesk.com/dm/v1/hubs/b.6bdabd18-6096-492b-966e-86492a4bb660/projects"
          }
        }
      }
    }
  }

You can filter out the BIM 360 accounts of interest using the data.attributes.name field. You can also get the region information here; "EMEA" in this case.

The Forge DM API reference on GET project folder contents shows how to list the folder contents you plan to open.

The response body looks like this:

  "included": [
    {
      "type": "versions",
      "id": "urn:adsk.wipbimemeastg:fs.file:vf.VFlOMhozRMac61hJ1JB_Nw?version=1",
      "attributes": {
        "name": "C4R_12_11_2019_10_01_14 AM_28.rvt",
        "displayName": "C4R_12_11_2019_10_01_14 AM_28.rvt",
        "createTime": "2019-12-11T10:01:44.0000000Z",
        "createUserId": "YZVYJQWWAJ89",
        "createUserName": "Phil Xia",
        "lastModifiedTime": "2019-12-11T10:01:47.0000000Z",
        "lastModifiedUserId": "YZVYJQWWAJ89",
        "lastModifiedUserName": "Phil Xia",
        "versionNumber": 1,
        "mimeType": "application/vnd.autodesk.r360",
        "extension": {
          "type": "versions:autodesk.bim360:C4RModel",
          "version": "1.1.0",
          "schema": {
            "href": "https://developer.api.autodesk.com/schema/v1/versions/versions:autodesk.bim360:C4RModel-1.1.0"
          },
          "data": {
            "modelVersion": 3,
            "projectGuid": "fd1335eb-733b-480c-9d16-1a22e742ef70",
            "modelType": "singleuser",
            "latestEpisodeGuid": "11da0d90-e1bb-492a-b90e-f3759ca6ab39",
            "mimeType": "application/vnd.autodesk.r360",
            "modelGuid": "e5a59497-0d79-4df0-879d-396310288bb0",
            "processState": "PROCESSING_COMPLETE",
            "extractionState": "SKIPPED",
            "splittingState": "NOT_SPLIT",
            "revisionDisplayLabel": "1",
            "sourceFileName": "C4R_12_11_2019_10_01_14 AM_28.rvt"
          }
        }
      },

You can filter out the relevant cloud model using the included.attributes.name field; the project Guid and model Guid information is provided in the included.attributes.extension.data field.

With these three pieces of information – region, project guid and model guid – you can convert a valid cloud path with the new ModelPathUtils.ConvertCloudGUIDsToCloudPath method and then open the model with the OpenDocument or OpenAndActivateDocument methods.

How to Save a Local File to a Non-Workshared Cloud Model

To save a local Revit file to the cloud as a non-workshared cloud model, you need to get the BIM 360 account id, BIM 360 project id, BIM 360 folder id, and a model name. There are two ways to retrieve this information:

  1. From the web browser
  2. Using the Forge DM API

SaveAsCloudModel Information in Web Browser

Open a web browser, navigate to your BIM 360 project home page and copy the highlighted URL:

Cloud Model API

The BIM 360 account id and project id are both GUID strings.

They can be extracted from the URL like this:

Cloud Model API

Navigate to your target BIM 360 Docs folder in the web browser and copy the highlighted URL:

Cloud Model API

The BIM 360 folder id is embedded in this URL; in this example, it is "urn:adsk.wipemea:fs.folder:co.Jo68ieLRRcKvQr4fI2Q8uQ":

Cloud Model API

With this information, you can save a local file which is opened in Revit to BIM 360 document management as a cloud model with a call like this:

  Guid account = new Guid("a8d3b76e-cf23-4dd7-a090-9e893efcf949");
  Guid project = new Guid("bf46f5e3-285e-496f-be03-b5b1f8b1e154");
  string folder_id = "urn:adsk.wipemea:fs.folder:co.Jo68ieLRRcKvQr4fI2Q8uQ";
  string model_name = "rac_advanced_sample_project.rvt";

  currentDocument.SaveAsCloudModel(
    account, // BIM 360 account id
    project, // BIM 360 project id
    folder_id, // BIM 360 folder id
    model_name // model name
);

SaveAsCloudModel Information with Forge DM API

With your Forge application, you can:

With this information, you can save a local file opened in Revit to BIM 360 document management as a cloud model using the same Revit API call as above.

Many thanks to the BIM 360 and Revit development teams for all their work on this and to Phil for putting together the valuable overview!

Easter bunny