ComponentInstanceRef
A lightweight placeholder for a ComponentInstance that hasn’t been fully loaded yet.
When you place component instances inside a SketchupOperation,
the API returns ComponentInstanceRef objects immediately, before
SketchUp has finished creating the instance. You can pass these refs
to other operation methods that accept component instances, but if
you need the full ComponentInstance object, you can request
it with entityForRef().
Think of a ref as a “claim ticket” — it guarantees a component
instance will exist after the operation commits, but it doesn’t
carry the instance’s properties (name, transformation, 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 { Transformation } = SketchUpApi;
await model.performOperation(async op => { const defRef = op.createDefinition('Chair'); // Add a seat to the definition op.createFace(defRef, [ [0, 0, 18], [18, 0, 18], [18, 18, 18], [0, 18, 18], ]); // Place two chairs side by side op.createInstance( model, defRef, Transformation.translation([0, 0, 0]) ); op.createInstance( model, defRef, Transformation.translation([24, 0, 0]) );}, 'Place two chairs');Properties
Section titled “Properties”sketchupId
Section titled “sketchupId”
readonlysketchupId:SketchupId
readonlytype:ComponentInstance=EntityType.ComponentInstance
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