SectionPlane
This example demonstrates how to create a section plane in SketchUp, set its plane, symbol, and name using the JavaScript SDK.
Prerequisites
Section titled “Prerequisites”- You have a
SketchupModelinstance (e.g., fromSketchup.getActiveModel()). - The protocol version supports section planes (SDK 2.16.0 / Protocol 1.13.0 or later).
Example
Section titled “Example”Creating a SectionPlane
Section titled “Creating a SectionPlane”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');Setting and Getting the Plane
Section titled “Setting and Getting the 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');Activating a SectionPlane
Section titled “Activating a SectionPlane”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');Deactivating a SectionPlane
Section titled “Deactivating a SectionPlane”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');Querying Only Active SectionPlanes
Section titled “Querying Only Active SectionPlanes”let model = await SketchUpApi.getActiveModel();let activeSectionPlanes = await model.getActiveSectionPlanes();console.log('Active section planes:', activeSectionPlanes);