Tools
Access to SketchUp’s active tool — read it, watch for changes, and trigger component placement.
Get this object from model.tools. Use it to detect which
tool the user has active, react when they switch tools, or
programmatically activate the component placement tool.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();
// Watch for tool activationslet handle = model.tools.observeToolChanges( change => { if (change.event === 'Activation') { console.log(change.tool.name); // => 'PaintTool', 'RectangleTool', etc. } });
// Stop observing when donehandle.stop();SDK 1.19.0 protocol 1.16.0
Methods
Section titled “Methods”clearActiveTool()
Section titled “clearActiveTool()”clearActiveTool():
Promise<Tool>
Deactivates any active tool and returns the user to Select mode.
Returns
Section titled “Returns”Promise<Tool>
SDK 1.19.0 protocol 1.16.0
getActive()
Section titled “getActive()”getActive():
Promise<Tool>
Returns the currently active tool, if any.
Returns
Section titled “Returns”Promise<Tool>
SDK 1.19.0 protocol 1.16.0
observeToolChanges()
Section titled “observeToolChanges()”observeToolChanges(
callback):ObserverHandle
Calls callback on every tool lifecycle event — initial
state, activation, and state changes. Returns a handle to
stop observing.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
( |
invoked with each |
Returns
Section titled “Returns”SDK 2.30.0 protocol 1.16.0
placeComponentOnce()
Section titled “placeComponentOnce()”placeComponentOnce(
component):Promise<ComponentInstance|undefined>
Activates the place-component tool and waits for the user
to click to place it, then resolves with the placed
ComponentInstance. Resolves with undefined if the user
cancels. If the user deletes the component definition
before placing, the snapshot is invalidated.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component definition to place |
Returns
Section titled “Returns”Promise<ComponentInstance | undefined>
the placed instance, or undefined if cancelled
placeComponentRepeatedly()
Section titled “placeComponentRepeatedly()”placeComponentRepeatedly(
component,callback?):Promise<ComponentInstance[]>
Activates the place-component tool in multi-place mode,
letting the user stamp multiple instances. Each time the
user places an instance the optional callback is called.
Resolves with the full array of placed instances when the
user cancels or switches to another tool.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component definition to place |
|
|
|
( |
invoked after each placement with the new instances |
Returns
Section titled “Returns”Promise<ComponentInstance[]>
toString()
Section titled “toString()”toString():
string
Returns
Section titled “Returns”string
Deprecated
Section titled “Deprecated”streamToolChanges()
Section titled “streamToolChanges()”streamToolChanges(
callback):ObserverHandle
Streams changes to the current active tool
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
( |
invoked on every tool change |
Returns
Section titled “Returns”SDK 1.19.0 protocol 1.16.0