Selection
These methods allow you to programmatically select or hide elements in the display. User-driven selection changes are also exposed as polling state properties (see State Properties).
setSelectedElements()
Programmatically selects a set of elements by their IDs. This replaces the current selection — passing an empty array clears the selection.
This is the programmatic equivalent of clicking elements in the Objects Tree.
setSelectedElements(ids: number[]): void;
var ctrl = Visu.page0.display1.getController();
// Select elements with IDs 1 and 2
ctrl.setSelectedElements([1, 2]);
// Clear selection
ctrl.setSelectedElements([]);
setHiddenElements()
Hides a set of elements by their IDs. Hidden elements are not rendered in the display. Passing an empty array makes all elements visible again.
This is the programmatic equivalent of toggling the eye icon on an element or group in the Objects Tree — the effect is identical.
setHiddenElements(ids: number[]): void;
// Hide element with ID 5
ctrl.setHiddenElements([5]);
// Make all elements visible
ctrl.setHiddenElements([]);
Reading selection changes
When the user selects elements interactively in the display, the change is exposed as polling state on the controller. See selectedIdsChanged and selectedIds in State Properties.
// INIT script
global var ctrl = Visu.page0.display1.getController();
// CYCLIC script
if (ctrl.selectedIdsChanged) {
ctrl.selectedIdsChanged = false;
var ids = ctrl.selectedIds;
// react to new selection...
}
Both setSelectedElements() and setHiddenElements() are fire and forget — they send a one-shot request to the client and return immediately. They do not set any persistent state on the controller: if the display is not mounted at the time of the call (e.g. the full-screen view is closed), the request is silently discarded with no effect. There is no queuing or retry.