In order to upgrade to the current version of Revit, we have to migrate our files from from BIM360 Teams to BIM360 Docs. Since we have hundreds of documents, I am looking to automate this process as much as possible.
The forge API allows me to download all Revit files from BIM360 Teams. I am also able to upgrade them all to Revit 2019, using either the Revit API or a third party app such as this Bulk File Upgrader`.
Using the Forge BIM360 API, I am able to create new projects programmatically, and upload the files and folders from the Team Drive. The step that I am having difficulty accomplishing in an automated fashion is to initiate collaboration for the upgraded Revit 2019 files. Is there a way that this can be accomplished with either the Revit API or the Forge API? Or is there another way that allows me to automatically accomplish the migration between these two Autodesk Cloud Collaboration solutions?
I came across this tutorial on publishing models, which suggests that one needs to manually initiate collaboration for each Revit file through the Revit UI. I hope to find an alternative solution to this suggestion.
Thank you!
My colleague Eason Kang 康益昇 confirmed that you can use the steps provided in my previous answer to achieve this as follows:
Revit 2019.2 and future releases include support for the "Single user workflow", the non-workshared cloud model. At the same time, they expose the API to initiate the non-workshared cloud model and convert the non-workshared cloud model to a workshared cloud model (C4R).
You can use the single user APIs to workaround the cases you mentioned as follows:
Document.SaveAsCloudModel
.Document.EnableCloudWorksharing
.Here is his report, including the solution to a credentials issue on the way:
Question: I would like to save a local RVT to my BIM360 account – with Design Collaboration service activated – using the Revit 2020 API, but Revit always throws an exception saying that I do not have the access rights. I have a valid C4R license and able to open C4R models from the folder id I passed to the API with the Revit UI. What is missing?
Code:
doc.SaveAsCloudModel(
"urn:adsk.wipprod:fs.folder:co.8rtX03jDQXKnssA1FfrEXw",
doc.Title);
Exception:
Answer: You need to have the 'Cloud Models for Revit' entitlement set up in manage.autodesk.com
.
Response: Thank you for clarifying. I confused the 'Cloud Models for Revit' with the C4R, and I didn't have the 'Cloud Models for Revit' entitlement set up in my manage.autodesk.com.
Answer: 'Cloud Models for Revit' is a new service provided since Revit 2019.2. It is part of the Revit and Revit LT subscription.
Btw, the major difference to the C4R models is thaT only one user at a time can work on the model created by this method.
Response: Great!
I set up my Revit Subscription as required, followed the steps shared above by Jeremy and confirmed that it works!
You can achieve the goal through the Revit API using the following steps:
Document.SaveAsCloudModel
.Document.EnableCloudWorksharing
.Here is my test code implementing this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
namespace adsk.c4r
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
string template = app.DefaultProjectTemplate;
string filename = @"D:\DevZone\ADN\t5021\revit_api_c4r_test_6.rvt";
string name = System.IO.Path.GetFileName(filename);
Document doc = app.NewProjectDocument(template);
doc.SaveAs(filename);
try
{
doc.SaveAsCloudModel(
"urn:adsk.wipprod:fs.folder:co.aCd1tMmrTxucmJcmtYTLBQ",
name);
var cloudPath = doc.GetCloudModelPath();
if(doc.CanEnableCloudWorksharing())
{
doc.EnableCloudWorksharing();
}
TaskDialog.Show("Revit",
string.Format("{0} is a C4R model now", name));
doc.Close();
uiapp.OpenAndActivateDocument(cloudPath, new OpenOptions(), false);
}
catch(Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message);
return Result.Cancelled;
}
return Result.Succeeded;
}
}
}