1

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?

3 Answers3

2

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

Zhong Wu
  • 1,721
  • 1
  • 8
  • 9
  • Thanks. Looks like (haven't tried yet) these methods will solve our issues for Revit 2022 and future versions. But we _do_ need to support versions 2019-21 as well. This leads me back to the second part of my question about the delay between the time a model is uploaded and the time a search result is available (see step 3 in the original post). Is this expected behavior? And how long a delay should we expect? – Henrik Skov Oct 21 '21 at 11:09
  • For the previous Revit version, unfortunately I don't know an easy way to get the model urn, but can you use filter[id] to find the project directly? If not, I think the way you are currently using should be the right direction. – Zhong Wu Oct 21 '21 at 15:51
  • I will accept this as an answer (not the answer I had hoped for). But the questions about the 'Search' endpoint has not been answered, I have posted a separate question 'bout that: ['Search' endpoint seems unstable](https://stackoverflow.com/questions/69770064/search-endpoint-seems-unstable). – Henrik Skov Oct 29 '21 at 13:50
0

Your approach is a bit too complex for me to grasp at a glance. without having tried to achieve the same myself. Anyway, The Building Coder discussed how to Determine Cloud Model Local File Path and mentions some similar steps to yours. Maybe that can provide some further hints. Searching here for Revit model cloud turns up numerous other related threads.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
  • Yes, it is complex. In more plain words: If I open a rvt from disk I can get the exact path using Document.PathName. When I open a cloud model - what should I do to get the exact path in the Autodesk cloud? (Thanks for the proposed links - unfortunately it didn't get me any further) – Henrik Skov Sep 21 '21 at 11:18
  • I am [checking](https://autodesk.slack.com/archives/C0PLC20PP/p1632234043082500) with the development team for you. – Jeremy Tammik Sep 21 '21 at 14:21
0

Use the ModelPath methods GetModelGUID and GetProjectGUID. You can go 'backward' from the model and go up the tree until you hit the Project File or the project Top Folder. If the user does not have full visibility, the parent folder may not be accessible to a specific user. Read more under GET projects/:project_id/items/:item_id/parent.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
  • Maybe I am missing something obvious, but I do not see the light yet. In my example the GetModelGUID() and GetProjectGUID() methods returns the GUIDS {eaa2e583-e862-4fd4-832c-0fd5255ef83a} and {6251f01d-03f9-4165-81f5-220420016eaa} respectively. What i need to call the mentioned "parent" endpoint is "b.a53dd7f7-0d33-4cd1-924d-31fb16224018" as project_id and "urn:adsk.wipprod:dm.lineage:2DQg9m2sSgqn2AN7cXNuIg" as item_id. I don't see how to get from the GUIDs to those. (These are in fact the values I am trying to find). – Henrik Skov Sep 23 '21 at 11:21
  • ok, i see; I am checking further for you... – Jeremy Tammik Sep 24 '21 at 12:18
  • Any news from the development team? – Henrik Skov Oct 06 '21 at 10:41
  • Re-prompting them for a response... – Jeremy Tammik Oct 20 '21 at 09:38