首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我们是否可以通过API访问Forge API/Revit API中的C4R(针对Revit的协作)功能?

我们是否可以通过API访问Forge API/Revit API中的C4R(针对Revit的协作)功能?
EN

Stack Overflow用户
提问于 2019-10-21 17:41:22
回答 1查看 381关注 0票数 0

我们最近收到了一项关于自动执行C4R(Revit协作)过程的咨询。我们是否可以通过API访问Forge API/Revit API中的C4R功能?我们已经搜索了API访问,但没有找到任何积极的结果。

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

EN

回答 1

Stack Overflow用户

发布于 2019-11-01 18:02:56

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

通过Document.EnableCloudWorksharing接口将非工作共享的云模型Document.SaveAsCloudModel.

  • Convert到
  1. ,从而启动非工作共享云模型

下面是一个工作代码片段,以及它的逻辑:

使用Revit template

  • Open
  1. C4R中的C4R模型将其另存为云

代码语言:javascript
复制
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;
            }
        }
    }

希望它能帮上忙!

Note1。此方法需要云模型。如果您无法保存云模型,请查看此页面: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 Data Management API来获取文件夹id。文件夹id也可以在查看Docs folder.For时的BIM360 Docs URL中找到例如,您的文件夹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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58483626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档