简体   繁体   English

如何使用 Forge API 获取 Revit model 的嵌套链接列表

[英]How to get a list of nested links for a Revit model using Forge APIs

I can acquire the full list of nested links in a Revit model using Revit APIs by this query:我可以通过以下查询使用 Revit API 获取 Revit model 中嵌套链接的完整列表:

  FilteredElementCollector collector = new FilteredElementCollector(document);
  return collector.OfCategory(BuiltInCategory.OST_RvtLinks)
    .OfClass(typeof(RevitLinkInstance))
    .Cast<RevitLinkInstance>()
    .Select(linkInstance => document.GetElement(linkInstance.GetTypeId()) as RevitLinkType)
    .Where(revitLinkType => revitLinkType.IsNestedLink)
    .Select(type => type.Name)
    .Distinct()
    .ToList();

I am trying to replicate the same function using Forge APIs.我正在尝试使用 Forge API 复制相同的 function。 While I can't get the nested links directly, I am hoping to get it in two steps.虽然我无法直接获取嵌套链接,但我希望分两步获取。

First: acquire the list of linked docs, Second: query the linked docs on every linked document acquired in step one.第一:获取链接文档列表,第二:在第一步获取的每个链接文档上查询链接文档。

I am using this API to get the list of linked docs for step one:我正在使用这个 API 来获取第一步的链接文档列表:

'https://developer.api.autodesk.com/data/v1/projects/[project_id]/versions/[version_id]/relationships/refs' 'https://developer.api.autodesk.com/data/v1/projects/[project_id]/versions/[version_id]/relationships/refs'

That returns a list that includes: linked docs, the document itself, and any document that has the document linked in. So for example:这将返回一个列表,其中包括:链接的文档、文档本身以及链接了该文档的任何文档。例如:

If A links B, and B links C, When I call the API on B, I get A, B and C. Now, it's easy to eliminate B from the response, but it's a bit confusing to figure out between A and C which one is a linked document.如果 A 链接 B,B 链接 C,当我在 B 上调用 API 时,我得到 A、B 和 C。现在,很容易从响应中消除 B,但在 A 和 C 之间弄清楚哪个有点令人困惑一个是链接文档。

I checked all the attributes and couldn't find anything, is there something I am missing?我检查了所有属性,但找不到任何东西,是不是我遗漏了什么? Also, is this the best way to acquire the list of nested linked documents?另外,这是获取嵌套链接文档列表的最佳方法吗?

To identify which file is the host or link, we can take a look at the direction attribute of the responses of GET projects/:project_id/versions/:version_id/relationships/refs要确定哪个文件是主机或链接,我们可以查看GET projects/:project_id/versions/:version_id/relationships/refs响应的direction属性

Here are two example responses representing the host and link correspondingly.下面是两个示例响应,分别表示主机和链接。

//Host Model
"data": [
    {
        "type": "versions",
        "id": "urn:adsk.wipprod:fs.file:vf.n4QEQGINSWid8VvcBVds1w?version=1",
        "meta": {
            "refType": "xrefs",
            "fromId": "urn:adsk.wipprod:fs.file:vf.n4QEQGINSWid8VvcBVds1w?version=1",
            "fromType": "versions",
            "toId": "urn:adsk.wipprod:fs.file:vf.y6GJ2scBSVSyIRM_wtEsDA?version=1",
            "toType": "versions",
            "direction": "to",
            "extension": {
                "type": "xrefs:autodesk.core:Xref",
                "version": "1.1",
                "schema": {
                    "href": "https://developer.api.autodesk.com/schema/v1/versions/xrefs:autodesk.core:Xref-1.1"
                },
                "data": {
                    "nestedType": "overlay"
                }
            }
        }
    }
],
// Link model
"data": [
    {
        "type": "versions",
        "id": "urn:adsk.wipprod:fs.file:vf.y6GJ2scBSVSyIRM_wtEsDA?version=1",
        "meta": {
            "refType": "xrefs",
            "fromId": "urn:adsk.wipprod:fs.file:vf.n4QEQGINSWid8VvcBVds1w?version=1",
            "fromType": "versions",
            "toId": "urn:adsk.wipprod:fs.file:vf.y6GJ2scBSVSyIRM_wtEsDA?version=1",
            "toType": "versions",
            "direction": "from",
            "extension": {
                "type": "xrefs:autodesk.core:Xref",
                "version": "1.1",
                "schema": {
                    "href": "https://developer.api.autodesk.com/schema/v1/versions/xrefs:autodesk.core:Xref-1.1"
                },
                "data": {
                    "nestedType": "overlay"
                }
            }
        }
    }
],

The direction attribute has two possible values, one is to and another is from . direction属性有两个可能的值,一个是to ,另一个是from

In the above example, host urn:adsk.wipprod:fs.file:vf.n4QEQGINSWid8VvcBVds1w?version=1 is linked to urn:adsk.wipprod:fs.file:vf.y6GJ2scBSVSyIRM_wtEsDA?version=1 .在上面的示例中,主机urn:adsk.wipprod:fs.file:vf.n4QEQGINSWid8VvcBVds1w?version=1链接到urn:adsk.wipprod:fs.file:vf.y6GJ2scBSVSyIRM_wtEsDA?version=1 Consider it like an arrow with the head pointing to -wards the link model.把它想象成一个箭头,箭头to链接 model。

What you see from link model perspective is simply the reverse, the arrow is coming from the host urn:adsk.wipprod:fs.file:vf.n4QEQGINSWid8VvcBVds1w?version=1 .您从链接 model 的角度看到的完全相反,箭头来自主机urn:adsk.wipprod:fs.file:vf.n4QEQGINSWid8VvcBVds1w?version=1

In both example responses, the fromId and toId don't change, only the direction of the arrow depending from which perspective you're looking at.在这两个示例响应中, fromIdtoId都没有改变,只有arrowdirection取决于您从哪个角度看。

Thanks for the response Eason.感谢伊森的回应。 Ok so if I use the 'GET' equivalent it works as you described.好的,如果我使用等效的“GET”,它会按照您的描述工作。 However, I can only get it to work on smaller test models, the API simply returns an empty array for data, even though the project does have several linked document:然而,我只能让它在较小的测试模型上工作,API 只是返回一个空的数据数组,即使该项目确实有几个链接文档:

{
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": {
      "href": "https://developer.api.autodesk.com/data/v1/projects/b.19e2199f-4132-4c47-9972-37d4708ea59f/versions/urn:adsk.wipprod:fs.file:vf.ZhP9FgAOTx6T4EV8acbrJg%3Fversion=27/relationships/refs"
    },
    "related": {
      "href": "https://developer.api.autodesk.com/data/v1/projects/b.19e2199f-4132-4c47-9972-37d4708ea59f/versions/urn:adsk.wipprod:fs.file:vf.ZhP9FgAOTx6T4EV8acbrJg%3Fversion=27/refs"
    }
  },
  "data": []
}

Are there any limits for this API?这个API有没有限制? Why would this work on some models and not on the other ones?为什么这适用于某些模型而不适用于其他模型?

暂无
暂无

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

相关问题 如何使用 Forge API 从 model Revit 2022 获取零件类别 - How to get Parts Category from model Revit 2022 using forge API 是否可以通过 Revit API 或 FORGE API 在 Revit 模型中加载新的 Cloud (BIM 360) 链接? - Is it possible to load new Cloud (BIM 360) links in a Revit model either through the Revit API or FORGE API? 如何使用 Autodesk Forge Data Management API 在 BIM360 Docs 中上传工作共享 Revit 模型 - How to Upload a worksharing Revit model in BIM360 Docs using Autodesk Forge Data Management API 如何使用 Forge Design Automation API 将 BIM 360 中的 Revit 文件保存为云 model? - How to save Revit file in BIM 360 as cloud model using Forge Design Automation API? 如何从 Forge 查看器获取 Revit 文件中的资产/房间/楼层、空间列表 - How to get list of assets/rooms/floors, spaces in Revit files from forge viewer 使用 Forge Model 衍生工具将特定 Revit 视图转换为 IFC - Convert Specific Revit View to IFC Using Forge Model Derivatives 伪造查看器模型的Revit位置 - Forge viewer model revit position Forge vuer 不渲染 revit model - Forge vuer not rendering the revit model 无法获取Revit Filemeta数据或在3D查看器中查看Forvit模型衍生API的Revit模型 - Unable to get revit filemeta data or see revit model in 3d viewer for forge modelderivative API 使用Autodesk Forge,如何从Revit Plan视图中获取尺寸对象及其属性? - Using Autodesk Forge, How do I get dimension objects and their properties from a Revit Plan view?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM