Skip to content

ActivePath

A snapshot of where the user is currently editing inside a SketchUp model.

The active path is like a breadcrumb trail. When the user double-clicks into a group or component, SketchUp tracks the chain of nested containers from the top-level model down to the one being edited. This class gives you that chain so you can inspect or manipulate it.

// Get the active editing path
let model = await SketchUpApi.getActiveModel();
let activePath = await model.getActivePath();
// Log each level of nesting
activePath.path.forEach((entry, i) => {
const type = entry.constructor.name;
console.log(`Level ${i}: ${entry.name} (${type})`);
});
// Show the local origin in world coords
console.log('Origin:', activePath.transform.origin);

SDK 2.17.0 protocol 1.14.0

readonly path: ActivePathEntity[]

An ordered array of groups and component instances from the outermost container down to the one currently open for editing. The last element is the one you’re editing inside of.


readonly transform: Transformation

Converts local coordinates to world coordinates for the current editing context.

When you create geometry inside a nested component, SketchUp expects world coordinates. Use this transformation to convert your local positions into the world-space values SketchUp needs.

Operation.createFace

let model = await SketchUpApi.getActiveModel();
let activePath = await model.getActivePath();
let transform = activePath.transform;
// If the array is empty, they are editing the model root
let container = activePath.path.at(-1) || model;
// Create a triangle in local coords,
// transformed into world space
await model.performOperation((op) => {
op.createFace(container, [
transform.applyTo([0, 0, 0]),
transform.applyTo([100, 0, 0]),
transform.applyTo([50, 100, 0]),
]);
}, 'Create triangle');