Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get BIm 360 model's "absolute" path

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
2423 Views, 11 Replies

Get BIm 360 model's "absolute" path

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

11 REPLIES 11
Message 2 of 12
jeremy_tammik
in reply to: Anonymous

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
Message 3 of 12
Sean_Page
in reply to: Anonymous

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
Partner, Computational Designer, Architect
Message 4 of 12
jeremy_tammik
in reply to: Sean_Page

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
Message 5 of 12
Sean_Page
in reply to: jeremy_tammik

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
Partner, Computational Designer, Architect
Message 6 of 12
Anonymous
in reply to: Anonymous

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?

Message 7 of 12
simonjones-uk
in reply to: Anonymous

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)....

Message 8 of 12

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
Message 9 of 12
jeremy_tammik
in reply to: Anonymous

Message 10 of 12
serg-001
in reply to: Anonymous

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

Message 11 of 12
serg-001
in reply to: Anonymous

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.

Message 12 of 12
richard.laroche
in reply to: Anonymous

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report