Skip to content

StyleRef

A lightweight placeholder for a Style that hasn’t been fully loaded yet.

When you duplicate styles inside a SketchupOperation, the API returns StyleRef objects immediately, before SketchUp has finished processing. You can pass these refs to other operation methods (like renaming or activating the style), but if you need the full Style instance, you can request it with entityForRef().

Think of a ref as a “claim ticket” — it guarantees a style will exist after the operation commits, but it doesn’t carry the style’s properties (name, description, rendering options, etc.) yet. A ref is only valid inside the performOperation callback that created it — do not return it or use it after the operation commits.

let model = await SketchUpApi.getActiveModel();
let Color = SketchUpApi.Color;
// Get the current style to duplicate
let selected = await model.getSelectedStyle();
let currentStyle = selected.style;
await model.performOperation(async op => {
const styleRef = op.createDuplicateStyle(
currentStyle
);
op.styleSetName(styleRef, 'Green Ground');
op.styleUpdateRenderingOptions(styleRef, {
GroundColor: new SketchUpApi.Color(120, 140, 110),
DrawGround: true,
});
op.setSelectedStyle(styleRef);
}, 'Duplicate style with green ground');

SDK 2.26.0 Protocol 1.23.0

readonly sketchupId: SketchupId


readonly type: Style = EntityType.Style

get typeName(): string

Returns a named variant of the type field.

SDK 2.35.0

string