Get BIm 360 model's "absolute" path

Get BIm 360 model's "absolute" path

Anonymous
Not applicable
5,192 Views
17 Replies
Message 1 of 18

Get BIm 360 model's "absolute" path

Anonymous
Not applicable

Am I missing something or the file paths in BIM 360 are not showing the actual folder structure?

 

This is what my current model's path looks like in the APIs:

ATassera_0-1615877279453.png

 

and this is what it should look like:

ATassera_1-1615877335972.png

 

At the same time, the Saved Path of the links looks correct:

ATassera_2-1615877422031.png

 

I tried all the different combos including doc.GetCloudModelPath() and ModelPathUtils.ConvertCloudGUIDsToCloudPath(ProjectId, ModelId) but they all return an odd-looking string that resembles a URL (but isn't really a URL).

 

Am I missing something?

 

Cheers

0 Likes
5,193 Views
17 Replies
Replies (17)
Message 2 of 18

jeremy_tammik
Alumni
Alumni

Daer Andrea,

  

There is no such thing as an absolute path in this context.

 

We have no idea how this data is stored. 

 

It could be an object oriented database, a quantum computer, or something else.

 

It is guaranteed not to be stored in a standard operating system in a standard file system with a standard absolute path. Such a system would never be able to handle the amount of information that is pumped into a large cloud hosted service like BIM360.

 

All of those "paths" that you see are simply views into some storage facility that we know nothing about and need not know anything about.

 

The views may be designed to resemble file paths because that is a system that we have learned to use to manage hierarchically structured information.

 

All of the above is based on pure guesswork on my side, of course.

 

I know no more and probably less than you do about the internal workings of BIM360.

 

Cheers,

 

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 18

Sean_Page
Collaborator
Collaborator

Not sure what you may be trying to get to them for, but I have had good lucking using the doc pathname and files names to find the local cached files.

 

internal static string DocPath(Document doc)
        {
            if (doc.PathName.StartsWith("BIM 360://"))
            {
                string fileName = doc.WorksharingCentralGUID + ".rvt";
                string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                string collaborationDir = Path.Combine(localAppData, "Autodesk\\Revit\\Autodesk Revit " + doc.Application.VersionNumber, "CollaborationCache");
                string file = Directory.GetFiles(collaborationDir, fileName, SearchOption.AllDirectories).FirstOrDefault(x => new FileInfo(x).Directory?.Name != "CentralCache");
                return file;
            }
            else
            {
                return doc.PathName;
            }
        }
Sean Page, AIA, NCARB, LEED AP
Senionr Partner, Computational Designer, Architect
0 Likes
Message 4 of 18

jeremy_tammik
Alumni
Alumni

Oh, now I see what Andrea was after. Sorry, I misunderstood.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 18

Sean_Page
Collaborator
Collaborator

I just took a shot in the dark as to what he may be after Jeremy, just because I have lamented so many times over not being able to get to Cloud paths the way I would like. I too could be way off base as well!

Sean Page, AIA, NCARB, LEED AP
Senionr Partner, Computational Designer, Architect
0 Likes
Message 6 of 18

Anonymous
Not applicable

Thanks all for your replies! And sorry for not explaining the problem well.

 

The reason why I'm looking for the path is that I want to run some checks against the structure of the path (hub/folder/subfolder/file.rvt), for example: Is the person working on the right file? Is the file in the WIP folder? Is the linked file in the same folder/project of the current file?

So as an example I would like to get a path like BIM 360://000000_CoordinationSandbox/WIP/Architecture/FileName.rvt so that I can check that the string contains the substring WIP, that it contains 000000_CoordinationSandbox and that the structural files are not in the Architecture folder.

 

That's why I'm confused by how the linked files show a Saved Path (as in my bottom screenshot) that looks exactly like what I'm looking for, but I can't find a way to extract that info from the currently open file.

 

I hope it makes a bit more sense now?

0 Likes
Message 7 of 18

simonjones-uk
Contributor
Contributor

Thanks for the original code to determine the file in the local cache for cloud models. However, I found it only worked for WorkShared Cloud models - this is the revision to work also with non-workshared cloud models:

 

string localRevitFile = "";

// --- Add rvt, rfa or rte
mTitle = mDoc.Title + Path.GetExtension(mDoc.PathName);

if (mDoc.IsModelInCloud)
{
ModelPath modelPath = mDoc.GetCloudModelPath();
string guid = modelPath.GetModelGUID().ToString();
string folder = "C:\\Users\\" + Environment.UserName + "\\AppData\\Local\\Autodesk\\Revit\\Autodesk Revit " + mVersionNumber + "\\CollaborationCache";
string revitFile = guid + Path.GetExtension(mDoc.PathName);
string[] files = Directory.GetFiles(folder, revitFile, SearchOption.AllDirectories).Where(c => !c.Contains("CentralCache")).ToArray();
if (files.Length > 0)
{
localRevitFile = files[0];
}
else
{
MessageBox.Show("Unable to find local rvt for: " + mDoc.PathName);
}
}
else
{
localRevitFile = mDoc.PathName;
}

 

The key is to use modelPath.GetModelGUID() rather than doc.WorksharingCentralGUID - thanks @jeremy_tammik for pointing this function to me (apparently this has been there since 2019.1)....

0 Likes
Message 8 of 18

jeremy_tammik
Alumni
Alumni

Dear Simon,

 

Thank you very much for sharing that simple and effective solution.

 

I added it to The Building Coder samples to make it easy to keep track of:

 

https://github.com/jeremytammik/the_building_coder_samples/compare/2022.0.150.5...2022.0.150.6

 

Cheers,

 

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 9 of 18

jeremy_tammik
Alumni
Alumni
0 Likes
Message 10 of 18

serg-001
Participant
Participant

Hello,

 

Thank you for described approach.

 

I was able to get file name which is local cache of BIM360 rvt-model.

But when I try to open such files in Revit 2023, Revit hangs up.

Can it be fixed?

 

For one model Revit opened cached file without problems. But this started to happen when I modified the model in Revit and updated in the cloud.

But when I download modified model via BIM360 Web UI it can be opened in Revit 2023 without any problems (file downloaded from BIM360 via Web UI and local cache file are not identical)

 

Thank you

0 Likes
Message 11 of 18

serg-001
Participant
Participant

Hello,

 

In most cases which I tried with Revit 2022, 2023, 2024 I was not able to open cached RVT-files in Revit itself.

Cache files differ from original one (specifically in "BasicFileInfo" file inside RVT-file with GUIDs and some other bytes).

As a result Revit can't open such cache RVT-files anymore.


Sometimes cached files are the same as original one, in such cases Revit can open them. This occurs rarely, and I can't realise how to get such behavior stable.

It is possible to do something so that cached files can be opened in Revit?

 

Thanks.

0 Likes
Message 12 of 18

richard.laroche
Contributor
Contributor

Same problem here.
I don't need the path to my local file in C:\Users\xxx\AppData\Local\Autodesk\Revit\Autodesk Revit 2023\CollaborationCache\XYZ\ncas519l-k116-430i-b02d-qbp825e31fcd" (fake GUIDS)
I can find these files.
The problem I have is that I could have two files on the cloud with the same name, in different directories.
I want to know with one is in which directory in my cloud folders.
Problem is when I use  modelcloudpath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(region, projectguid, ModelGuid)
and
modelpathstr = ModelPathUtils.ConvertModelPathToUserVisiblePath(modelcloudpath)

I get:

richardlaroche_0-1727189642822.png

even though these two models are in different folders in my cloud:

richardlaroche_1-1727189712464.png

 

0 Likes
Message 13 of 18

priyali_muttepawar
Observer
Observer

Encounter similar issue where two files with the same name exist in different directories on the cloud. However, when I query the API for these files, it returns the same path for both, which does not provide information on which directory each file resides in. It is possible to do something so that we can get absolute path.

 

0 Likes
Message 14 of 18

priyali_muttepawar
Observer
Observer

any help on this?? i want Autodesk Docs Cloud path not the local path.

0 Likes
Message 15 of 18

Chuong.Ho
Advocate
Advocate

I remember I have a post was share the way to do it before :

https://chuongmep.com/posts/2022-04-14-Get-Path-Linked-BIM360-Dynamo-Revit.html#how-to-get-path-bim3...

To get the url from bim360 or acc, may be you need from document :

1. Get Cloud model urn (ItemId)

doc.GetCloudModelUrn()

2. Get Project id by use:

doc.GetProjectId()

 

3. Use API Autodesk Platform Services to get href and you can see the url at location : link-> webView -> href

{
    "jsonapi": {
        "version": "1.0"
    },
    "links": {
        "self": {
            "href": "https://developer.api.autodesk.com/data/v1/projects/b.799e4eaa-9b7b-4809-9ce0-7d487228c5ea/items/urn:adsk.wipprod:dm.lineage:TN8o6kdbSBKzGUqSnMqwBg"
        }
    },
    "data": {
        "type": "items",
        "id": "urn:adsk.wipprod:dm.lineage:TN8o6kdbSBKzGUqSnMqwBg",
        "attributes": {
            "displayName": "racbasicsampleproject2025.rvt",
            "createTime": "2025-03-10T08:10:57.0000000Z",
            "createUserId": "DUGSREM5LS6N",
            "createUserName": "Ho Van Chuong",
            "lastModifiedTime": "2025-03-10T08:11:19.0000000Z",
            "lastModifiedUserId": "DUGSREM5LS6N",
            "lastModifiedUserName": "Ho Van Chuong",
            "hidden": false,
            "reserved": false,
            "extension": {
                "type": "items:autodesk.bim360:C4RModel",
                "version": "1.0.0",
                "schema": {
                    "href": "https://developer.api.autodesk.com/schema/v1/versions/items:autodesk.bim360:C4RModel-1.0.0"
                },
                "data": {}
            }
        },
        "links": {
            "self": {
                "href": "https://developer.api.autodesk.com/data/v1/projects/b.799e4eaa-9b7b-4809-9ce0-7d487228c5ea/items/urn:adsk.wipprod:dm.lineage:TN8o6kdbSBKzGUqSnMqwBg"
            },
            "webView": {
                "href": "https://acc.autodesk.com/docs/files/projects/799e4eaa-9b7b-4809-9ce0-7d487228c5ea?folderUrn=urn%3Aadsk.wipprod%3Afs.folder%3Aco.rSfzce9rRBmWWIwpYVPCjA&entityId=urn%3Aadsk.wipprod%3Adm.lineage%3ATN8o6kdbSBKzGUqSnMqwBg"
            }
        },

 

Chuong Ho

EESignature

0 Likes
Message 16 of 18

ol.nistratov
Contributor
Contributor

Hey @jeremy_tammik,

 

Starting from Revit 2024 user is able to override default location of the Cloud model cache.  See Options Dialog: Cloud Model Tab

Is it possible to get overridden Cloud model cache location using Revit API from Options?

 

Thank you.

0 Likes
Message 17 of 18

jeremy_tammik
Alumni
Alumni

Dear Oleksandr,

  

I can't tell you offhand, so I asked the development team for you.

  

Cheers,

  

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 18 of 18

jeremy_tammik
Alumni
Alumni

Answer:

  

  • it is stored in Revit.ini
  • you can use external tools to read and modify it
  • Revit needs a restart for it to take effect when changed
  • it is not exposed in Revit API

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes