0

参考:

https://thebuildingcoder.typepad.com/blog/2009/02/uniqueid-dwf-and-ifc-guid.html

https://github.com/Autodesk-Forge/bim360appstore-model.derivative-nodejs-xls.exporter

https://gist.github.com/jsdbroughton/8ead390ad03f9e26658a80f461276472

按照示例“bim360appstore-model.derivative-nodejs-xls.exporter”,我可以从 BIM360 模型中导出元数据。每个 forgeObject 都有一个格式为 8-4-4-4-12-8 的属性“externalId”。我需要将其转换为 IfcGuid(22 个字符长)。

使用 Revit C# API 时,我必须调用

 Guid elemGuid = ExportUtils.GetExportId(element.Document, element.Id);

 String ifcGuid = IfcGuid.ToIfcGuid(elemGuid);

获取 ifcGuid。如何在 Forge 环境中使用 JavaScript 做同样的事情?

我试过了,使用上面参考资料中 J. Broughton 的 JS 代码,但函数 fromFullToCompressed() 的输入数据是 8-4-4-4-12 值,而不是 8-4-4-4- 12-8 外部标识。

那么如何进行从 externalId 到 elemGuid 的第一步转换呢?

4

1 回答 1

0

目前,IFC 模型由 Navisworks 翻译管道处理。因此,外部 id 遵循 Navisworks 的规则。这是选择树的节点路径,详细信息请参见我的答案:https ://stackoverflow.com/a/56985615/7745569

要在 Forge Viewer 中搜索项目IfcGUIDs,您可以执行自定义 PropertyDb 查询:

// Assume there are two IFC Guids: 2cgXCjpDT0ZxBvxMSr3pfm, 0LKJKCHUL1kBtnlFXddz6a

function userFunction( pdb, idVals ) {
    const attrName = 'IfcGUID';

    // Now iterate over all parts to find out which one is the largest.
    const result = [];

    pdb.enumObjects(( dbId ) => {
        // For each part, iterate over their properties.
        pdb.enumObjectProperties( dbId, ( attrId, valId ) => {
            const def = pdb.getAttributeDef( attrId );

            const propName = def.name;
            const displayName = def.displayName;

            if( propName === attrName || displayName === attrName ) {
                const value = pdb.getAttrValue( attrId, valId );
                if( idVals.includes( value ) ) {
                    result.push( dbId );
                    return true;
                }
            }
        });
    });

    // Return results
    return result;
}

NOP_VIEWER.model.getPropertyDb().executeUserFunction( userFunction, [ '2cgXCjpDT0ZxBvxMSr3pfm', '0LKJKCHUL1kBtnlFXddz6a' ] ).then( ( result ) => console.log( result ) ) 

笔记。IFC 模型必须由基于 Revit 的 IFC 转换管道处理,因此请在此处查看指令以切换加载器:https ://forge.autodesk.com/blog/model-derivative-ifc-pipeline-call-change

希望能帮助到你。

干杯,

于 2019-10-07T09:23:17.810 回答