Get the Currently Selected Prims

USD does not have a concept of a selection, but in Kit, you can select prims enabling users and extensions to then use manipulators and tools on the selection or perform actions upon the selection. This snippet shows you how you can get the list of currently selected prim paths on the stage.

import omni.usd

prim_path = "/World/My/Prim"
ctx = omni.usd.get_context()
# returns a list of prim path strings
selection = ctx.get_selection().get_selected_prim_paths()

usdview Python interpreter has a built-in object called usdviewApi that gives you access to the currently selected prims.

from typing import List
from pxr import Usd

prims: List[Usd.Prim] = usdviewApi.selectedPrims