SelectionMetadata
Lightweight selection information — just counts and flags, no entity data.
Retrieve it with model.getSelectionMetadata() or stream changes with
model.streamSelectionMetadata(). Use this when you only care about
“how many?” or “is it a curve?” without fetching the full list of
entities — it’s much faster for large selections.
Call getSelection() if you later need the full entity list with
geometry and properties.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let meta = await model.getSelectionMetadata();
console.log(meta.totalNumberOfElements);// => total count of selected entities
if (meta.isCurve) { console.log('User selected a curve');}
// Fetch full entities if neededlet sel = await meta.getSelection();SDK 2.14.0 Protocol 1.11.0
Properties
Section titled “Properties”isCurve
Section titled “isCurve”
readonlyisCurve:boolean
True if the selection forms a continuous chain of connected edges, like a polyline or circle. Useful for curve-editing operations.
isSingleObject
Section titled “isSingleObject”
readonlyisSingleObject:boolean
True if exactly one entity is selected — handy for single-object workflows like editing properties or applying materials.
isSurface
Section titled “isSurface”
readonlyisSurface:boolean
True if all selected entities belong to a single continuous surface (one or more coplanar faces). Useful for surface-editing operations.
matchingDrawingElements
Section titled “matchingDrawingElements”
readonlymatchingDrawingElements:number
Number of selected entities that match the filter passed to
getSelectionMetadata(), or total count if no filter was given.
totalNumberOfElements
Section titled “totalNumberOfElements”
readonlytotalNumberOfElements:number
Total number of selected entities in SketchUp, ignoring any filter. Use this to detect if the filter excluded some selected items.
Methods
Section titled “Methods”getSelection()
Section titled “getSelection()”getSelection():
Promise<Selection>
Fetches the full selection with entity data and geometry. Use this
when you’ve been working with metadata and now need the actual
entities. The filter is preserved from when you called
getSelectionMetadata().
Returns
Section titled “Returns”Promise<Selection>
A Selection with the full list of entities.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let meta = await model.getSelectionMetadata();
if (meta.isCurve) { // Now fetch the actual edges const sel = await meta.getSelection(); console.log(sel.drawingElements[0].type); // => 1 (Edge type)}refresh()
Section titled “refresh()”refresh():
Promise<SelectionMetadata>
Re-fetches the selection metadata from SketchUp to pick up any
changes the user made since this snapshot was taken. The filter
originally passed to getSelectionMetadata() is preserved.
Returns
Section titled “Returns”Promise<SelectionMetadata>
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let meta = await model.getSelectionMetadata();console.log(meta.totalNumberOfElements);
// Later, after the user makes changes...let updated = await meta.refresh();console.log(updated.totalNumberOfElements);toString()
Section titled “toString()”toString():
string
Returns
Section titled “Returns”string