Autodesk Forge 数据管理参考 API 未列出 Revit 参考

问题描述

我的目标是使用设计自动化 API 计算 Revit 模型。 Revit 模型托管在 BIM360 文档上。 Revit 模型包含其他模型的链接/参考。这些引用是在 Revit 中创建的,并且都引用了同样托管在 BIM360 文档中的模型。

为了将工作项提交给设计自动化 API,我需要知道所有引用的文件。这被描述为here

但是,当我查询数据管理 API {{FORGE_HOST}}/data/v1/projects/:project/versions/:version/relationships/refs 的引用端点时,我得到一个空数据对象。

我本来希望得到引用项目的版本。

一个提议的工作流程似乎是使用 BIM360 文档前端中的“上传链接文件功能文件上传到 BIM360,请参阅this blog post。这样做,我确实使用上述引用端点获取引用。但是,这对我们的组织和工作流程不起作用,因为在规划阶段添加了越来越多的参考。而且,有些文件相互引用,这也是使用“上传链接文件功能无法实现的。博客也提到了forge API链接文件,但是我们不想使用forge API手动链接模型,而是想使用Revit提供的功能

如何提取/查询已使用 Revit 中的引用链接的 Revit 文件的 Revit 引用?

解决方法

更新

事情已经改变了。要使用 Forge Data Management API 获取 Revit 参考,模型需要匹配以下内容:

参考:https://knowledge.autodesk.com/support/revit-products/troubleshooting/caas/sfdcarticles/sfdcarticles/Collaboration-for-Revit-Local-links-not-visible-on-the-cloud.html

如果您的 Revit 模型属于上述任何一种,则 Revit API 方式是另一种选择。您可以编写一个在 Revit Desktop 上运行的 Revit 插件,以在运行您提到的设计自动化工作项之前读取 Revit 链接数据。

==========

Autodesk Desktop Connector 将是设置引用的最佳选择,而无需使用我在博客中分享的 upload linked files 或 Forge DM API。

如果您只想转储链接信息,我们可以利用 Revit API 来执行此操作。这是给您的代码片段。 (在 Forge Design Automation API for Revit 上运行之前,需要删除 TaskDialog.Show

https://thebuildingcoder.typepad.com/blog/2019/06/accessing-bim360-cloud-links-thumbnail-and-dynamo.html

  // Obtain all external resource references 
  // (saying BIM360 Cloud references and local 
  // file references this time)

  ISet<ElementId> xrefs = ExternalResourceUtils
    .GetAllExternalResourceReferences( doc );

  string caption = "BIM360 Links";

  try
  {
    int n = 0;
    var msg = string.Empty;

    foreach( ElementId eid in xrefs )
    {
      var elem = doc.GetElement( eid );
      if( elem == null ) continue;

      // Get RVT document links only this time

      var link = elem as RevitLinkType;
      if( link == null ) continue;

      var map = link.GetExternalResourceReferences();
      var keys = map.Keys;

      foreach( var key in keys )
      {
        var reference = map[key];

        // Contains Forge BIM360 ProjectId 
        // (i.e.,LinkedModelModelId) and 
        // ModelId (i.e.,LinkedModelModelId) 
        // if it's from BIM360 Docs. 
        // They can be used in calls to
        // ModelPathUtils.ConvertCloudGUIDsToCloudPath.

        var dictinfo = reference.GetReferenceInformation();

        // Link Name shown on the Manage Links dialog

        var displayName = reference.GetResourceShortDisplayName();
        var path = reference.InSessionPath;
      }

      try
      {
        // Load model temporarily to get the model 
        // path of the cloud link

        var result = link.Load();

        // Link ModelPath for Revit internal use

        var mdPath = result.GetModelName();

        link.Unload( null );

        // Convert model path to user visible path,// i.e.,saved Path shown on the Manage Links 
        // dialog

        var path = ModelPathUtils
          .ConvertModelPathToUserVisiblePath( mdPath );

        // Reference Type shown on the Manage Links dialog

        var refType = link.AttachmentType;

        msg += string.Format( "{0} {1}\r\n",link.AttachmentType,path );

        ++n;
      }
      catch( Exception ex ) // never catch all exceptions!
      {
        TaskDialog.Show( caption,ex.Message );
      }
    }

    caption = string.Format( "{0} BIM360 Link{1}",n,Util.PluralSuffix( n ) );

    TaskDialog.Show( caption,msg );
  }
  catch( Exception ex )
  {
    TaskDialog.Show( caption,ex.Message );
  }