0

I uploaded linked files to bim360 and use Forge to view the central file. I want to distinguish elements of file central and file linked, any way to do it?

Eason Kang
  • 6,155
  • 1
  • 7
  • 24
Jihai
  • 110
  • 8

1 Answers1

1

Yeah, it's possible to achieve this request. We can leverage the AecModelData to get linked model data and rebuild relationships from the PropertyDB inside APS Viewer.

// Get linked documents data 
let model = viewer.getAllModels()[0];
const aecData = await Autodesk.Viewing.Document.getAecModelData(model.getDocumentNode());
let rvtLinks = aecData.linkedDocuments;

// Get linked elements of given link instance id
function getExternalIdMappingAsync( model ) {
    return new Promise( ( resolve, reject ) => {
        model.getExternalIdMapping(
            map => resolve( map ),
            error => reject( error )
        );
    });
}

let instanceId = rvtLinks[0].instanceId;
let model = viewer.getAllModels()[0];
let externalIdMap = await getExternalIdMappingAsync( model );
let entities = Object.entries(externalIdMap);
let linkedElementIds = rvtLinkExternalIds.map(instanceId => {
                return entities.filter(entity => entity[0].includes(`${instanceId}/`)).map(entity => entity[1]);
})
  .flat();

You can find more details here:

enter image description here

References:

Eason Kang
  • 6,155
  • 1
  • 7
  • 24