Sandbox — LSD is in active testing. All systems operational·payments are test-mode (no real charges).
Overview Use Cases News Docs Tool Store Support Community Get LSD
All docs
Docs/ API Reference/ Context/ selection
Context· property

Context.selection

the user's current selection, if any

Python
selection: Selection

Returns Selection — the current selection (entities/rows), or None

Example#

Python
@tool.command("demo/count_selected")
def count_selected(ctx: Context):
    n = len(ctx.selection) if ctx.selection else 0

Notes#

A lazily populated slot — None when nothing is selected or the invoking surface has no selection. Guard before iterating.

See also#

API: entity · ui · Context

Guides: Commands & actions

By LSD Team · Last updated Jul 17, 2026 Ask on Discord View as Markdown