Is it possible to open a BIM 360 model without using Forge?

Is it possible to open a BIM 360 model without using Forge?

dantartaglia8696
Advocate Advocate
6,609 Views
21 Replies
Message 1 of 22

Is it possible to open a BIM 360 model without using Forge?

dantartaglia8696
Advocate
Advocate

Hi,

Using 2019.1, is it possible to open a BIM 360 C4R models using only the Revit API? Below is from the 2019.1 SDK help file. It may not be possible but I'm trying to handing BIM 360 and non-BIM 360 opening of models using: OpenDocumentFile(), I'm not ready yet to use Forge. Can this be done? My attempts so far have failed.

 

Thanks,

Dan

 

Existing APIs now support open from cloud paths (Collaboration for Revit)

Document Open APIs support cloud paths

The existing methods:

  • Application.OpenDocumentFile(ModelPath modelPath, OpenOptions openOptions)
  • UIApplication.OpenAndActivateDocument(ModelPath modelPath, OpenOptions openOptions, bool detachAndPrompt)

and the new methods:

  • Application.OpenDocumentFile(ModelPath modelPath,OpenOptions openOptions, IOpenFromCloudCallback openFromCloudCallback)
  • UIApplication.OpenAndActivateDocument(ModelPath modelPath, OpenOptions openOptions, bool detachAndPrompt, IOpenFromCloudCallback openFromCloudCallback)

now offer the ability to open a C4R model from its location on the cloud. Obtain a relevant ModelPath representing the document from:

  • ModelPathUtils.ConvertCloudGUIDsToCloudPath(Guid, Guid)

by inputting the the project Guid and model Guid (which could be obtained from various Forge APIs).

Callback for conflict cases when opening from a cloud path

The callback method:

  • Autodesk.Revit.DB.IOpenFromCloudCallback.OnOpenConflict()

can be passed to the document open methods to gain to handle conflict cases. The method is passed an OpenConflictScenario value identifying the reason for the conflict ( Rollback, Relinquished or OutOfDate) and should return an OpenConflictResult with the desired response (keep local changes, discard local changes and open the latest version or cancel).

The new class:

  • DefaultOpenFromCloudCallback

provides a default way to handle conflicts: it always discards the local change and gets the latest version from the cloud.

0 Likes
Accepted solutions (1)
6,610 Views
21 Replies
Replies (21)
Message 2 of 22

zhong_wu
Autodesk Support
Autodesk Support
Accepted solution

In general, I should say "No", it's not possible to open the BIM360 model without Forge API.

 

As you can see from 2019.1, some methods are improved to open cloud models on BIM360, Revit developers can use  method ModelPathUtils.ConvertCloudGUIDsToCloudPath() to get the cloud model path from projectGuid & modelGuid, and then open it,  here is the sample code as follow:

 

            String modelGuidString = "55a82cfc-680d-4a44-bcf7-2f11837062a5";
            String projectGuidString = "0e57bf28-a777-443c-9d10-aee9ef0d37f4";
            Guid modelGuid, projectGuid;
            if (Guid.TryParse(modelGuidString, out modelGuid)
               && Guid.TryParse(projectGuidString, out projectGuid))
            {
                Autodesk.Revit.DB.OpenOptions oopts = new Autodesk.Revit.DB.OpenOptions();
                ModelPath modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(projectGuid, modelGuid);
                revitApp.OpenAndActivateDocument(modelPath, oopts, false);
            }

 

But the method requires the projectGuid and modelGuid which you can only get by Forge API, you need to access BIM360 Docs with Forge API, from hub->project->folder->item->version,  if you are not clear about this part, please check the Forge Data Management API for more details, and with that API, you can get the projectGuid and modelGuid and then use it in Revit API.Picture2.png

 

Screen Shot 2018-09-28 at 12.32.35 PM.png

 

 

 

   


John Wu
Developer Technical Services
Autodesk Developer Network


Message 3 of 22

dantartaglia8696
Advocate
Advocate

Thanks @zhong_wu!, I'm sure what you sent will help a lot. I haven't been coding as much as I used to but I need to get more familiar with Forge. I'll be at ForgeDevCon at AU which will help.

 

Thanks again,

Dan

0 Likes
Message 4 of 22

AdamHamilton
Advocate
Advocate

but isn't this still accessing Published Models? Currently there is no automation to publish a model or access the Working Models?

0 Likes
Message 5 of 22

dantartaglia8696
Advocate
Advocate

OpenAndActivateDocument() seems to access the cloud model not the published model in my tests. I will use Forge to get the GUIDs for the project and models, you can get them from the C:\Users\USERNAME\AppData\Local\Autodesk\Revit\Autodesk Revit 2019\CollaborationCache folder. I've been doing a little testing with these but would rather get the values dynamically.

Message 6 of 22

Anonymous
Not applicable

Hello,

I've been using the code provided to open BIM 360 models.  This works most of the time, but in a project I'm testing for some reason models in a subfolder won't open.  (The path obtained from the model does not contain subfolders)  I have the model/project guids but I get an Autodesk.Revit.Exceptions.CentralModelMissingException: "The central model is missing." at the OpenAndActivateDocument method, but I can open this same model thru Revit.  This exception doesn't appear in the list of exceptions in the 2019.2 API guide.  Any ideas?  Thanks.

0 Likes
Message 7 of 22

zhong_wu
Autodesk Support
Autodesk Support

Interesting, what's your file structure? can you share that to me and we can try to to see if this can be reproduced my side?


John Wu
Developer Technical Services
Autodesk Developer Network


0 Likes
Message 8 of 22

Anonymous
Not applicable

Hi John,

 

Thanks for reaching out.  You can disregard, I discovered what happened.  I believe we obtained the model ids and then someone moved the models into the subfolder which caused the model id to change.  Getting the new model id fixed the problem.

 

Thanks.

0 Likes
Message 9 of 22

pedro_getz
Observer
Observer

Very useful answers! Thanks a lot for that. I have a  very basic question. How do you convert the number of the project that you pointed out before,  in Collaboration Cache folder,  to a valid Guid to pass as an argument of the OpenandActivateDocument method? How can I  make the casting? : /

 

0 Likes
Message 10 of 22

zhong_wu
Autodesk Support
Autodesk Support
I guess you can try https://forge.autodesk.com/en/docs/data/v2/tutorials/publish-model/ to publish cloud model automatically.

John Wu
Developer Technical Services
Autodesk Developer Network


0 Likes
Message 11 of 22

zhong_wu
Autodesk Support
Autodesk Support
Normally, we should use Forge API to get the Ids of a cloud model, but I am not sure how to get these ids from the cache file....

John Wu
Developer Technical Services
Autodesk Developer Network


Message 12 of 22

dantartaglia8696
Advocate
Advocate

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

 

 

Message 13 of 22

bcampbell11
Advocate
Advocate

So, this seems possible for sure, my question now is, can this be achieved without purchasing and using tokens?

I see where some things may be free, but not totally clear if this would be or not.  Anybody know?

 

0 Likes
Message 14 of 22

zhong_wu
Autodesk Support
Autodesk Support
From what I can see, there should be no APS(Forge) token required because this is all about using Data Management API and Revit API. Forge what should be charged, please refer https://forge.autodesk.com/pricing for details.

John Wu
Developer Technical Services
Autodesk Developer Network


Message 15 of 22

dantartaglia8696
Advocate
Advocate

Hi,

 

I open models all the time via the API to print and perform other tasks however when I attemped to open the model to work in, the model would not completely open (gray screen but model was open). Are you seeing different results?

 

Thanks,

Dan

0 Likes
Message 16 of 22

dantartaglia8696
Advocate
Advocate

Please disregard my last response 🙂

0 Likes
Message 17 of 22

bcampbell11
Advocate
Advocate

ok, thank you!  I need to get my head into the data management API, I have not used it before.

0 Likes
Message 18 of 22

iref3at
Contributor
Contributor
thanks for the detailed instruction, were you able to open or sync to a central file placed in a cloud-sharing file storage other than BIM 360? (ie: dropbox)

I didn't find the collaboration cache folder in my disk.
else there was a cefcache folder, it contained blob-Storage folder that contained another folder with title looks like GUID is it it?
0 Likes
Message 19 of 22

zhong_wu
Autodesk Support
Autodesk Support

No, I don't think you can open or sync the cloud worksharing model to other cloud storage, only BIM 360 Docs and Autodesk Docs are allowed currently.


John Wu
Developer Technical Services
Autodesk Developer Network


0 Likes
Message 20 of 22

SONA-ARCHITECTURE
Advocate
Advocate

Hi everyone.

Thx to this dicussion, I'm now able to open a document wich is in collaboration cache folder.

But, how to open a document wich is not yet into the collaboration cache folder because it was not previously opened?

Like I 'll do with an OpenFileDialog?

Pierre NAVARRA
SONA-Architecture.
http://www.sona-architecture.com
https://fr.linkedin.com/in/pierre-navarra-62032a107