以编程方式启动BIM360 Docs协作 [英] Initiate BIM360 Docs collaboration programmatically

查看:196
本文介绍了以编程方式启动BIM360 Docs协作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了升级到Revit的当前版本,我们必须将文件从BIM360 Teams迁移到BIM360 Docs.由于我们有数百个文档,因此我希望尽可能地使此过程自动化.

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.

forge API允许我从BIM360 Teams下载所有Revit文件.我还可以使用Revit API或第三方应用程序(例如

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

使用Forge BIM360 API,我可以以编程方式创建新项目,并从Team Drive上传文件和文件夹.我很难以自动化方式完成的步骤是为升级的Revit 2019文件启动协作.有没有一种方法可以使用Revit API或Forge API来完成?还是有其他方法可以让我自动完成这两个Autodesk Cloud Collaboration解决方案之间的迁移?

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?

我遇到了有关发布模型的教程,这表明需要通过Revit UI为每个Revit文件手动启动协作.我希望找到此建议的替代解决方案.

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.

谢谢!

推荐答案

我的同事Eason Kang康益升确认您可以使用我以前的答案中提供的步骤来实现此目标,如下所示:

My colleague Eason Kang 康益昇 confirmed that you can use the steps provided in my previous answer to achieve this as follows:

Revit 2019.2和更高版本包含对非工作共享云模型单一用户工作流"的支持.同时,他们公开API以启动非工作共享云模型,并将非工作共享云模型转换为工作共享云模型(C4R).

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

您可以使用单用户API解决以下情况:

You can use the single user APIs to workaround the cases you mentioned as follows:

  • 将下载的文件和非工作共享文件保存到本地文件系统中.
  • 通过对Document.SaveAsCloudModel的API调用来启动非工作共享云模型.
  • 通过API Document.EnableCloudWorksharing将其转换为C4R模型.
  • Save the downloaded files and non-workshared files to your local file system.
  • Initiate non-workshared cloud model through the API call to Document.SaveAsCloudModel.
  • Convert it to a C4R model via the API Document.EnableCloudWorksharing.

这是他的报告,包括以下方式的凭证问题解决方案:

Here is his report, including the solution to a credentials issue on the way:

问题:我想将本地RVT保存到我的BIM360帐户–启用了Design Collaboration服务的–使用Revit 2020 API,但是Revit总是抛出一个异常,说我没有访问权限.我拥有有效的C4R许可证,并且能够通过我通过Revit UI传递给API的文件夹ID打开C4R模型.什么不见​​了?

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?

代码:

  doc.SaveAsCloudModel(
    "urn:adsk.wipprod:fs.folder:co.8rtX03jDQXKnssA1FfrEXw",
    doc.Title);

例外:

  • Autodesk.Revit.Exceptions.RevitServerUnauthorizedException:您没有云模型权利可访问云中的此资源

答案:您需要在manage.autodesk.com中设置"Revit的云模型"权利.

Answer: You need to have the 'Cloud Models for Revit' entitlement set up in manage.autodesk.com.

响应:谢谢您的澄清.我将"Revit的云模型"与C4R混淆了,但在manage.autodesk.com中没有设置"Revit的云模型"权利.

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.

答案:"Revit的云模型"是Revit 2019.2.以来提供的一项新服务.它是Revit和Revit LT订阅的一部分.

Answer: 'Cloud Models for Revit' is a new service provided since Revit 2019.2. It is part of the Revit and Revit LT subscription.

顺便说一句,与C4R模型的主要区别在于,一次只有一个用户可以使用此方法创建的模型.

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.

回复:很好!

我根据需要设置了Revit订阅,然后按照杰里米(Jeremy)上面共享的步骤进行操作,并确认它可以正常工作!

I set up my Revit Subscription as required, followed the steps shared above by Jeremy and confirmed that it works!

您可以通过以下步骤通过Revit API实现目标:

You can achieve the goal through the Revit API using the following steps:

  • 通过对Document.SaveAsCloudModel的API调用来启动非工作共享的云模型.
  • 通过API Document.EnableCloudWorksharing将其转换为C4R模型.
  • Initiate a non-workshared cloud model through the API call to Document.SaveAsCloudModel.
  • Convert it to a C4R model via the API 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;
    }
  }
}

这篇关于以编程方式启动BIM360 Docs协作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆