Selection
A snapshot of the drawing elements currently selected in SketchUp.
Retrieve the selection with model.getSelection(). It captures what
the user has selected at a point in time — clicking, dragging, or
triple-clicking in the viewport updates the selection. Because it’s
a snapshot, call refresh() if the user changes their selection
after you fetched it, or use model.observeSelectionMetadata() to
be notified automatically whenever the selection changes.
Use model.getSelectionMetadata() if you only need counts and flags
(like isCurve or isSingleObject) without downloading the full
list of entities.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let sel = await model.getSelection();
console.log(sel.drawingElements.length);// => number of selected entities
console.log(sel.isSingleObject);// => true if exactly one thing is selected
// Later, after the user makes changes...let updated = await sel.refresh();SDK 2.14.0 Protocol 1.11.0
Properties
Section titled “Properties”drawingElements
Section titled “drawingElements”
readonlydrawingElements: readonlyDrawingElement[]
The selected entities, respecting the filter that was passed to
getSelection() (if any). Empty array if nothing matches.
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.
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”refresh()
Section titled “refresh()”refresh():
Promise<Selection>
Re-fetches the selection from SketchUp to pick up any changes the user
made since this snapshot was taken. The filter originally passed to
getSelection() is preserved — if you filtered for faces only, the
refresh will also return only faces.
Returns
Section titled “Returns”Promise<Selection>
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let sel = await model.getSelection();console.log(sel.drawingElements.length);
// Later, after the user makes changes...let updated = await sel.refresh();console.log(updated.drawingElements.length);