Skip to content

SectionPlane

This example demonstrates how to create a section plane in SketchUp, set its plane, symbol, and name using the JavaScript SDK.

  • You have a SketchupModel instance (e.g., from Sketchup.getActiveModel()).
  • The protocol version supports section planes (SDK 2.16.0 / Protocol 1.13.0 or later).
let model = await SketchUpApi.getActiveModel();
await model.performOperation(async operation => {
const plane = [0, 0, 1, 0];
const sectionPlane = operation.createSectionPlane(model, plane);
operation.sectionPlaneSetSymbol(sectionPlane, 'A');
operation.sectionPlaneSetName(sectionPlane, 'Main Cut');
operation.sectionPlaneActivate(sectionPlane);
console.log(sectionPlane);
}, 'Create a section plane');
let model = await SketchUpApi.getActiveModel();
await model.performOperation(async operation => {
const plane = [0, 0, 1, 0];
const sectionPlaneRef = operation.createSectionPlane(model, plane);
// Set a new plane
const newPlane = [0, 0, 1, -10];
operation.sectionPlaneSetPlane(sectionPlaneRef, newPlane);
// Get the updated plane
const sectionPlane = await operation.entityForRef(sectionPlaneRef);
console.log('Updated plane:', sectionPlane.plane);
}, 'Set/get section plane');
let model = await SketchUpApi.getActiveModel();
await model.performOperation(async operation => {
const plane = [0, 0, 1, 0];
const sectionPlaneRef = operation.createSectionPlane(model, plane);
operation.sectionPlaneActivate(sectionPlaneRef);
const sectionPlane = await operation.entityForRef(sectionPlaneRef);
console.log('Active:', sectionPlane.active); // true
}, 'Activate section plane');
let model = await SketchUpApi.getActiveModel();
await model.performOperation(async operation => {
const plane = [0, 0, 1, 0];
const sectionPlaneRef = operation.createSectionPlane(model, plane);
operation.sectionPlaneActivate(sectionPlaneRef);
// Now deactivate
operation.sectionPlaneDeactivate(sectionPlaneRef);
const sectionPlane = await operation.entityForRef(sectionPlaneRef);
console.log('Active:', sectionPlane.active); // false
}, 'Deactivate section plane');
let model = await SketchUpApi.getActiveModel();
let activeSectionPlanes = await model.getActiveSectionPlanes();
console.log('Active section planes:', activeSectionPlanes);