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

查看:70
本文介绍了我如何从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.

现在,我想创建一个像'Model Browser'这样的扩展名,它将把根文件名显示为顶部或父节点,并将所有链接文件的名称显示为子节点.该链接文件应在查看器中隔离,并且通过单击根文件",所有元素(包括所有链接文件元素)都应显示.

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.如果外部标识包含斜杠符号,则表示它来自链接的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-0015a0f6
  • AECModelData中的linkedDocuments中的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天全站免登陆