Skip to content

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.

let model = await SketchUpApi.getActiveModel();
// Read the viewport dimensions
let info = await model.view.getViewInfo();
console.log(info.vpWidth, info.vpHeight);
// => 839 730
// Reposition the camera
let 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

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

Promise<Camera>

SDK 2.8.0 Protocol 1.6.0


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.

Parameter Type Description

fileType

ImageFileType

image format — 'png', 'jpg', or 'gif'

options

ScreenshotOptions

screenshot dimensions and quality settings

Promise<string>

SDK 2.8.0 Protocol 1.6.0


getViewInfo(): Promise<Readonly<ViewInfo>>

Fetches the current viewport dimensions, center point, and graphics engine name. Useful for positioning overlays or computing screen-space coordinates.

Promise<Readonly<ViewInfo>>

SDK 2.8.0 Protocol 1.6.0


observeCamera(callback): ObserverHandle

Calls callback each time the user moves the camera — panning, orbiting, or zooming. Returns a handle to stop observing.

Parameter Type Description

callback

(camera) => void

invoked with the updated camera data

ObserverHandle

SDK 2.30.0 Protocol 1.6.0


observeViewInfo(callback): ObserverHandle

Calls callback each time the viewport dimensions or graphics engine changes. Returns a handle you can use to stop observing.

Parameter Type

callback

(viewInfo) => void

ObserverHandle

SDK 2.30.0 Protocol 1.6.0


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.

Parameter Type Description

camera

CameraData | Camera

the camera data to apply

transitionTimeSeconds?

number

animated transition duration in seconds

Promise<void>

SDK 2.8.0 Protocol 1.6.0


toString(): string

string

currentScene(): Promise<Scene | undefined>

Queries the model for the current scene (if any)

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(filter?): Promise<Scene[]>

Queries the model for the current list of scenes

Parameter Type

filter?

SketchupEntityFilter

Promise<Scene[]>

the list of scenes

SDK 2.9.0 Protocol 1.7.0


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

Parameter Type Description

scene

Scene | SceneRef

the scene to make current

Promise<void>

SDK 2.9.0 Protocol 1.7.0


streamCamera(callback): ObserverHandle

Initiates a stream of updates for camera information from SketchUp

Parameter Type Description

callback

(camera) => void

callback invoked everytime the camera is changed in SketchUp

ObserverHandle

SDK 2.8.0 Protocol 1.6.0


streamViewInfo(callback): ObserverHandle

Initiates a stream of updates for view information from SketchUp

Parameter Type

callback

(viewInfo) => void

ObserverHandle

SDK 2.8.0 Protocol 1.6.0