how do i get a list of link files from a translated compressedzip file?

You can take advantage of the AecModelData to get linked models data and rebuild relationships from the PropertyDB inside Forge Viewer.

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:

  • Object extetnal id: ffa0b0a8-8aab-48f9-beb5-dba5d9b4968f-0010cfee/e021b7a9-1e57-428c-87db-8e087322cd49-0015a0f6
  • An instanceId from the linkedDocuments in the AECModelData: ffa0b0a8-8aab-48f9-beb5-dba5d9b4968f-0010cfee

You can see the GUID on the left side of the slash symbol matches the instance id mentioned above.

enter image description here

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

Here is the snapshot of my test:

enter image description here

Hope it helps~

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top