# Question about getSelectedLayers API

**URL:** https://forum.techsoft3d.com/t/question-about-getselectedlayers-api/5082
**Category:** Help
**Tags:** webviewer
**Created:** [February 11, 2026, 7:54pm UTC](https://forum.techsoft3d.com/t/question-about-getselectedlayers-api/5082 "2026-02-11T19:54:43Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nick.wong](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@nick.wong](https://forum.techsoft3d.com/u/nick.wong)
#### Post date: [February 11, 2026, 7:54pm UTC](https://forum.techsoft3d.com/t/question-about-getselectedlayers-api/5082/1 "2026-02-11T19:54:43Z")

</div>

In the sample source 2024.3.0, when user clicks the layer item in the model browser, it will trigger selectLayer API which trigger a clear selection and layer related nodes selection.

In LayersTree.js and TreeControl.js, I notice that when the latter selection triggers the selectionArray callback, the getSelectedLayers is still empty. So I would like to know if there is callback will be triggered when the getSelectedLayers reflects the actual situation?

I guess the async execution of \_updateTreeSelectionHighlight in \_doSelection in TreeControl.js is for handling my question.

```auto
// LayersTree.js
...
selectionArray: (events) => {
        if (this._layerNames.length === 0) {
          return;
        }
        this._tree.updateSelection(events);
...
}

// TreeControl.js
_doSelection(...) {
            this._selectionLabelHighlightTimer.set(30, () => {
                const selectionIds = this._viewer.selectionManager.getResults().map((item) => item.getNodeId());
                this._updateTreeSelectionHighlight(selectionIds);
            });
}

_updateLayerTreeSelectionHighlight(...) {
...
this._selectedLayers = this._viewer.selectionManager.getSelectedLayers();
}

```

Thank you

---

<div class="post-metadata">

### Author: ![tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tino](https://forum.techsoft3d.com/u/tino)
#### Post date: [February 12, 2026, 10:43pm UTC](https://forum.techsoft3d.com/t/question-about-getselectedlayers-api/5082/2 "2026-02-12T22:43:55Z")

</div>

@nick.wong,

When the [selectionArray](https://partner.support.techsoft3d.com/servicedesk/customer/portal/12) callback is triggered, the class `SelectionManager` method [getSelectedLayers](https://docs.techsoft3d.com/hoops/visualize-web/api_ref/viewing/classes/Selection.SelectionManager.html#wv.Selection.SelectionManager.getSelectedLayers) returns `null` because `layers` is not part of the [SelectionItem](https://docs.techsoft3d.com/hoops/visualize-web/api_ref/viewing/classes/Selection.SelectionItem.html#wv.Selection.SelectionItem) class . The `SelectionItem` class returns entities such as `PointEntity`, `FaceEntity` and `LineEntity`.

Perhaps the best way forward is for you to create a feature request in our [Support Portal](https://partner.support.techsoft3d.com/servicedesk/customer/portal/12) if this is functionality you are very interested in.
