View
Access to the SketchUp viewport — camera, screenshots, and view dimensions.
Get this object from model.view. Use it to read or set the
current camera, capture screenshots, watch for camera changes
as the user navigates, and query viewport size.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();
// Read the viewport dimensionslet info = await model.view.getViewInfo();console.log(info.vpWidth, info.vpHeight);// => 839 730
// Reposition the cameralet cam = SketchUpApi.Camera.default() .setOrientation( [0, -500, 200], [0, 0, 0], [0, 0, 1] );await model.view.setCamera(cam.build());SDK 2.8.0 Protocol 1.6.0
Methods
Section titled “Methods”getCamera()
Section titled “getCamera()”getCamera():
Promise<Camera>
Fetches the current camera as a raw data object. Wrap it
with new Camera(rawCam) if you need helper methods like
setFieldOfView or setOrientation.
NOTE as of SDK 2.35.0 this method now returns a Camera instead of a CameraData
Returns
Section titled “Returns”Promise<Camera>
SDK 2.8.0 Protocol 1.6.0
getScreenshot()
Section titled “getScreenshot()”getScreenshot(
fileType,options?):Promise<string>
Fetches the current viewport as a base64 data URL.
Supported formats are 'png', 'jpg', and 'gif'.
GIF is not supported on SketchUp Web.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
image format — |
|
|
screenshot dimensions and quality settings |
Returns
Section titled “Returns”Promise<string>
SDK 2.8.0 Protocol 1.6.0
getViewInfo()
Section titled “getViewInfo()”getViewInfo():
Promise<Readonly<ViewInfo>>
Fetches the current viewport dimensions, center point, and graphics engine name. Useful for positioning overlays or computing screen-space coordinates.
Returns
Section titled “Returns”Promise<Readonly<ViewInfo>>
SDK 2.8.0 Protocol 1.6.0
observeCamera()
Section titled “observeCamera()”observeCamera(
callback):ObserverHandle
Calls callback each time the user moves the camera —
panning, orbiting, or zooming. Returns a handle to stop
observing.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
( |
invoked with the updated camera data |
Returns
Section titled “Returns”SDK 2.30.0 Protocol 1.6.0
observeViewInfo()
Section titled “observeViewInfo()”observeViewInfo(
callback):ObserverHandle
Calls callback each time the viewport dimensions or
graphics engine changes. Returns a handle you can use to
stop observing.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
( |
Returns
Section titled “Returns”SDK 2.30.0 Protocol 1.6.0
setCamera()
Section titled “setCamera()”setCamera(
camera,transitionTimeSeconds?):Promise<void>
Moves the viewport to the given camera position. Pass the
output of camera.build() or any SketchupCamera object.
Supply the optional transitionTimeSeconds for an animated fly-to.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the camera data to apply |
|
|
|
|
animated transition duration in seconds |
Returns
Section titled “Returns”Promise<void>
SDK 2.8.0 Protocol 1.6.0
toString()
Section titled “toString()”toString():
string
Returns
Section titled “Returns”string
Deprecated
Section titled “Deprecated”currentScene()
Section titled “currentScene()”currentScene():
Promise<Scene|undefined>
Queries the model for the current scene (if any)
Returns
Section titled “Returns”Promise<Scene | undefined>
the current scene, or undefined if there are no scenes in the model
SDK 2.9.0 Protocol 1.7.0
scenes()
Section titled “scenes()”scenes(
filter?):Promise<Scene[]>
Queries the model for the current list of scenes
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”Promise<Scene[]>
the list of scenes
SDK 2.9.0 Protocol 1.7.0
setCurrentScene()
Section titled “setCurrentScene()”setCurrentScene(
scene):Promise<void>
Sets the current scene for the model
NOTE: that this does not need an operation. it’s more of a view thing
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene to make current |
Returns
Section titled “Returns”Promise<void>
SDK 2.9.0 Protocol 1.7.0
streamCamera()
Section titled “streamCamera()”streamCamera(
callback):ObserverHandle
Initiates a stream of updates for camera information from SketchUp
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
( |
callback invoked everytime the camera is changed in SketchUp |
Returns
Section titled “Returns”SDK 2.8.0 Protocol 1.6.0
streamViewInfo()
Section titled “streamViewInfo()”streamViewInfo(
callback):ObserverHandle
Initiates a stream of updates for view information from SketchUp
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
( |
Returns
Section titled “Returns”SDK 2.8.0 Protocol 1.6.0