doc.SaveAs on active CloudModel

doc.SaveAs on active CloudModel

Anonymous
Not applicable
1,784 Views
4 Replies
Message 1 of 5

doc.SaveAs on active CloudModel

Anonymous
Not applicable

Hi,

 

I have the need to save active cloud model to a local file. When I try to use SaveAs I get the following error.

 

"Error saving solved project: A managed exception was thrown by Revit or by one of its external applications."

 

My code is like below, where "NewFilePath" is to local hard drive.

SaveAsOptions sao = new SaveAsOptions();
sao.OverwriteExistingFile = true;

doc.SaveAs(NewFilePath, sao);

I've tried this on both the active cloud document, and by making copy of the local cache file first, but both approaches result in error.

 

Any thoughts? Keep in mind my main goal is just to get a detached local copy of the cloud model.

 

Thanks,

Jon

 

0 Likes
Accepted solutions (1)
1,785 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Accepted solution

I may have answered my own question, but feel free to chime in if any thoughts or comments.

 

What I'm doing that seems to work.

  1. Locate local cache copy of file by investigating Revit journal file (namely looking for most recent "Rvt.Attr.LastSavePath:" value)
  2. Copy that file to desired local destination
  3. Open that file using OpenOptions.DetachFromCentralOption.DetachAndDiscardWorksets
    1. Doing this even if CloudModel is NOT workshared which appears to work.
  4. At this point the new copy of CloudModel is completely removed from Cloud and can be saved as normal.

 

 

0 Likes
Message 3 of 5

jeremytammik
Autodesk
Autodesk

Here are some related links on accessing and saving Revit models to and from BIM360.

 

  

Hope they help!

 

Please let us know how you end up solving this.

 

Thank you!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk

I saw your answer after posting my list.

 

Your approach sounds both feasible and clever.

 

Thank you for sharing the solution!

 

I hope it continues to work reliably for you!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 5

Anonymous
Not applicable

Thanks Jeremy,

 

After reviewing the links you provided I've settled on using the solution I posted above (I will mark this as the solution for post). It accomplishes exactly what I need. The only "down-side" to my solution I feel is digging through the journal file to locate local cache file, but as long as it remains reliable then not a problem.

 

I did find the "IopenFromCloudCallback" link helpful/interesting as it reveals you can Open & Detach directly using the CloudModelPath, with the result being a detached file that has the local cache file in doc.PathName (no need to dig through journal). I would have used this but the opened document replaces my active document (the CloudDocument) and I prefer to have both of them open.

 

Thanks again!

Jon

 

0 Likes