【问题标题】:Do we have API access to C4R(Collaboration for Revit) functionalities in Forge API/Revit API?我们是否可以通过 API 访问 Forge API/Revit API 中的 C4R(Collaboration for Revit)功能?
【发布时间】:2020-02-17 09:15:00
【问题描述】:

我们最近有一项关于自动化 C4R(Revit 协作)流程的调查。我们是否可以通过 API 访问 Forge API/Revit API 中的 C4R 功能?我们搜索了 API 访问权限,但没有找到任何积极的结果。

或者,如果我们通过 BIM 360 API 上传 Revit 模型文件,则 Revit 项目文件 (.rvt) 将断开连接/无法用于工作共享环境。是否有任何可能的解决方法来解决此问题。

【问题讨论】:

  • 抱歉迟到了。我正在调查它。请耐心等待,它需要额外的时间来验证它。谢谢!

标签: autodesk-forge autodesk-bim360


【解决方案1】:

要通过 Revit API 激活 C4R 模型,请至少执行以下步骤:

  1. 通过 API 调用启动非工作共享云模型 Document.SaveAsCloudModel
  2. 通过 API 将其转换为 C4R 模型 Document.EnableCloudWorksharing


这是一个工作代码sn-p,以及它的逻辑:

  1. 使用 Revit 模板创建 Architecture 项目
  2. 保存到本地磁盘,然后保存为云模型
  3. 通过Document.EnableCloudWorksharing 激活 Revit Cloud Collaboration (C4R)
  4. 在 Revit 桌面打开 C4R 模型


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 = @"C:\tmp\revit_api_c4r_test.rvt";
                string name = System.IO.Path.GetFileName(filename);

                Document newdoc = app.NewProjectDocument(template);
                newdoc.SaveAs(filename);


                try
                {
                    newdoc.SaveAsCloudModel("urn:adsk.wipprod:fs.folder:co.OOOOOXXXXX", name);
                    var cloudPath = newdoc.GetCloudModelPath();
                    var newdocCanC4R = newdoc.CanEnableCloudWorksharing();

                    if(newdocCanC4R)
                    {
                        newdoc.EnableCloudWorksharing();
                    }

                    TaskDialog.Show("Revit", string.Format("{0} is a C4R model now", name));
                    newdoc.Close();

                    uiapp.OpenAndActivateDocument(cloudPath, new OpenOptions(), false);
                }
                catch(Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message);
                    return Result.Cancelled;
                }

                return Result.Succeeded;
            }
        }
    }

希望对你有帮助!


注意1。此方法需要 Cloud Model for Revit 权利。如果您无法保存云模型,请查看此页面:https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/sfdcarticles/sfdcarticles/Using-Cloud-Worksharing-and-Cloud-Models-for-Revit.html

Note2.这种方法必须在调用 Document.SaveAsCloudModel 时使用 Forge 数据管理 API 来获取文件夹 id。在查看Docs文件夹时,也可以在BIM360 Docs URL中找到文件夹id。例如,您的文件夹URL是:https://docs.b360.autodesk.com/projects/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/folders/urn:adsk.wipprod:fs.folder:co.OOOOOXXXXX/detail,文件夹id是urn:adsk.wipprod:fs.folder:co.OOOOOXXXXX

【讨论】:

    猜你喜欢
    • 2020-04-21
    • 2021-10-25
    • 2016-10-24
    • 1970-01-01
    • 2020-04-20
    • 2016-01-11
    • 2017-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多