Problem getting cloud path from files in BIM360

Problem getting cloud path from files in BIM360

edfdiloreto
Contributor Contributor
3,031 Views
36 Replies
Message 1 of 37

Problem getting cloud path from files in BIM360

edfdiloreto
Contributor
Contributor

I'm using Revit 2022 API and this method to get the cloud path: 

 

ModelPathUtils.ConvertCloudGUIDsToCloudPath("US", "projectGuid", "modelGuid")

 

This is working well with files that were collaborated by my team via Revit. The problem is with the files that are consumed through design collaboration (package consumption in BIM360). I'm getting this error:

Exception: You are unauthorized to access this hub/project or the hub/project doesn't exist. Detail is Haven't found the cloud model.
Please check if your cloud folder is accessible and if the model exists or not.

 

What could be the error? This process works manually...

 

Thanks!

0 Likes
3,032 Views
36 Replies
Replies (36)
Message 21 of 37

Messi_Hu
Autodesk
Autodesk

I know your workaround, then is it acceptable to you all to use the tip version of rcm model or you must depend on that sepcific version in consum folder?

 

BTW, the essential reason of getting the cloud model path is not you are admin, the essential reason is Admin has full permission for that model located folder.

0 Likes
Message 22 of 37

Messi_Hu
Autodesk
Autodesk

remove duplicated answer,

 

0 Likes
Message 23 of 37

edfdiloreto
Contributor
Contributor
Understood! So the person must have permissions to the folder where is located the "real" rcm model?
0 Likes
Message 24 of 37

edfdiloreto
Contributor
Contributor

I have anoher issue when the plugin is working. Let's say I want to link this model that is in this folder:
Model to link.png

 

 

 

 

 

When I link it manually I can see the full path, but when I use the plugin the path point to the source file folder, instead of the consumed folder.

 

Correct Path.pngOther Path.png

0 Likes
Message 25 of 37

SONA-ARCHITECTURE
Advocate
Advocate

Hi @edfdiloreto 

I read up your interesting post.

I've got a question :

How to get ProjectGuid and ModelGuid of a file wich is shared in Accdocs from a wpf form like I can do with OpenFileDialog to open files wich are in my Network?

Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
0 Likes
Message 26 of 37

Messi_Hu
Autodesk
Autodesk

Now, there is just some workaround, you cannot get them except via because the local cache(file) may not be created at the beginning:

- use forge API to go through Hub(Account) -> Project -> Guid, you can use fiddler to capture its propers to do that.

See this sample. https://forums.autodesk.com/t5/revit-api-forum/is-it-possible-to-open-a-bim-360-model-without-using-...

0 Likes
Message 27 of 37

SONA-ARCHITECTURE
Advocate
Advocate
Thx @Messi_Hu
So, I need a Forge Token access to be able to go through Hub (Account) , is it correct?
Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
0 Likes
Message 28 of 37

Messi_Hu
Autodesk
Autodesk

Yes, you need apply for forge-api key.

0 Likes
Message 29 of 37

SONA-ARCHITECTURE
Advocate
Advocate
I've got an other question : I've developped a plugin into VisuaStudio for a client. This client got a licence for sharing and using accdocs. If I want the plugin to open accdocs files, I must pay to get the forge token key?
Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
0 Likes
Message 30 of 37

Messi_Hu
Autodesk
Autodesk

Sorry, I did not have experience for this, I don't know if you pay for another one.

1 thing I want to remind you here, if you just want to develop a tool to use by yourself, it is easy, you have your private Autodesk account key/password and permssion to access your project/hub/ in acc/docs, but if you want to make this tool to be used by 3rd user. You cannot use your forge key/secret to access 3rd user's hub/project because it needs their permssion.

0 Likes
Message 31 of 37

SONA-ARCHITECTURE
Advocate
Advocate
Hi @Messi_Hu
Thx for taking time to answer me.
Do you think I can add a configurable form in this tool with the Key/secret token key of the 3rd user ?
Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
0 Likes
Message 32 of 37

Messi_Hu
Autodesk
Autodesk

Yes, you can. I think there is a sample implemented by   in above post I mentioned. And I happen to see there is a workaround (not a good solution, but it works) in above thread offered by dantartaglia8696.
I copied it from original post.

 

1. Open the model in Revit.

2. I usually do a sync.

3. Go to this folder:

    C:\Users\USERNAME\AppData\Local\Autodesk\Revit\Autodesk Revit 2022\CollaborationCache

4. Open the user folder (i.e. sim to: 200806230453619).

5. Sort by Date Modified. The newest GUID is the project GUID.

6. Open the GUID folder.

7. Sort by Date Modified. The newest GUID is the model GUID.

 

ModelPath oModelPath = null;
Guid modelGuid, projectGuid;

if (Guid.TryParse(strModelGuid, out modelGuid)
&& Guid.TryParse(strProjectGuid, out projectGuid))
{
oModelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(
ModelPathUtils.CloudRegionUS, projectGuid, modelGuid);

 

0 Likes
Message 33 of 37

SONA-ARCHITECTURE
Advocate
Advocate
Hi @Messi_Hu
I've already used this code to find the ModelGuid and ProjectGuid. But, this implies that user have already opened the accdocs file. But, if not, this collaborationCache maybe do not exists and in this case, how to get those Guid? Using Forge API?
Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
0 Likes
Message 34 of 37

Messi_Hu
Autodesk
Autodesk
Yes, you have to use forge api to get them.
0 Likes
Message 35 of 37

SONA-ARCHITECTURE
Advocate
Advocate
Ok, thx @Messi_Hu, I'm gonna subscribe to get a Forge Token.
Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107
Message 36 of 37

ssobreira2
Explorer
Explorer

Any update on this?

I believe that using 

ModelPathUtils.ConvertCloudGUIDsToCloudPath

returns the source file (the Published Central File in the WIP folder) rather than the Consumed file in the Consumed folder. This happens because it relies on the model GUID, and Autodesk Construction Cloud doesn't create a hard copy of the file when it's packaged and consumed. Instead, it creates a reference link that points back to the source file.

So, we would need to use a method like "ModelPathUtils.ConvertCloudIDsToCloudPath" instead of using the model GUID.

Alternatively, is there a workaround using the "Autodesk Docs://" path format?

Has anyone had success with this approach?

0 Likes
Message 37 of 37

ssobreira2
Explorer
Explorer

Never mind, I was able to resolve it using ExternalReference.

You will need the ServerID:

internal Guid GetADocsServerGUID()
{
    // Get the external resource service
    var resourceService = ExternalResourceServiceUtils.GetServersByType(ExternalResourceTypes.BuiltInExternalResourceTypes.RevitLink);
    var resourceNames = resourceService.Select(x => (x.GetName(), x.GetServerId())).ToList(); 
    var value = resourceNames.Where(x => x.Item1 == "Autodesk Docs").ToList(); //There is no space, it is a NO-BREAK SPACE
    return value.Any() ? value.First().Item2 : new Guid();             
}

P.S.: I know this one can be simplified, but it was leading to errors while debugging - so this is the code I use to analyze it.

And finally:

internal ExternalResourceReference CreateExternalReference(Guid serverId, 
                                                         string versionUrn, 
                                                         string inSessionPath,
                                                         string itemUrn,
                                                         string projectId,
                                                         string modelGUID,
                                                         string projectGUID)
{
    // Create reference information dictionary
    IDictionary<string, string> referenceInfo = new Dictionary<string, string>
    {
        { "ForgeDmItemUrn", itemUrn},
        { "ForgeDmProjectId", projectId },
        { "LinkedModelModelId", modelGUID },
        { "LinkedModelProjectId", projectGUID },
        { "LinkedModelRegion", "US" }
    };

    // Instantiate the ExternalResourceReference using the constructor
    ExternalResourceReference externalRef = new ExternalResourceReference(
        serverId,
        referenceInfo,
        versionUrn,
        inSessionPath
    );

    return externalRef;
}



0 Likes