Scenes
Creating a Scene
Section titled “Creating a Scene”let model = await SketchUpApi.getActiveModel();await model.performOperation(async operation => { const sceneRef = operation.createScene('Scene Name'); const scene = await operation.entityForRef(sceneRef); console.log(scene.name);}, 'Create a Scene');Updating the camera from the current view
Section titled “Updating the camera from the current view”let model = await SketchUpApi.getActiveModel();await model.performOperation(async operation => { operation.sceneUpdate(scene, {use_camera: true});}, 'Update a Scene');Removing a scene
Section titled “Removing a scene”let model = await SketchUpApi.getActiveModel();await model.performOperation(async operation => { operation.removeScene(scene);}, 'Remove a Scene');Programmatically setting scene camera
Section titled “Programmatically setting scene camera”let model = await SketchUpApi.getActiveModel();await model.performOperation(async operation => { operation.sceneSetCamera(scene, SketchUpApi.Camera.default().build());}, 'Update scene');Programmatically setting scene axes
Section titled “Programmatically setting scene axes”let model = await SketchUpApi.getActiveModel();await model.performOperation(async operation => { operation.sceneSetAxes(scene, [0, 10, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]);}, 'Update scene');Programmatically updating scene shadow info
Section titled “Programmatically updating scene shadow info”let model = await SketchUpApi.getActiveModel();await model.performOperation(async operation => { operation.shadowInfoSetCity("Gotham", scene);}, 'Update scene');Programmatically hiding tags/folders
Section titled “Programmatically hiding tags/folders”let model = await SketchUpApi.getActiveModel();await model.performOperation(async operation => { const tag = operation.createTag('new tag'); const tagFolder = operation.createTagFolder('new tag folder'); operation.sceneSetTagVisibility(scene, tag, false); operation.sceneSetTagFolderVisibility(scene, tagFolder, false);}, 'Update scene');Programmatically hiding elements
Section titled “Programmatically hiding elements”let model = await SketchUpApi.getActiveModel();await model.performOperation(async operation => { const face = operation.createFace(model, [[0, 0, 0], [100, 0, 0], [100, 100, 0]]); // note this only works for either top level geometry OR nested component instances and depends on use_hidden_geometry, use_hidden_objects operation.sceneSetDrawingElementVisibility(scene, face, false);}, 'Update scene');