Skip to content

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.

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 needed
let sel = await meta.getSelection();

SDK 2.14.0 Protocol 1.11.0

readonly isCurve: boolean

True if the selection forms a continuous chain of connected edges, like a polyline or circle. Useful for curve-editing operations.


readonly isSingleObject: boolean

True if exactly one entity is selected — handy for single-object workflows like editing properties or applying materials.


readonly isSurface: boolean

True if all selected entities belong to a single continuous surface (one or more coplanar faces). Useful for surface-editing operations.


readonly matchingDrawingElements: number

Number of selected entities that match the filter passed to getSelectionMetadata(), or total count if no filter was given.


readonly totalNumberOfElements: number

Total number of selected entities in SketchUp, ignoring any filter. Use this to detect if the filter excluded some selected items.

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().

Promise<Selection>

A Selection with the full list of entities.

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(): 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.

Promise<SelectionMetadata>

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(): string

string