从Forge externalId转换为IfcGuid [model-derivative-api]

问题描述 投票:0回答:1

参考:

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都有一个属性“ externalId”,格式为8-4-4-4-12-8。我需要将其转换为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。

那么如何执行从externalId转换为elemGuid的第一步?

javascript autodesk-forge forge autodesk-model-derivative ifc
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 === displayName ) {
                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 ) ) 

希望有帮助。

干杯,

© www.soinside.com 2019 - 2024. All rights reserved.