1

Thank you all in advance for your help.

My problem is that in the model browser I can't see the elements organized by model. They are all seen together in no order. I have been able to load linked files via jobpayload with rootFilename. I have seen a lot of information about it but if someone has done it or has an idea of how to do it, I would greatly appreciate the help or start. All the best.

Example

  • Goal: Model 1 -category 1 -Family -Type -Element -Element2 -category 2 -Family -Type -Element 3 -Element 4 … Model 2 -category 1 -Family -Type -Element 5 – user17356139 Jun 03 '22 at 06:42

1 Answers1

0

If the model is a composite Revit model translation, the host and linked RVT files are translated by a zip package, the model structure will be merged into a single tree, so it won't organize the tree structure by models.

However, we can tell which object is from the linked RVT. See the concept here:

https://stackoverflow.com/a/64672951

and here is a code example that I use this function to get their dbIds.

async getRevitLinkedElementIds(rvtLinkExternalIds, model) {
    const modelKey = model.getModelKey();
    const externalIdMap = this.modelExternalIdMaps[modelKey];
    const entities = Object.entries(externalIdMap);
    const linkedElementIds = rvtLinkExternalIds.map(instanceId => {
        return entities.filter(entity => entity[0].includes(`${instanceId}/`)).map(entity => entity[1]);
    })
        .flat();

    return linkedElementIds;
}

I think you can make use of the linkedElementIds, and then call model.getInstanceTree().getNodeParentId( dbId ) repeatedly until you get the root node id, so that you can get name of non-leaf nodes, e.g., Family Type, Family, and Category, to rebuild your own tree nodes using jstree.js. (Don't use non-leaf nodes' dbIds, since they are shared by the host and linked contents)

enter image description here enter image description here

Afterward, you can build node data of the jstree.js like this for each models (host and links) to expand the tree structure of my custom panel in the code example.

[
  { id1, externalId: -1, type: 'revit-category', text: 'Curtain Panels' },
  { id2, externalId: -1, type: 'revit-family', text: 'System Panel' },
  { id3, externalId: -1, type: 'revit-family-type', text: 'Glazed' },
  { id4, externalId: '03d1b04e-ba90-4a0e-8fe2-eca95236e26a/ab343b7e-3705-4b87-bacc-33c06a6cee1d-000ee82e', type: 'revit-elements', text: 'System Panel [976942]' }
]
Eason Kang
  • 6,155
  • 1
  • 7
  • 24