Search code examples
cloudautodesk-forgerevit-apiautodesk-bim360

How to find cloud Item id of a Revit model?


In our solution we need a reference between a Revit model and its presence in the cloud (BIM 360/Autodesk Construction Cloud).

In Revit we open a cloud model or save a model to the cloud (Save As cloud model). The rvt-file obviously "knows" where it is placed in the cloud but I see no way to extract that information from the file. The challenge is therefore to find the files Item id in the cloud.

Currently we do the following:

From the Revit document we get

  • CloudProjectName (extracted from Revit api Document.GetCloudModelPath())
  • ModelGuid (Revit api Document.GetModelGUID())

Then...

  1. Get the accounts for the user (Forge Datamanagement API https://developer.api.autodesk.com/project/v1/hubs)
  2. For each account: Iterate through projects to find project with the specified name. (Forge Datamanagement API https://developer.api.autodesk.com/project/v1/hubs/:hub_id/projects)
  3. If project found: Search root folder in project to find files with the specified ModelGuid (Forge Datamanagement API https://developer.api.autodesk.com/data/v1/projects/:project_id/folders/:folder_id/search?filter[attributes.extension.data.modelGuid]={ModelGuid})
  4. If 1 or more files found: Pick out the 'original' file. (relationships.item.data.id == attributes.extension.data.originalItemUrn)

(We do not care about the cloud model version).

This actually works, except step 3 can be a bit tricky. It takes several minutes, maybe hours, from the model is uploaded to the cloud until a search is possible which is quite annoying.

So here is two questions:

  1. Is there a better/easier way to find the cloud Item id of the file?
  2. Is there an alternative to the 'search' call (step 3) or at least some kind of documentation saying when a result can be expected to be available?

Solution

  • Which Revit version are you using? If Revit 2022, the new API Document.GetCloudModelUrn() in latest SDK 2022 should be the one you are looking for, and it also provides the following API for cloud info:

    Getting the Forge ID for a Model These methods allow you to identify the Forge IDs for Cloud Models:

    Document.GetHubId(): ForgeDM hub id where the model is located
    Document.GetProjectId(): ForgeDM project id where the model is located
    Document.GetCloudFolderId(bool forceRefresh): ForgeDM folder id where the model is located
    Document.GetCloudModelUrn(): A ForgeDM Urn identifying the model They return strings which will be empty for a document which is not a cloud model.
    

    Check details at https://help.autodesk.com/view/RVT/2022/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_Application_and_Document_CloudFiles_html and https://www.revitapidocs.com/2022/7c2bced8-b309-b67f-2b82-13299c617a0b.htm