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.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let Color = SketchUpApi.Color;
// Get the current style to duplicatelet 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');- Style
- Operation.createDuplicateStyle
- Operation.styleSetName
- Operation.styleUpdateRenderingOptions
- Operation.setSelectedStyle
- Operation.entityForRef
SDK 2.26.0 Protocol 1.23.0
Properties
Section titled “Properties”sketchupId
Section titled “sketchupId”
readonlysketchupId:SketchupId
readonlytype:Style=EntityType.Style
Accessors
Section titled “Accessors”typeName
Section titled “typeName”Get Signature
Section titled “Get Signature”get typeName():
string
Returns a named variant of the type field.
SDK 2.35.0
Returns
Section titled “Returns”string
Methods
Section titled “Methods”toString()
Section titled “toString()”toString():
string
Returns
Section titled “Returns”string