Search code examples
autodesk-forge

Selection in aggregated view scenario in forge viewer


I’m trying to select elements in a multi-model scenario using the getAggregateSelection(selection) function. This function used to work fine earlier but has started resulting in the following error:

"viewer3D.min.js:18 Uncaught TypeError: Cannot read properties of undefined (reading 'length') at viewer3D.min.js:18:1301021 at u.setSelection (viewer3D.min.js:18:1301094) at c.setAggregateSelection (viewer3D.min.js:18:1305012) at C.de.setAggregateSelection (viewer3D.min.js:18:638482) at <anonymous>:1:15"

The getAggregateSelction function is working fine.


Solution

  • Just tried the setAggregateSelection in one of my samples, and it seems to be working fine. Are you sure you're using the correct format for the input parameter? It should be:

    viewer.setAggregateSelection([
      {
        model: someModelInstance,
        ids: [123, 456]
      },
      {
        model: anotherModelInstance,
        ids: [789]
      }
    ]);
    

    enter image description here