简体   繁体   English

以编程方式启动 BIM360 Docs 协作

[英]Initiate BIM360 Docs collaboration programmatically

In order to upgrade to the current version of Revit, we have to migrate our files from from BIM360 Teams to BIM360 Docs.为了升级到当前版本的 Revit,我们必须将我们的文件从 BIM360 Teams 迁移到 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. Forge API 允许我从 BIM360 Teams 下载所有 Revit 文件。 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 `.我还可以使用 Revit API 或第三方应用程序(例如此 Bulk File Upgrader `)将它们全部升级到 Revit 2019。

Using the Forge BIM360 API, I am able to create new projects programmatically, and upload the files and folders from the Team Drive.使用 Forge BIM360 API,我能够以编程方式创建新项目,并从 Team Drive 上传文件和文件夹。 The step that I am having difficulty accomplishing in an automated fashion is to initiate collaboration for the upgraded Revit 2019 files.我难以以自动化方式完成的步骤是启动升级后的 Revit 2019 文件的协作。 Is there a way that this can be accomplished with either the Revit API or the Forge API?有没有一种方法可以通过 Revit API 或 Forge API 来实现? Or is there another way that allows me to automatically accomplish the migration between these two Autodesk Cloud Collaboration solutions?还是有另一种方法可以让我自动完成这两个 Autodesk Cloud Collaboration 解决方案之间的迁移?

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.我遇到了这个关于发布模型的教程,它表明需要通过 Revit UI 手动启动每个 Revit 文件的协作。 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:我的同事 Eason Kang 康益升确认您可以使用我之前的回答中提供的步骤来实现这一点,如下所示:

Revit 2019.2 and future releases include support for the "Single user workflow", the non-workshared cloud model. Revit 2019.2 和未来版本包括对“单用户工作流”(非工作共享云模型)的支持。 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).同时,他们公开了用于启动非工作共享云模型并将非工作共享云模型转换为工作共享云模型(C4R)的 API。

You can use the single user APIs to workaround the cases you mentioned as follows:您可以使用单用户 API 来解决您提到的情况,如下所示:

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

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.问题:我想使用 Revit 2020 API 将本地 RVT 保存到我的 BIM360 帐户(激活了 Design Collaboration 服务),但 Revit 总是抛出异常,提示我没有访问权限。 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.我拥有有效的 C4R 许可证,并且能够从我通过 Revit UI 传递给 API 的文件夹 ID 打开 C4R 模型。 What is missing?什么东西少了?

Code:代码:

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

Exception:例外:

  • Autodesk.Revit.Exceptions.RevitServerUnauthorizedException: You do not have cloud model entitlement to access this resource in cloud Autodesk.Revit.Exceptions.RevitServerUnauthorizedException:您没有云模型授权来访问云中的此资源

Answer: You need to have the 'Cloud Models for Revit' entitlement set up in manage.autodesk.com .回答:您需要在manage.autodesk.com中设置“Cloud Models for 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.我将“Cloud Models for Revit”与 C4R 混淆了,而且我没有在我的 manage.autodesk.com 中设置“Cloud Models for Revit”授权。

Answer: 'Cloud Models for Revit' is a new service provided since Revit 2019.2.答: “Cloud Models for Revit”是自 Revit 2019.2 以来提供的一项新服务。 It is part of the Revit and Revit LT subscription.它是 Revit 和 Revit LT 订阅的一部分。

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.顺便说一句,与 C4R 模型的主要区别在于,一次只有一个用户可以使用这种方法创建的模型。

Response: Great!回应:太好了!

I set up my Revit Subscription as required, followed the steps shared above by Jeremy and confirmed that it works!我根据需要设置我的 Revit 订阅,按照 Jeremy 上面分享的步骤进行操作并确认它有效!

You can achieve the goal through the Revit API using the following steps:您可以使用以下步骤通过 Revit API 实现目标:

  • Initiate a non-workshared cloud model through the API call to Document.SaveAsCloudModel .通过对Document.SaveAsCloudModel的 API 调用启动非工作共享云模型。
  • Convert it to a C4R model via the API Document.EnableCloudWorksharing .通过 API Document.EnableCloudWorksharing将其转换为 C4R 模型。

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

Sorry for the delay answering this.很抱歉延迟回答这个问题。

This issue sounds similar to the one raised in the Revit API discussion forum and escalated to the ADN case 14906646 Old topic brought back - changing link paths to Cloud paths .此问题听起来与 Revit API 讨论论坛中提出并升级为 ADN 案例 14906646 的问题相似旧主题将链接路径更改回云路径

We have raised the question with the Revit, C4R, Forge and Desktop Connector development teams, causing lively discussion with no clear answer yet in sight.我们已经向 Revit、C4R、Forge 和 Desktop Connector 开发团队提出了这个问题,引发了热烈的讨论,目前还没有明确的答案。

We are researching as hard and fast as possible and will provide a more conclusive answer asap.我们正在尽可能努力和快速地进行研究,并将尽快提供更确凿的答案。

The development team are still discussing this issue.开发团队仍在讨论这个问题。 Meanwhile, they also said:与此同时,他们还表示:

This request is recorded in the development issue REVIT-140793.此请求记录在开发问题 REVIT-140793 中。

There may be a workaround to achieve what you need.可能有一种解决方法可以实现您的需要。

Revit 2019.2 and future releases include support for the "Single user workflow" -- that is the non-workshared cloud model. Revit 2019.2 和未来版本包括对“单用户工作流”的支持——即非工作共享云模型。 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).同时,他们公开了用于启动非工作共享云模型并将非工作共享云模型转换为工作共享云模型(C4R)的 API。

So, I think you can use the single user APIs to workaround the cases you mentioned as follows:因此,我认为您可以使用单用户 API 来解决您提到的以下情况:

  1. Save the downloaded files and non-workshared files (local files).保存下载的文件和非工作共享文件(本地文件)。
  2. Initiate non-workshared cloud model through the API call to Document.SaveAsCloudModel .通过对Document.SaveAsCloudModel的 API 调用启动非工作共享云模型。
  3. Convert it to a C4R model via the API Document.EnableCloudWorksharing .通过 API Document.EnableCloudWorksharing将其转换为 C4R 模型。

Autodesk has also recently published a GitHub repository with a solution for this exact scenario. Autodesk 最近还发布了一个GitHub 存储库,其中包含针对这种情况的解决方案。 You can find the video here which talk about this.你可以在这里找到谈论这个的视频 This basically uses enhanced api calls in Revit 2022 API - RevitLinkType.Create & RevitLinkType.LoadFrom which support cloud model creation and linking.这基本上使用 Revit 2022 API 中增强的 API 调用- RevitLinkType.CreateRevitLinkType.LoadFrom支持云模型创建和链接。


There's a related question about how to create new cloud models using Revit API.有一个关于如何使用 Revit API创建新云模型的相关问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM