如何从 Revit 文件的已翻译压缩/zip 文件中获取链接文件列表? [英] How can i get the list of link files from a translated compressed/zip of revit file?

查看:24
本文介绍了如何从 Revit 文件的已翻译压缩/zip 文件中获取链接文件列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我翻译了一个包含多个链接文件的 revit 文件.从查看器中,我可以浏览根 revit 模型中的所有元素,包括使用模型浏览器"默认扩展名的链接文件中的所有元素.甚至我还创建了一个自定义扩展,从中我可以隔离每个对象类型的所有元素.

I have translated a revit file with several link files. From viewer i can browse all elements from the root revit model including all elements from link files using 'Model Browser' default extension. Even i also created a custom extension from where i can isolate each object type's all elements.

现在,我想创建一个像模型浏览器"这样的扩展名,它将根文件名显示为顶部或父节点,将所有链接文件的名称显示为子节点.我还希望,通过单击每个链接文件,来自该链接文件应在查看器中隔离,通过单击根文件,应显示所有元素,包括所有链接文件元素.

Now, i want to create a extension like 'Model Browser', which will show Root file name as top or parent node and all link file's name as child node.I also want, by clicking each link file, all elements from that link file should isolate in the viewer and by clicking Root file, all elements including all link files elements should show .

有关信息,我的应用程序是在 .Net 平台上使用 C# 和 JavaScript 构建的.

For information, my application is built using C# and JavaScript in .Net platform.

谁能告诉我哪个api,我可以试试?如果有人分享示例或网址,我可以获得帮助,这也会非常有帮助.

Can anyone advice me which api, i can try? It would be also very helpful if someone share examples or url where i can get help.

提前致谢!

推荐答案

您可以利用 AecModelData 从 Forge Viewer 内的 PropertyDB 获取链接模型数据并重建关系.

You can take advantage of the AecModelData to get linked models data and rebuild relationships from the PropertyDB inside Forge Viewer.

如果对象来自链接的 RVT,您可以检查其外部 ID.如果外部 ID 包含斜杠符号,则这意味着它来自链接的 RVT.下面是一个例子:

If an object is from the linked RVT, you can check its' external id. If the external id contains a slash symbol, then this means it is from a linked RVT. Here is an example:

  • 对象外部 ID:ffa0b0a8-8aab-48f9-beb5-dba5d9b4968f-0010cfee/e021b7a9-1e57-428c-87db-8e087322cd49-0015a0f>
  • 来自 AECModelData 中链接文档的 instanceId:ffa0b0a8-8aab-48f9-beb5-dba5d9b4968f-0010cfee

您可以看到斜线符号左侧的 GUID 与上面提到的实例 ID 匹配.

You can see the GUID on the left side of the slash symbol matches the instance id mentioned above.

要获取链接的RVT模型名称,我们可以重用AECModelData的linkedDocuments中的instanceId来再次获取我们需要的信息.这是给您的代码片段,假设实例 ID 为 ffa0b0a8-8aab-48f9-beb5-dba5d9b4968f-0010cfee:

To get the linked RVT model name, we can reuse the instanceId from the linkedDocuments of the AECModelData to get the information we need again. Here is a code snippet for you, and assume the instance id is ffa0b0a8-8aab-48f9-beb5-dba5d9b4968f-0010cfee:

function getExternalIdMappingAsync( model ) {
    return new Promise( ( resolve, reject ) => {
        model.getExternalIdMapping(
            map => resolve( map ),
            error => reject( error )
        );
    });
}

function getPropertiesAsync( dbId, viewer ) {
    return new Promise( ( resolve, reject ) => {
        viewer.getProperties(
            dbId,
            result => resolve( result ),
            error => reject( error )
        );
    });
}

//1.  Get external id mapping for converting external id to Viewer's dbId
let externalIdMapping = await getExternalIdMappingAsync( viewer.model );
let dbId = externalIdMapping['ffa0b0a8-8aab-48f9-beb5-dba5d9b4968f-0010cfee'];

//2. Get properties of the linked model instance
let propResult = await getPropertiesAsync( dbId, viewer )

//3. Find the type name property for its value
let linkNameProp = propResult.properties.find( prop => prop.displayName == 'Type Name' || prop.attributeName == 'Type Name' );
let linkName = linkNameProp.displayValue; //!<<< This is linked RVT name

这是我的测试快照:

希望能帮到你~

这篇关于如何从 Revit 文件的已翻译压缩/zip 文件中获取链接文件列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆