参考文献:
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?
答案 0 :(得分: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 ) )
希望有帮助。
干杯