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.
Example
Section titled “Example”// Get the active editing pathlet model = await SketchUpApi.getActiveModel();let activePath = await model.getActivePath();
// Log each level of nestingactivePath.path.forEach((entry, i) => { const type = entry.constructor.name; console.log(`Level ${i}: ${entry.name} (${type})`);});
// Show the local origin in world coordsconsole.log('Origin:', activePath.transform.origin);SDK 2.17.0 protocol 1.14.0
Properties
Section titled “Properties”
readonlypath: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.
transform
Section titled “transform”
readonlytransform: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.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let activePath = await model.getActivePath();let transform = activePath.transform;
// If the array is empty, they are editing the model rootlet container = activePath.path.at(-1) || model;
// Create a triangle in local coords,// transformed into world spaceawait model.performOperation((op) => { op.createFace(container, [ transform.applyTo([0, 0, 0]), transform.applyTo([100, 0, 0]), transform.applyTo([50, 100, 0]), ]);}, 'Create triangle');Methods
Section titled “Methods”toString()
Section titled “toString()”toString():
string
Returns
Section titled “Returns”string