Operation
The mutation API for SketchUp models — every geometry change, material assignment, and entity modification happens through methods on this class.
You receive a SketchupOperation inside the callback passed to
model.performOperation(). The operation batches your instructions and
sends them to SketchUp efficiently. Most methods are synchronous (they
queue instructions without waiting), but you can call await on queries
mid-operation to read back geometry created earlier in the same callback.
Operation refs (like FaceRef, EdgeRef, MaterialRef) are lightweight handles
returned by create methods. They’re only valid within the operation callback
that created them. To read an entity’s properties outside the operation, call
entityForRef(ref) to fetch the full entity object before the callback ends.
Outside the scope of performOperation, the operation is closed and methods
will throw errors.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();
// Create a rectangle, then extrude it.await model.performOperation(op => { // Create a material const red = op.createMaterial('RedBrick'); op.materialSetColor( red, new SketchUpApi.Color(200, 50, 50) );
// Create a face const faceRef = op.createFace(model, [ [0, 0, 0], [100, 0, 0], [100, 100, 0], [0, 100, 0], ]);
// Apply material and extrude op.drawingElementSetMaterial(faceRef, red); op.facePushPull(faceRef, 50);}, 'Create red box');ArcCurve
Section titled “ArcCurve”createArc()
Section titled “createArc()”createArc(
container,center,xaxis,normal,radius,startAngle,endAngle,numSegments?):ArcCurveAndComponents
Creates an arc of a circle on the container.
Because SketchUp intersects and deduplicates edges, multiple curves may result from a single call. This method returns a reference to the curve associated with the first edge. Use Model.findCurvesForEdges to find all curves produced by this instruction.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container to create the arc on. |
|
|
|
The center point of the arc. |
|
|
|
The direction of the xaxis, the angles are taken from this axis. |
|
|
|
The normal of the arc. |
|
|
|
|
The radius of the arc in inches. |
|
|
|
Start angle for the arc, in radians. |
|
|
|
End angle for the arc, in radians. |
|
|
|
the number of segments of the arc (by default 24). |
Returns
Section titled “Returns”ArcCurveAndComponents
An arc and any edges created
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let arc = await model.performOperation(op => { const arcAndEdges = op.createArc(op.model, [0, 0, 0], [1, 0, 0], [0, 0, 1], 50, 0, Math.PI ); return op.entityForRef(arcAndEdges.curve);}, 'Create arc');console.log(arc);SDK 2.30.0 Protocol 1.20.0
ArcCurve for code examples
createCircle()
Section titled “createCircle()”createCircle(
container,center,normal,radius,numSegments?):ArcCurveAndComponents
Creates a full circle on the container. Because SketchUp intersects and deduplicates edges, multiple curves may result from a single call. This method returns a reference to the curve associated with the first edge. Use Model.findCurvesForEdges to find all curves produced by this instruction.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
The container to create the circle on. |
|
|
|
|
The center point of the circle. |
|
|
|
|
The normal vector (perpendicular to the circle plane). |
|
|
|
|
|
The radius in inches. |
|
|
|
|
The number of edge segments (default 24). |
Returns
Section titled “Returns”ArcCurveAndComponents
An arc curve and any edges created.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let circle = await model.performOperation(op => { const circleAndEdges = op.createCircle( op.model, [0, 0, 0], [0, 0, 1], 75 ); return op.entityForRef(circleAndEdges.curve);}, 'Create circle');console.log(circle);SDK 2.30.0 Protocol 1.20.0
ArcCurve for code examples
createNgon()
Section titled “createNgon()”createNgon(
container,center,normal,radius,numSegments?):ArcCurveAndComponents
Creates an n-gon (regular polygon) on the container — similar
to createCircle but also creates a face bounded by the edges.
Because SketchUp intersects and deduplicates edges, multiple curves may result from a single call. This method returns a reference to the curve associated with the first edge. Use Model.findCurvesForEdges to find all curves produced by this instruction.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
The container to create the n-gon on. |
|
|
|
|
The center point. |
|
|
|
|
The normal vector (perpendicular to the polygon plane). |
|
|
|
|
|
The radius in inches. |
|
|
|
|
The number of sides (default 24). |
Returns
Section titled “Returns”ArcCurveAndComponents
An arc curve and any edges created.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let hexagon = await model.performOperation(op => { const ngonAndEdges = op.createNgon( op.model, [0, 0, 0], [0, 0, 1], 50, 6 ); return op.entityForRef(ngonAndEdges.curve);}, 'Create hexagon');console.log(hexagon);SDK 2.30.0 Protocol 1.20.0
ArcCurve for code examples
curveMoveVertices()
Section titled “curveMoveVertices()”curveMoveVertices(
curve,newPoints):void
Moves the vertices of the curve to new positions. The number of points must exactly match the number of vertices in the curve, otherwise SketchUp will throw an error.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the curve |
|
|
the new positions for each vertex |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let curve = await model.performOperation(op => { const curveAndEdges = op.createCurve(op.model, [ [0, 0, 0], [50, 25, 0], [100, 0, 0] ]); op.curveMoveVertices(curveAndEdges.curve, [ [0, 0, 0], [50, 50, 0], [100, 0, 0] ]); return op.entityForRef(curveAndEdges.curve);}, 'Move curve vertices');console.log(curve.vertices.map(v => v.y));// => [0, 50, 0]SDK 2.23.0 Protocol 1.20.0
ComponentDefinition
Section titled “ComponentDefinition”createDefinition()
Section titled “createDefinition()”createDefinition(
name):ComponentDefinitionRef
Creates a new component definition with the given name. If the name already exists, SketchUp appends a randomized suffix to make it unique.
The returned ref is only valid within this operation. To access
the definition after the operation ends, convert it with
entityForRef(defRef).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the name of the component |
Returns
Section titled “Returns”reference to the created component definition
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let def = await model.performOperation(op => { const defRef = op.createDefinition('MyComponent'); op.createFace(defRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); return op.entityForRef(defRef);}, 'Create definition');console.log(def);ComponentDefinition for code examples
SDK 2.30.0
definitionAddClassification()
Section titled “definitionAddClassification()”definitionAddClassification(
ref,schemaName,schemaType):void
Assigns a classification type from a loaded schema (like IFC)
to a component. Once classified, the component carries metadata
that other tools (BIM software, exporters) can read. Load
schemas first with modelLoadSchemaFromUrl.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component or component reference |
|
|
|
|
the name of the loaded classification schema |
|
|
|
the type within that schema to assign |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Load IFC schema, skipping if already loaded const schemas = await model.getClassifications(); const isLoaded = schemas.some( s => s.name === 'IFC 2x3' ); if (!isLoaded) { const url = 'https://cdn.habitat.sketchup.com/' + 'classifications/schemas/IFC2x3.skc'; await op.modelLoadSchemaFromUrl(url); } // Create component with geometry const defRef = op.createDefinition('DoorComp'); await op.createBuilder((builder) => { // Vertical door-shaped rectangle (X/Z plane) builder.createFace([ [0, 0, 0], [36, 0, 0], [36, 0, 80], [0, 0, 80] ]); }).build(defRef); // Add classification op.definitionAddClassification( defRef, 'IFC 2x3', 'IfcDoor' );}, 'Add IFC classification');SDK 2.30.0 Protocol 1.3.0
definitionRemoveClassification()
Section titled “definitionRemoveClassification()”definitionRemoveClassification(
ref,schemaName,schemaType):void
Removes a previously assigned classification from a component, stripping the associated schema metadata. Useful when the component’s type changes or the classification was assigned in error.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component or component reference |
|
|
|
|
the name of the classification schema |
|
|
|
the type to remove |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Load IFC schema, skipping if already loaded const schemas = await model.getClassifications(); const isLoaded = schemas.some( s => s.name === 'IFC 2x3' ); if (!isLoaded) { const url = 'https://cdn.habitat.sketchup.com/' + 'classifications/schemas/IFC2x3.skc'; await op.modelLoadSchemaFromUrl(url); } // Create component with geometry const defRef = op.createDefinition('DoorComp'); await op.createBuilder((builder) => { // Vertical door-shaped rectangle (X/Z plane) builder.createFace([ [0, 0, 0], [36, 0, 0], [36, 0, 80], [0, 0, 80] ]); }).build(defRef); // Add and remove classification op.definitionAddClassification( defRef, 'IFC 2x3', 'IfcDoor' ); op.definitionRemoveClassification( defRef, 'IFC 2x3', 'IfcDoor' );}, 'Remove classification');SDK 2.30.0 Protocol 1.3.0
definitionSetClassificationValue()
Section titled “definitionSetClassificationValue()”definitionSetClassificationValue(
ref,path,value):void
Sets a specific property value within a component’s
classification data. The path navigates the classification
hierarchy to the target attribute, like
['IFC 2x3', 'IfcDoor', 'Name', 'IfcLabel'].
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component or component reference |
|
|
|
|
key path to the classification attribute |
|
|
the value to set (must be valid for that attribute’s type) |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Load IFC schema, skipping if already loaded const schemas = await model.getClassifications(); const isLoaded = schemas.some( s => s.name === 'IFC 2x3' ); if (!isLoaded) { const url = 'https://cdn.habitat.sketchup.com/' + 'classifications/schemas/IFC2x3.skc'; await op.modelLoadSchemaFromUrl(url); } // Create component with geometry const defRef = op.createDefinition('DoorComp'); await op.createBuilder((builder) => { // Vertical door-shaped rectangle (X/Z plane) builder.createFace([ [0, 0, 0], [36, 0, 0], [36, 0, 80], [0, 0, 80] ]); }).build(defRef); // Add classification and set property op.definitionAddClassification( defRef, 'IFC 2x3', 'IfcDoor' ); op.definitionSetClassificationValue( defRef, ['IFC 2x3', 'IfcDoor', 'Name', 'IfcLabel'], 'MainEntrance' );}, 'Set classification value');SDK 2.30.0 Protocol 1.3.0
definitionSetDescription()
Section titled “definitionSetDescription()”definitionSetDescription(
ref,value):void
Sets the description for a component definition. The description appears in the Component Browser and can explain what the component represents, its design intent, or usage instructions.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component or component reference |
|
|
|
|
the description text |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const defRef = op.createDefinition('DoorFrame'); await op.createBuilder((builder) => { // Vertical rectangle on the X/Z plane builder.createFace([ [0, 0, 0], [36, 0, 0], [36, 0, 80], [0, 0, 80] ]); }).build(defRef); op.definitionSetDescription( defRef, 'Standard wooden frame for doors' );}, 'Set component description');SDK 2.30.0
definitionSetName()
Section titled “definitionSetName()”definitionSetName(
ref,value):void
Renames a component definition. The name appears in the Component Browser and must be unique within the model — SketchUp may append a suffix if a conflict exists. Renaming here updates the definition; instance names are separate.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component or component reference |
|
|
|
|
the new name |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const defRef = op.createDefinition('OldName'); await op.createBuilder((builder) => { // Vertical rectangle on the X/Z plane builder.createFace([ [0, 0, 0], [50, 0, 0], [50, 0, 50], [0, 0, 50] ]); }).build(defRef); op.definitionSetName(defRef, 'WindowFrame');}, 'Rename component');SDK 2.30.0
definitionSetNoScaleMask()
Section titled “definitionSetNoScaleMask()”definitionSetNoScaleMask(
ref,value):void
Controls which axes and planes are locked when the user scales an instance of this component. Use this to prevent non-uniform scaling on certain axes — for example, to keep a column always uniform in X/Z while allowing Y (height) to stretch freely.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component or component reference |
|
|
|
|
which scaling axes/planes are locked |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();
await model.performOperation(op => { const defRef = op.createDefinition('ScaleTestColumn');
// Build a cube inside the definition const faceRef = op.createFace(defRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0], ]); op.facePushPull(faceRef, 100);
// Lock X and Y — only Z (up/down) can scale op.definitionSetNoScaleMask(defRef, { disableRed: true, disableBlue: true, disableRedBlue: true, disableRedGreen: true, });
op.createInstance( model, defRef, SketchUpApi.Transformation.IDENTITY );}, 'Create scale-locked column');SDK 2.30.0
definitionSetShadowsToFaceSun()
Section titled “definitionSetShadowsToFaceSun()”definitionSetShadowsToFaceSun(
ref,value):void
Controls whether the shadow cast by this component always faces the sun, regardless of the component’s actual geometry. When enabled, the shadow behaves like a flat plane perpendicular to the sun — commonly used for 2D tree or person cutouts.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component or component reference |
|
|
|
|
when true, the shadow always faces the sun |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const treeGreen = op.createMaterial('TreeGreen'); op.materialSetColor( treeGreen, new SketchUpApi.Color(34, 139, 34) ); const defRef = op.createDefinition('Tree'); await op.createBuilder((builder) => { return builder.createFace([ [0, 0, 0], [100, 0, 0], [100, 100, 0], [0, 100, 0] ]); }).onPostBuild((converter, buildFaceRef) => { const faceRef = converter.asRef(buildFaceRef); op.drawingElementSetMaterial(faceRef, treeGreen); op.facePushPull(faceRef, 250); }).build(defRef); op.definitionSetShadowsToFaceSun( defRef, true );}, 'Create sun-facing shadow component');SDK 2.30.0
definitionSetTo2d()
Section titled “definitionSetTo2d()”definitionSetTo2d(
ref,value):void
Marks this component as a 2D flat cutout that always faces the camera. This is the “Always face camera” option in the Component Options panel — useful for trees, people, and other billboard- style objects that should always appear face-on to the viewer.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component or component reference |
|
|
|
|
when true, the component always rotates to face the camera |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const green = op.createMaterial('Green'); op.materialSetColor( green, new SketchUpApi.Color(144, 238, 144) ); const defRef = op.createDefinition('Billboard'); await op.createBuilder((builder) => { return builder.createFace([ [0, 0, 0], [100, 0, 0], [100, 0, 0], [0, 100, 0] ]); }).onPostBuild((converter, buildFaceRef) => { const faceRef = converter.asRef(buildFaceRef); op.drawingElementSetMaterial(faceRef, green); }).build(defRef); op.definitionSetTo2d(defRef, true); op.createInstance( op.model, defRef, SketchUpApi.Transformation.IDENTITY );}, 'Create billboard component');SDK 2.30.0
definitionSetToCutOpening()
Section titled “definitionSetToCutOpening()”definitionSetToCutOpening(
ref,value):void
Controls whether instances of this component automatically cut a hole through any face they are placed on. Useful for doors, windows, and other components that need an opening in a wall.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component or component reference |
|
|
|
|
when true, placed instances cut an opening in faces |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let def = await model.performOperation(async op => { const brown = op.createMaterial('Brown'); op.materialSetColor( brown, new SketchUpApi.Color(139, 69, 19) ); const defRef = op.createDefinition('WindowHole'); await op.createBuilder((builder) => { // 2d components are modeled on the XY plane frame (X/Y plane) with a // hole cut in the middle return builder.createFace( [ [0, 0, 0], [100, 0, 0], [100, 100, 0], [0, 100, 0] ], [[ [75, 25, 0], [75, 75, 0], [25, 75, 0], [25, 25, 0] ]] ); }).onPostBuild((converter, buildFaceRef) => { const faceRef = converter.asRef(buildFaceRef); op.drawingElementSetMaterial(faceRef, brown); }).build(defRef); op.definitionSetTo2d(defRef, true); op.definitionSetToSnapTo(defRef, SketchUpApi.ComponentSnapTo.Vertical); op.definitionSetToCutOpening(defRef, true); return op.entityForRef(defRef);}, 'Create cut-opening component');
console.log('Glue the component to a vertical face to see the behavior');SDK 2.30.0
definitionSetToFaceCamera()
Section titled “definitionSetToFaceCamera()”definitionSetToFaceCamera(
ref,value):void
Controls whether instances of this component automatically rotate to face the camera (like 2D trees or people cutouts). When enabled, the component’s front face always points toward the viewer regardless of the camera angle.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component definition or reference |
|
|
|
|
|
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const pink = op.createMaterial('Pink'); op.materialSetColor( pink, new SketchUpApi.Color(255, 105, 180) ); const defRef = op.createDefinition('SignBoard'); await op.createBuilder((builder) => { return builder.createFace([ [0, 0, 0], [80, 0, 0], [80, 0, 80], [0, 0, 80] ]); }).onPostBuild((converter, buildFaceRef) => { const faceRef = converter.asRef(buildFaceRef); op.drawingElementSetMaterial(faceRef, pink); }).build(defRef); op.definitionSetTo2d(defRef, true); op.definitionSetToFaceCamera(defRef, true);}, 'Create face-camera component');SDK 2.30.0
definitionSetToSnapTo()
Section titled “definitionSetToSnapTo()”definitionSetToSnapTo(
ref,value):void
Controls what surface the component snaps to when the user places or moves an instance. For example, a chair component can snap to horizontal floors, a picture can snap to vertical walls, or a light can snap to sloped ceilings.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component or component reference |
|
|
|
the surface type this component snaps to when placed |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const gold = op.createMaterial('Gold'); op.materialSetColor( gold, new SketchUpApi.Color(255, 215, 0) ); const defRef = op.createDefinition('PictureFrame'); await op.createBuilder((builder) => { // 2D snapping components must be modeled on the X/Y plane. return builder.createFace([ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); }).onPostBuild((converter, buildFaceRef) => { const faceRef = converter.asRef(buildFaceRef); op.drawingElementSetMaterial(faceRef, gold); }).build(defRef); op.definitionSetTo2d(defRef, true); op.definitionSetToSnapTo(defRef, SketchUpApi.ComponentSnapTo.Vertical );}, 'Create snap-to-vertical component');SDK 2.30.0
loadDefinition()
Section titled “loadDefinition()”loadDefinition(
options):Promise<ComponentDefinitionRef>
Loads a component definition from an external resource (URL,
Blob, or data URL) and adds it to the model. The resource must
be a valid .skp file. Use this to import pre-built components
from a library or CDN.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
resource and loading configuration |
Returns
Section titled “Returns”Promise<ComponentDefinitionRef>
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const defRef = await op.loadDefinition({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/models/Bed.skp' } }); op.createInstance( op.model, defRef, SketchUpApi.Transformation.IDENTITY );}, 'Load component from CDN');SDK 2.30.0 Protocol 1.4.0
Throws
Section titled “Throws”ComponentLoadError if SketchUp cannot parse the resource or the endpoint returns a non-2xx status
purgeUnusedDefinitions()
Section titled “purgeUnusedDefinitions()”purgeUnusedDefinitions():
void
Removes all component definitions that have zero instances placed in the model. This reduces file size by cleaning up definitions that are no longer in use.
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Load a definition but never place an instance await op.loadDefinition({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/models/Bed.skp' } }); // Purge removes it since it's unused op.purgeUnusedDefinitions();}, 'Purge unused definitions');SDK 2.30.0
removeDefinition()
Section titled “removeDefinition()”removeDefinition(
ref):void
Permanently removes a component definition from the model. All placed instances of this definition are also deleted.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component definition or reference to remove |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const defRef = await op.loadDefinition({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/models/Bed.skp' } }); op.removeDefinition(defRef);}, 'Remove component definition');SDK 2.30.0
ComponentInstance
Section titled “ComponentInstance”createInstance()
Section titled “createInstance()”createInstance(
ref,componentRef,transform?):ComponentInstanceRef
Places an instance of a component definition into the model. Component instances are reusable copies of a shared definition — editing the definition updates all instances. The optional transformation positions, rotates, and scales the instance relative to its parent container’s axes.
Returns a ComponentInstanceRef that’s valid only within this operation. To
read the instance’s properties or use it outside the operation callback,
call entityForRef(instanceRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the instance will be placed (model, group, or another component instance). |
|
|
|
The component definition to instantiate. |
|
|
|
Optional transformation to apply to the instance. Defaults to identity (origin with no rotation or scaling). |
Returns
Section titled “Returns”A reference to the newly created component instance.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let defs = await model.getDefinitions();if (defs.length === 0) { console.log('there are no definitions');} else { let instance = await model.performOperation(op => { const instanceRef = op.createInstance( op.model, defs[0] ); return op.entityForRef(instanceRef); }, 'Create instance'); console.log(instance);}- ComponentInstance for code examples
- entityForRef
SDK 2.30.0
instanceApplyTransformation()
Section titled “instanceApplyTransformation()”instanceApplyTransformation(
ref,transformation):void
Multiplies the component instance’s current transformation by
the given transformation, moving or rotating it relative to its
current position. Use this for incremental movement. To set an
absolute position, use instanceSetTransformation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component instance or component instance reference |
|
|
|
the transformation to compound with the current one |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create instance at originlet instanceRef = await model.performOperation( async op => { const bedDef = await op.loadDefinition({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/models/Bed.skp' } }); const ref = op.createInstance( op.model, bedDef, SketchUpApi.Transformation.translation( [300, 0, 0] ) ); return op.entityForRef(ref); }, 'Create instance at origin');// Second operation: apply relative transformationawait model.performOperation(op => { op.instanceApplyTransformation( instanceRef, SketchUpApi.Transformation.translation( [0, 100, 0] ) );}, 'Apply instance transformation');SDK 2.30.0 Protocol 0.4.0
instanceSetGluedTo()
Section titled “instanceSetGluedTo()”instanceSetGluedTo(
entity,element):void
Attaches (glues) a component instance or group to a face,
so it moves and rotates with that face. Gluing is how windows
stay in walls and decals stick to surfaces. Pass undefined
to detach the instance from its current face.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the group or component instance to glue |
|
|
|
|
the face to glue it to, or |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Floor face on the X/Y plane const floorRef = op.createFace(op.model, [ [300, 0, 0], [500, 0, 0], [500, 500, 0], [300, 500, 0] ]); const bedDef = await op.loadDefinition({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/models/Bed.skp' } }); // Glueable components must allow gluing op.definitionSetTo2d(bedDef, true); const instanceRef = op.createInstance( op.model, bedDef, SketchUpApi.Transformation.translation( [400, 0, 0] ) ); op.instanceSetGluedTo(instanceRef, floorRef);}, 'Glue instance to floor face');SDK 2.30.0 Protocol 1.18.0
instanceSetLocked()
Section titled “instanceSetLocked()”instanceSetLocked(
ref,value):void
Locks or unlocks a component instance. Locked instances cannot be moved, edited, or deleted by the user in the viewport.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component instance or component instance reference |
|
|
|
|
|
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const bedDef = await op.loadDefinition({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/models/Bed.skp' } }); const instanceRef = op.createInstance( op.model, bedDef, SketchUpApi.Transformation.translation( [100, 0, 0] ) ); op.instanceSetLocked(instanceRef, true);}, 'Lock component instance');SDK 2.30.0 Protocol 0.4.0
instanceSetName()
Section titled “instanceSetName()”instanceSetName(
ref,value):void
Gives a component instance a user-visible name. Each instance can have its own name independent of its definition name — this shows in the Outliner panel and Entity Info.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component instance or component instance reference |
|
|
|
|
the display name, like |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const bedDef = await op.loadDefinition({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/models/Bed.skp' } }); const instanceRef = op.createInstance( op.model, bedDef, SketchUpApi.Transformation.translation( [0, 0, 0] ) ); op.instanceSetName(instanceRef, 'GuestBed');}, 'Set instance name');SDK 2.30.0 Protocol 1.2.0
instanceSetTransformation()
Section titled “instanceSetTransformation()”instanceSetTransformation(
ref,transformation):void
Replaces the component instance’s transformation with a new
one, absolutely positioning and orienting it within its
container. Use this for exact placement. To move an instance
relative to its current position, use instanceApplyTransformation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component instance or component instance reference |
|
|
|
the new absolute transformation within its container |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create instance at originlet instanceRef = await model.performOperation( async op => { const bedDef = await op.loadDefinition({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/models/Bed.skp' } }); const ref = op.createInstance( op.model, bedDef, SketchUpApi.Transformation.translation( [200, 0, 0] ) ); return op.entityForRef(ref); }, 'Create instance at origin');// Second operation: set absolute transformationawait model.performOperation(op => { op.instanceSetTransformation( instanceRef, SketchUpApi.Transformation.translation( [200, 100, 0] ) );}, 'Set instance transformation');SDK 2.30.0 Protocol 0.4.0
ConstructionLine
Section titled “ConstructionLine”constructionLineReverse()
Section titled “constructionLineReverse()”constructionLineReverse(
ref):void
Reverses the direction of a construction line, swapping its start and end points (or flipping the direction vector for infinite lines).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the construction line or reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create a simple linelet lineRef = await model.performOperation(op => { const ref = op.createConstructionLine( op.model, new SketchUpApi.Point3d(600, 0, 0), new SketchUpApi.Point3d(600, 100, 0) ); return op.entityForRef(ref);}, 'Create construction line');// Second operation: reverse start/endawait model.performOperation(op => { op.constructionLineReverse(lineRef);}, 'Reverse construction line');SDK 2.7.0 Protocol 1.5.0
constructionLineSetDirection()
Section titled “constructionLineSetDirection()”constructionLineSetDirection(
ref,direction):void
Sets the direction vector of a construction line. For infinite lines, this determines the angle of the guide. For finite lines, the direction is derived from start/end points.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the construction line or reference |
|
|
|
the new direction vector |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create an infinite linelet lineRef = await model.performOperation(op => { const ref = op.createConstructionLine( op.model, new SketchUpApi.Point3d(300, 0, 0), new SketchUpApi.Vector3d(0, 1, 0) ); return op.entityForRef(ref);}, 'Create infinite construction line');// Second operation: change its directionawait model.performOperation(op => { op.constructionLineSetDirection( lineRef, new SketchUpApi.Vector3d(0, 1, 1) );}, 'Set construction line direction');SDK 2.7.0 Protocol 1.5.0
constructionLineSetEnd()
Section titled “constructionLineSetEnd()”constructionLineSetEnd(
ref,end):void
Sets the end point of a construction line, making it
finite at the end. Pass null to make the line infinite
(extending infinitely in the end direction).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the construction line or reference |
|
|
|
the end point, or |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create a simple linelet lineRef = await model.performOperation(op => { const ref = op.createConstructionLine( op.model, new SketchUpApi.Point3d(150, 0, 0), new SketchUpApi.Point3d(150, 100, 0) ); return op.entityForRef(ref);}, 'Create construction line');// Second operation: move the end pointawait model.performOperation(op => { op.constructionLineSetEnd( lineRef, new SketchUpApi.Point3d(150, 50, 0) );}, 'Set construction line end');SDK 2.7.0 Protocol 1.5.0
constructionLineSetPosition()
Section titled “constructionLineSetPosition()”constructionLineSetPosition(
ref,position):void
Moves the construction line to pass through a new 3D point, while preserving its direction. Useful for sliding a guide line to a new position without changing its angle.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the construction line or reference |
|
|
|
the new point the line should pass through |
Returns
Section titled “Returns”void
SDK 2.7.0 Protocol 1.5.0
constructionLineSetStart()
Section titled “constructionLineSetStart()”constructionLineSetStart(
ref,start):void
Sets the start point of a construction line, making it
finite at the start. Pass null to make the line infinite
(extending infinitely in the start direction).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the construction line or reference |
|
|
|
the start point, or |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create a simple linelet lineRef = await model.performOperation(op => { const ref = op.createConstructionLine( op.model, new SketchUpApi.Point3d(50, 0, 0), new SketchUpApi.Point3d(50, 100, 0) ); return op.entityForRef(ref);}, 'Create construction line');// Second operation: move the start pointawait model.performOperation(op => { op.constructionLineSetStart( lineRef, new SketchUpApi.Point3d(50, 50, 0) );}, 'Set construction line start');SDK 2.7.0 Protocol 1.5.0
constructionLineSetStipple()
Section titled “constructionLineSetStipple()”constructionLineSetStipple(
ref,stipple):void
Set Construction Line stipple - the pattern used to display the Construction Line
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
of Construction Line |
|
|
|
|
string / number |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create a simple linelet lineRef = await model.performOperation(op => { const ref = op.createConstructionLine( op.model, new SketchUpApi.Point3d(450, 0, 0), new SketchUpApi.Point3d(450, 100, 0) ); return op.entityForRef(ref);}, 'Create construction line');// Second operation: change the stipple patternawait model.performOperation(op => { op.constructionLineSetStipple(lineRef, '.');}, 'Set construction line stipple');SDK 2.7.0 Protocol 1.5.0
Valid strings are:
- ”.” (Dotted Line),
- ”-” (Short Dashes Line),
- ”_” (Long Dashes Line),
- ”-.-” (Dash Dot Dash Line).
createConstructionLine()
Section titled “createConstructionLine()”createConstructionLine(
ref,start,end,stipple?):ConstructionLineRef
Creates a construction line, which is guide geometry that helps with snapping and alignment but doesn’t appear in rendered output. You can create a finite line segment (by passing two points) or an infinite ray (by passing a start point and a direction vector). The stipple parameter controls the line’s dash pattern.
Returns a ConstructionLineRef that’s valid only within this operation. To
read the line’s properties or use it outside the operation callback, call
entityForRef(constructionLineRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
The container where the construction line will be created (model, group, or component instance). |
|
|
|
|
The starting point of the line in 3D space (inches). |
|
|
|
|
Either an end point (for a finite segment) or a direction vector (for an infinite ray). |
|
|
|
|
|
The dash pattern, like ”-” for solid or ”.” for dotted. Defaults to ”-”. |
Returns
Section titled “Returns”A reference to the newly created construction line.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let line = await model.performOperation(op => { const lineRef = op.createConstructionLine( op.model, new SketchUpApi.Point3d(0, 0, 0), new SketchUpApi.Point3d(100, 100, 0) ); return op.entityForRef(lineRef);}, 'Create construction line');console.log(line);- ConstructionLine for code examples
- entityForRef
SDK 2.30.0 Protocol 1.5.0
ConstructionPoint
Section titled “ConstructionPoint”createConstructionPoint()
Section titled “createConstructionPoint()”createConstructionPoint(
ref,point):ConstructionPointRef
Creates a construction point at the given 3D location. Construction points are guide geometry — they don’t appear in rendered output but help with snapping and alignment during modeling. They’re often used to mark key locations like centers, intersections, or reference heights.
Returns a ConstructionPointRef that’s valid only within this operation. To
read the point’s properties or use it outside the operation callback, call
entityForRef(constructionPointRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the construction point will be created (model, group, or component instance). |
|
|
|
The 3D position in inches. |
Returns
Section titled “Returns”A reference to the newly created construction point.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let point = await model.performOperation(op => { const pointRef = op.createConstructionPoint(op.model, [50, 50, 50]); return op.entityForRef(pointRef);}, 'Create construction point');console.log(point);- ConstructionPoint for code examples
- entityForRef
SDK 2.30.0 Protocol 1.5.0
createCurve()
Section titled “createCurve()”createCurve(
container,points):CurveAndComponents
Creates a curve from an arbitrary list of points. Edges are drawn connecting consecutive points, and the resulting edge chain is grouped as a curve.
Because SketchUp intersects and deduplicates edges, multiple curves may result from a single call. This method returns a reference to the curve associated with the first edge. Use Model.findCurvesForEdges to find all curves produced by this instruction.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container to create the curve on. |
|
|
|
The points that define the curve’s path. |
Returns
Section titled “Returns”CurveAndComponents
A curve and any edges created.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let curve = await model.performOperation(op => { const curveAndEdges = op.createCurve(op.model, [ [0, 0, 0], [50, 25, 0], [100, 0, 0], [100, 50, 0] ]); return op.entityForRef(curveAndEdges.curve);}, 'Create curve');console.log(curve);SDK 2.30.0 Protocol 1.20.0
Curve for code examples
createCurveByWeldingEdges()
Section titled “createCurveByWeldingEdges()”createCurveByWeldingEdges(
edges):Promise<CurveRef[]>
Welds the given edges together into one or more curves. All edges must share the same parent container, otherwise SketchUp will throw an error.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The edges to weld. |
Returns
Section titled “Returns”Promise<CurveRef[]>
The curve refs resulting from the weld.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let curves = await model.performOperation(op => { const edgeRefs = op.createEdge(op.model, [ [0, 50, 0], [25, 100, 0], [50, 75, 0], [50, 25, 0], [25, 0, 0] ]); return op.createCurveByWeldingEdges( edgeRefs );}, 'Weld C-shaped edges');console.log(curves);Curve for code examples
SDK 2.30.0 Protocol 1.20.0
curveMoveVertices()
Section titled “curveMoveVertices()”curveMoveVertices(
curve,newPoints):void
Moves the vertices of the curve to new positions. The number of points must exactly match the number of vertices in the curve, otherwise SketchUp will throw an error.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the curve |
|
|
the new positions for each vertex |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let curve = await model.performOperation(op => { const curveAndEdges = op.createCurve(op.model, [ [0, 0, 0], [50, 25, 0], [100, 0, 0] ]); op.curveMoveVertices(curveAndEdges.curve, [ [0, 0, 0], [50, 50, 0], [100, 0, 0] ]); return op.entityForRef(curveAndEdges.curve);}, 'Move curve vertices');console.log(curve.vertices.map(v => v.y));// => [0, 50, 0]SDK 2.23.0 Protocol 1.20.0
DimensionLinear
Section titled “DimensionLinear”createDimensionLinear()
Section titled “createDimensionLinear()”createDimensionLinear(
container,start,end,offset):DimensionLinearRef
Creates a linear dimension that measures the distance between two points. The offset vector controls how far the dimension line is displaced from the measured geometry and must not be zero length.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the container to place the dimension in |
|
|
|
the first measurement point (vertex, edge midpoint, or free point) |
|
|
|
the second measurement point |
|
|
|
non-zero vector displacing the dimension line from the geometry |
Returns
Section titled “Returns”A reference to the linear dimension
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [100, 0, 0], [100, 100, 0], [50, 0, 0] ); return op.entityForRef(dimRef);}, 'Create dimension');console.log(dim);Dimension between a construction point and edge:
let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const cpRef = op.createConstructionPoint( op.model, [200, 50, 0] ); const edgeRefs = op.createEdge(op.model, [ [0, 0, 0], [100, 0, 0] ]); const dimRef = op.createDimensionLinear( op.model, { entity: cpRef }, { entity: edgeRefs[0], point: [50, 0, 0] }, [0, 50, 0] ); return op.entityForRef(dimRef);}, 'Create dimension with edge');console.log(dim);Dimension with instance path:
let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const edgeRefs = op.createEdge(op.model, [ [0, 100, 0], [100, 100, 0] ]); const dimRef = op.createDimensionLinear( op.model, { point: [0, 200, 0] }, { instancePath: [edgeRefs[0]], point: [100, 100, 0] }, [0, 50, 0] ); return op.entityForRef(dimRef);}, 'Create dimension with instance path');console.log(dim);SDK 2.30.0 Protocol 1.20.0
DimensionLinear for code examples
dimensionLinearSetAlignedTextPosition()
Section titled “dimensionLinearSetAlignedTextPosition()”dimensionLinearSetAlignedTextPosition(
dimension,textPosition):void
Sets the position of the text label relative to the dimension line when the dimension has aligned text enabled. Controls whether the text sits above, below, or on the line. Values come from DimensionAlignedTextPosition.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
the aligned text position |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [700, 0, 0], [700, 100, 0], [20, 0, 0] ); op.dimensionSetHasAlignedText(dimRef, true); op.dimensionLinearSetAlignedTextPosition( dimRef, SketchUpApi.DimensionAlignedTextPosition.Outside ); return op.entityForRef(dimRef);}, 'Position aligned dimension text');console.log(dim.alignedTextPosition);// => 2SDK 2.23.0 Protocol 1.20.0
dimensionLinearSetEnd()
Section titled “dimensionLinearSetEnd()”dimensionLinearSetEnd(
dimension,point):void
Moves the end attachment point of a linear dimension to a new location. The dimension line will update to span from the start point to this new end point.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
the new end attachment point |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dimEntity = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [400, 0, 0], [400, 100, 0], [20, 0, 0] ); return op.entityForRef(dimRef);}, 'Create dimension');
let moved = await model.performOperation(op => { op.dimensionLinearSetEnd( dimEntity, [400, 150, 0] ); return op.entityForRef(dimEntity);}, 'Move dimension end');console.log(moved.endPoint);// => Point3d { x: 400, y: 150, z: 0 }SDK 2.23.0 Protocol 1.20.0
dimensionLinearSetOffset()
Section titled “dimensionLinearSetOffset()”dimensionLinearSetOffset(
dimension,offset):void
Sets the offset vector controlling how far the dimension line is displaced from the measured geometry. The vector points in the direction and distance to where the dimension text and line are drawn.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
the offset vector from the geometry to the dimension line |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dimEntity = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [500, 0, 0], [500, 100, 0], [20, 0, 0] ); return op.entityForRef(dimRef);}, 'Create dimension');
let moved = await model.performOperation(op => { op.dimensionLinearSetOffset( dimEntity, [50, 0, 0] ); return op.entityForRef(dimEntity);}, 'Increase dimension offset');console.log(moved.offsetVector);// => Vector3d { x: 50, y: 0, z: 0 }SDK 2.23.0 Protocol 1.20.0
dimensionLinearSetStart()
Section titled “dimensionLinearSetStart()”dimensionLinearSetStart(
dimension,point):void
Moves the start attachment point of a linear dimension to a new location. The dimension line will update to span from this new start point to the end point.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
the new start attachment point |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dimEntity = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [300, 0, 0], [300, 100, 0], [20, 0, 0] ); return op.entityForRef(dimRef);}, 'Create dimension');
let moved = await model.performOperation(op => { op.dimensionLinearSetStart( dimEntity, [300, 50, 0] ); return op.entityForRef(dimEntity);}, 'Move dimension start');console.log(moved.startPoint);// => Point3d { x: 300, y: 50, z: 0 }SDK 2.23.0 Protocol 1.20.0
dimensionLinearSetTextPosition()
Section titled “dimensionLinearSetTextPosition()”dimensionLinearSetTextPosition(
dimension,textPosition):void
Sets where the text label appears relative to the dimension line — for example, inside the extension lines, outside them, or centered. Values come from DimensionTextPosition.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
the text position relative to the dimension line |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [600, 0, 0], [600, 100, 0], [20, 0, 0] ); op.dimensionLinearSetTextPosition( dimRef, SketchUpApi.DimensionTextPosition.OutsideStart ); return op.entityForRef(dimRef);}, 'Center dimension text');console.log(dim.textPosition);// => 1SDK 2.23.0 Protocol 1.20.0
dimensionSetArrowType()
Section titled “dimensionSetArrowType()”dimensionSetArrowType(
dimension,arrowType):void
Sets the arrowhead style used at both endpoints of a dimension. The type controls whether endpoints show filled arrows, open arrows, dots, slashes, or nothing. Values come from DimensionArrowType.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
the new arrow type |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [100, 0, 0], [100, 100, 0], [20, 0, 0] ); op.dimensionSetArrowType( dimRef, SketchUpApi.DimensionArrowType.Open ); return op.entityForRef(dimRef);}, 'Set dimension arrow type');console.log(dim.arrowType);// => 4SDK 2.23.0 Protocol 1.20.0
dimensionSetHasAlignedText()
Section titled “dimensionSetHasAlignedText()”dimensionSetHasAlignedText(
dimension,hasAlignedText):void
Controls whether the dimension text label aligns with the measurement line (rotated to follow the line) or always stays horizontal regardless of the dimension’s orientation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
|
when true, text rotates to follow the dimension line |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [200, 0, 0], [200, 100, 0], [20, 0, 0] ); op.dimensionSetHasAlignedText(dimRef, true); return op.entityForRef(dimRef);}, 'Align dimension text');console.log(dim.hasAlignedText);// => trueSDK 2.23.0 Protocol 1.20.0
dimensionSetText()
Section titled “dimensionSetText()”dimensionSetText(
dimension,text):void
Overrides the auto-generated measurement text with a custom string. Pass an empty string to revert to the automatic value (the measured distance or radius).
Include ”<>” to add text generated from the measurement.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
|
the custom label text, or empty string for auto |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [0, 0, 0], [0, 100, 0], [20, 0, 0] ); op.dimensionSetText(dimRef, 'Wall span <>'); return op.entityForRef(dimRef);}, 'Set dimension text');console.log(dim.text);// => "Wall span"SDK 2.23.0 Protocol 1.20.0
DimensionRadial
Section titled “DimensionRadial”createDimensionRadial()
Section titled “createDimensionRadial()”createDimensionRadial(
container,arcCurve,leaderBreakPoint):DimensionRadialRef
Creates a radial dimension that displays the radius (or diameter) of an arc or circle. The leader break point sets where the leader line bends on its way to the text label.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the container to place the dimension in |
|
|
|
the arc or circle to measure |
|
|
|
the 3D point where the leader line bends |
Returns
Section titled “Returns”A reference to the radial dimension
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const circleAndEdges = op.createCircle( op.model, [0, 0, 0], [0, 0, 1], 50 ); const dimRef = op.createDimensionRadial( op.model, circleAndEdges.curve, [75, 75, 0] ); return op.entityForRef(dimRef);}, 'Create radial dimension');console.log(dim);SDK 2.30.0 Protocol 1.20.0
DimensionRadial for code examples
dimensionRadialSetArcCurve()
Section titled “dimensionRadialSetArcCurve()”dimensionRadialSetArcCurve(
dimension,arcCurve):void
Changes which arc or circle a radial dimension is measuring. The dimension will update to display the radius (or diameter) of the new arc curve.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
the arc or circle to measure |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let [dim, curve2] = await model.performOperation(async op => { const circle1 = op.createCircle( op.model, [800, 0, 0], [0, 0, 1], 30 ); const circle2 = op.createCircle( op.model, [800, 100, 0], [0, 0, 1], 60 ); const dimRef = op.createDimensionRadial( op.model, circle1.curve, [850, 0, 0] ); return op.entitiesForRefs([dimRef, circle2.curve]);}, 'Create circles and dimension');
let updated = await model.performOperation(op => { op.dimensionRadialSetArcCurve(dim, curve2); return op.entityForRef(dim);}, 'Retarget radial dimension');console.log(updated.text);// => "R60.0"SDK 2.23.0 Protocol 1.20.0
dimensionRadialSetLeaderBreakPoint()
Section titled “dimensionRadialSetLeaderBreakPoint()”dimensionRadialSetLeaderBreakPoint(
dimension,breakpoint):void
Sets the point where the radial dimension’s leader line bends. The leader runs from the arc to this breakpoint, then to the text label, creating the characteristic “elbow” in the line.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
the 3D point where the leader line bends |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dimEntity = await model.performOperation(op => { const circle = op.createCircle( op.model, [900, 0, 0], [0, 0, 1], 40 ); const dimRef = op.createDimensionRadial( op.model, circle.curve, [950, 0, 0] ); return op.entityForRef(dimRef);}, 'Create radial dimension');
let moved = await model.performOperation(op => { op.dimensionRadialSetLeaderBreakPoint( dimEntity, [950, 50, 0] ); return op.entityForRef(dimEntity);}, 'Bend radial leader');console.log(moved.leaderBreakPoint);// => Point3d { x: 950, y: 50, z: 0 }SDK 2.23.0 Protocol 1.20.0
dimensionSetArrowType()
Section titled “dimensionSetArrowType()”dimensionSetArrowType(
dimension,arrowType):void
Sets the arrowhead style used at both endpoints of a dimension. The type controls whether endpoints show filled arrows, open arrows, dots, slashes, or nothing. Values come from DimensionArrowType.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
the new arrow type |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [100, 0, 0], [100, 100, 0], [20, 0, 0] ); op.dimensionSetArrowType( dimRef, SketchUpApi.DimensionArrowType.Open ); return op.entityForRef(dimRef);}, 'Set dimension arrow type');console.log(dim.arrowType);// => 4SDK 2.23.0 Protocol 1.20.0
dimensionSetHasAlignedText()
Section titled “dimensionSetHasAlignedText()”dimensionSetHasAlignedText(
dimension,hasAlignedText):void
Controls whether the dimension text label aligns with the measurement line (rotated to follow the line) or always stays horizontal regardless of the dimension’s orientation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
|
when true, text rotates to follow the dimension line |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [200, 0, 0], [200, 100, 0], [20, 0, 0] ); op.dimensionSetHasAlignedText(dimRef, true); return op.entityForRef(dimRef);}, 'Align dimension text');console.log(dim.hasAlignedText);// => trueSDK 2.23.0 Protocol 1.20.0
dimensionSetText()
Section titled “dimensionSetText()”dimensionSetText(
dimension,text):void
Overrides the auto-generated measurement text with a custom string. Pass an empty string to revert to the automatic value (the measured distance or radius).
Include ”<>” to add text generated from the measurement.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the dimension to modify |
|
|
|
|
the custom label text, or empty string for auto |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let dim = await model.performOperation(op => { const dimRef = op.createDimensionLinear( op.model, [0, 0, 0], [0, 100, 0], [20, 0, 0] ); op.dimensionSetText(dimRef, 'Wall span <>'); return op.entityForRef(dimRef);}, 'Set dimension text');console.log(dim.text);// => "Wall span"SDK 2.23.0 Protocol 1.20.0
Drawing Element
Section titled “Drawing Element”drawingElementErase()
Section titled “drawingElementErase()”drawingElementErase(
ref):void
Permanently removes a drawing element (face, edge, group, etc.) from the model. Connected edges may also be removed if they no longer bound any face.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the drawing element or drawing element reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); op.drawingElementErase(faceRef);}, 'Erase face');console.log('Face erased');drawingElementEraseWithForce()
Section titled “drawingElementEraseWithForce()”drawingElementEraseWithForce(
ref):void
Removes a drawing element even if it’s a locked group or component instance. Automatically unlocks the element before erasing it.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the drawing element or drawing element reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.groupSetLocked(groupRef, true); op.drawingElementEraseWithForce(groupRef);}, 'Erase locked group');console.log('Locked group erased');drawingElementsApplyTransformation()
Section titled “drawingElementsApplyTransformation()”drawingElementsApplyTransformation(
refs,transform,options?):void
Moves, rotates, or scales one or more drawing elements (or vertices) by applying a transformation matrix. All elements receive the same transformation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the element(s) to transform |
|
|
the transformation to apply |
|
|
|
{ |
the options |
|
|
‐ |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); const transform = SketchUpApi.Transformation .translation([50, 50, 0]); op.drawingElementsApplyTransformation( faceRef, transform );}, 'Transform element');console.log('Element transformed');SDK 2.14.0 Protocol 1.11.0
drawingElementsBulkTransformation()
Section titled “drawingElementsBulkTransformation()”drawingElementsBulkTransformation(
refs,transforms):void
Moves, rotates, or scales multiple drawing elements in a single
call. Each element is paired with its own transformation — the
first ref gets the first transform, the second ref gets the
second, and so on. Much more efficient than calling
drawingElementsApplyTransformation repeatedly when you need
different transforms for each element.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the drawing elements or vertices to transform |
|
|
a transformation for each element (same length as refs) |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const face1 = op.createFace(op.model, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); const face2 = op.createFace(op.model, [ [0, 100, 0], [50, 100, 0], [50, 150, 0], [0, 150, 0] ]); const transforms = [ SketchUpApi.Transformation.translation([50, 0, 0]), SketchUpApi.Transformation.translation([0, 50, 0]) ]; op.drawingElementsBulkTransformation( [face1, face2], transforms );}, 'Bulk transform');console.log('Elements transformed');SDK 2.14.0 Protocol 1.11.0
drawingElementSetMaterial()
Section titled “drawingElementSetMaterial()”drawingElementSetMaterial(
ref,materialRef):void
Paints a drawing element with a material. For faces, this sets
the front material — use faceSetBackMaterial for the reverse
side. For edges, groups, and component instances, this sets
their overall material.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the drawing element or drawing element reference |
|
|
|
the material to apply |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 1], [50, 0, 1], [50, 50, 1], [0, 50, 1] ]); const matRef = op.createMaterial('Brick'); op.materialSetColor( matRef, new SketchUpApi.Color(180, 80, 40) ); op.drawingElementSetMaterial(faceRef, matRef);}, 'Set material');console.log('Material applied');Operation.faceSetBackMaterial to set face back material
drawingElementSetMaterialName()
Section titled “drawingElementSetMaterialName()”drawingElementSetMaterialName(
ref,materialName):void
Paints a drawing element with a material looked up by name.
Convenient when you know the material’s name but don’t have a
ref. For faces, this sets the front side — use
faceSetBackMaterialName for the reverse.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the drawing element or drawing element reference |
|
|
|
|
The material’s name, like |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 1], [50, 0, 1], [50, 50, 1], [0, 50, 1] ]); op.drawingElementSetMaterialName( faceRef, 'Brick_Antique' );}, 'Set material by name');console.log('Material applied');Operation.faceSetBackMaterialName to set face back material
drawingElementSetProperties()
Section titled “drawingElementSetProperties()”drawingElementSetProperties(
ref,properties):void
Updates visibility, cast-shadows, receive-shadows, and other display properties on a drawing element in one call.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the drawing element or drawing element reference |
|
|
|
the changes to apply to the properties |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); op.drawingElementSetProperties(faceRef, { hidden: true, castShadows: true });}, 'Set element properties');console.log('Properties updated');drawingElementSetTag()
Section titled “drawingElementSetTag()”drawingElementSetTag(
ref,tag):void
Assigns a tag (layer) to a drawing element. Tags control visibility — when a tag is hidden, all entities on that tag disappear from view.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the drawing element or drawing element reference |
|
|
|
the tag to assign |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); const tagRef = op.createTag('Floors'); op.drawingElementSetTag(faceRef, tagRef);}, 'Assign tag to face');console.log('Tag assigned');drawingElementSetTagName()
Section titled “drawingElementSetTagName()”drawingElementSetTagName(
ref,tagName):void
Assigns a tag to a drawing element by the tag’s name string. Convenient when you know the tag name but don’t have a TagRef.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the drawing element or drawing element reference |
|
|
|
|
the display name of the tag, like |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); op.createTag('Floors'); op.drawingElementSetTagName(faceRef, 'Floors');}, 'Assign tag by name');console.log('Tag assigned by name');createEdge()
Section titled “createEdge()”createEdge(
ref,vertices): readonlyEdgeRef[]
Creates one or more edges connecting the given vertices. Consecutive vertices are connected by edges — for example, four vertices create three edges. SketchUp will automatically intersect the new edges with existing geometry, potentially splitting faces or other edges where they cross.
For creating large amounts of geometry efficiently, use createBuilder
instead — it avoids repeated intersection passes and is much faster for
bulk operations.
Returns EdgeRef handles that are valid only within this operation. To read
an edge’s properties or use it outside the operation callback, call
entityForRef(edgeRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the edges will be created (model, group, or component instance). |
|
|
|
readonly |
The points to connect with edges, in order. Three vertices create two edges (A-B and B-C). |
Returns
Section titled “Returns”readonly EdgeRef[]
References to the newly created edges, in the same order as the vertex segments.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let edges = await model.performOperation(op => { const edgeRefs = op.createEdge(op.model, [ [0, 0, 0], [100, 0, 0], [100, 100, 0] ]); return op.entitiesForRefs(edgeRefs);}, 'Create edges');console.log(edges);- Edge for code examples
- createBuilder
- entityForRef
SDK 2.30.0
edgeSetProperties()
Section titled “edgeSetProperties()”edgeSetProperties(
ref,edgeProperties):void
Updates display properties on an edge — soft, smooth, hidden, and color. Soft edges don’t show a visible crease; smooth edges interpolate normals across connected faces for a curved look.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the edge or edge reference |
|
|
|
the property changes to apply |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let sharedEdge = await model.performOperation(op => { op.createFace(op.model, [ [0, 0, 0], [50, 0, 10], [50, 100, 10], [0, 100, 0] ]); op.createFace(op.model, [ [50, 0, 10], [100, 0, 0], [100, 100, 0], [50, 100, 10] ]); return op.entityForRef( op.createEdge(op.model, [ [50, 0, 10], [50, 100, 10] ])[0] );}, 'Create shared edge');await model.performOperation(op => { op.edgeSetProperties(sharedEdge, { soft: true, smooth: true });}, 'Soften edge');console.log('Edge softened - notice smooth shading');entitiesSetEdgeProperties()
Section titled “entitiesSetEdgeProperties()”entitiesSetEdgeProperties(
ref,edgeUsageType,edgeProperties):void
Applies edge property changes to all edges in a container that match a given usage type. For example, you can soften all curve edges, or hide all profile edges, in one call. Much more efficient than modifying each edge individually.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the entity container or container reference |
|
|
|
|
the edge usage type to target (e.g. ‘Shared’) |
|
|
the property changes to apply |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let group = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); op.createFace(groupRef, [ [50, 0, 0], [100, 0, 0], [100, 50, 0], [50, 50, 0] ]); op.entitiesSetEdgeProperties( groupRef, SketchUpApi.EdgeUsageType.Shared, { smooth: true, hidden: true } ); return op.entityForRef(groupRef);}, 'Smooth shared mesh edges');let edges = await group.entities.get({ filterBy: { types: ['Edge'] }});let smoothEdges = edges.filter(e => e.smooth);console.log(smoothEdges.length);// => 1Entity
Section titled “Entity”entitiesForRefs()
Section titled “entitiesForRefs()”entitiesForRefs<
E>(refs):Promise<EntityFor<E>[]>
Resolves an array of entity references to full entity objects. Use this inside an operation to read back the properties of entities you created in the same operation, since refs only carry an identifier. Results are returned in the same order as the input refs.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
|
|
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the entity references to resolve |
Returns
Section titled “Returns”Promise<EntityFor<E>[]>
the full entity objects in the same order as refs
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { const faceRef1 = op.createFace(op.model, [[0,0,0],[100,0,0],[100,100,0],[0,100,0]]); const faceRef2 = op.createFace(op.model, [[0,0,100],[100,0,100],[100,100,100],[0,100,100]]); return op.entitiesForRefs([faceRef1, faceRef2]);}, 'Create faces');console.log(face.vertices);entityDeleteAttribute()
Section titled “entityDeleteAttribute()”entityDeleteAttribute(
ref,path,key):void
Removes a single attribute key from an entity’s attribute dictionary. The path identifies which dictionary contains the key. Must not be empty.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the entity or entity reference |
|
|
|
|
the dictionary path (e.g. |
|
|
|
the attribute key to delete |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let edge = await model.performOperation((op) => { let [ref] = op.createEdge(op.model, [[0, 0, 0], [10, 0, 0]]); op.entitySetAttribute(ref, 'MyPlugin', 'type', 'beam'); op.entitySetAttribute(ref, 'MyPlugin', 'color', 'red'); return op.entityForRef(ref);}, 'Add attributes');await model.performOperation((op) => { op.entityDeleteAttribute(edge, 'MyPlugin', 'type');}, 'Remove type attribute');edge = await edge.refresh();console.log(edge.attributes.hasValue( 'MyPlugin', 'type'));entityDeleteAttributes()
Section titled “entityDeleteAttributes()”entityDeleteAttributes(
ref,path):void
Removes an entire attribute dictionary (and all its keys) from the entity. The path identifies which dictionary to delete. Must not be empty.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the entity or entity reference |
|
|
|
|
the dictionary path (e.g. |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let edge = await model.performOperation((op) => { let [ref] = op.createEdge(op.model, [[0, 0, 0], [10, 0, 0]]); op.entitySetAttribute(ref, 'MyPlugin', 'type', 'beam'); op.entitySetAttribute(ref, 'MyPlugin', 'color', 'red'); return op.entityForRef(ref);}, 'Add attributes');await model.performOperation((op) => { op.entityDeleteAttributes(edge, 'MyPlugin');}, 'Remove all attributes');edge = await edge.refresh();console.log(edge.attributes.hasValue( 'MyPlugin', 'type'));entityForRef()
Section titled “entityForRef()”entityForRef<
E>(ref):Promise<EntityFor<E>>
Fetches the full entity snapshot for an operation ref. Use this to read properties (geometry, name, material) of something you created or modified earlier in the operation. The ref must still exist in SketchUp — throws if it was deleted.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
|
|
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the entity reference |
Returns
Section titled “Returns”Promise<EntityFor<E>>
a promise containing the entity
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { const faceRef = op.createFace(op.model, [[0,0,0],[100,0,0],[100,100,0],[0,100,0]]); return op.entityForRef(faceRef);}, 'Create Face');console.log(face.vertices);entitySetAttribute()
Section titled “entitySetAttribute()”entitySetAttribute(
ref,path,key,value):void
Stores a custom key/value pair in one of the entity’s attribute dictionaries. Attributes are persistent metadata that survive save/load cycles.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the entity or entity reference |
|
|
|
|
Dictionary path (must not be empty), like
|
|
|
|
the attribute key |
|
|
the value to set |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let edge = await model.performOperation((op) => { let [ref] = op.createEdge(op.model, [[0, 0, 0], [10, 0, 0]]); op.entitySetAttribute(ref, 'MyPlugin', 'type', 'beam'); return op.entityForRef(ref);}, 'Add edge attribute');console.log(edge.attributes.getValue( 'MyPlugin', 'type'));Entity Container
Section titled “Entity Container”createBuilder()
Section titled “createBuilder()”createBuilder<
A>(func):EntityBuilderCall<A,A>
Creates a builder for efficiently constructing large amounts of geometry.
The builder batches face, edge, and curve creation calls and applies
SketchUp’s intersection logic once at the end, which is much faster than
creating geometry piecemeal with createFace or createEdge.
The callback receives an EntitiesBuilder instance with methods like
faceCreate, edgeCreate, and arcCreate. Once you’ve queued all the
geometry, call .build(container) on the returned object to commit it to
the model.
The builder’s create methods return refs to the created geometry, which you
can use to set materials, apply transformations, or read back properties
after calling build().
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
|
|
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
( |
A callback that uses the builder’s methods to define geometry. Can be synchronous or async. |
Returns
Section titled “Returns”EntityBuilderCall<A, A>
An object with a build(container) method. Call it to insert the
geometry into the model, group, or component instance.
EntitiesBuilder for code examples
createConstructionLine()
Section titled “createConstructionLine()”createConstructionLine(
ref,start,end,stipple?):ConstructionLineRef
Creates a construction line, which is guide geometry that helps with snapping and alignment but doesn’t appear in rendered output. You can create a finite line segment (by passing two points) or an infinite ray (by passing a start point and a direction vector). The stipple parameter controls the line’s dash pattern.
Returns a ConstructionLineRef that’s valid only within this operation. To
read the line’s properties or use it outside the operation callback, call
entityForRef(constructionLineRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
The container where the construction line will be created (model, group, or component instance). |
|
|
|
|
The starting point of the line in 3D space (inches). |
|
|
|
|
Either an end point (for a finite segment) or a direction vector (for an infinite ray). |
|
|
|
|
|
The dash pattern, like ”-” for solid or ”.” for dotted. Defaults to ”-”. |
Returns
Section titled “Returns”A reference to the newly created construction line.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let line = await model.performOperation(op => { const lineRef = op.createConstructionLine( op.model, new SketchUpApi.Point3d(0, 0, 0), new SketchUpApi.Point3d(100, 100, 0) ); return op.entityForRef(lineRef);}, 'Create construction line');console.log(line);- ConstructionLine for code examples
- entityForRef
SDK 2.30.0 Protocol 1.5.0
createConstructionPoint()
Section titled “createConstructionPoint()”createConstructionPoint(
ref,point):ConstructionPointRef
Creates a construction point at the given 3D location. Construction points are guide geometry — they don’t appear in rendered output but help with snapping and alignment during modeling. They’re often used to mark key locations like centers, intersections, or reference heights.
Returns a ConstructionPointRef that’s valid only within this operation. To
read the point’s properties or use it outside the operation callback, call
entityForRef(constructionPointRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the construction point will be created (model, group, or component instance). |
|
|
|
The 3D position in inches. |
Returns
Section titled “Returns”A reference to the newly created construction point.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let point = await model.performOperation(op => { const pointRef = op.createConstructionPoint(op.model, [50, 50, 50]); return op.entityForRef(pointRef);}, 'Create construction point');console.log(point);- ConstructionPoint for code examples
- entityForRef
SDK 2.30.0 Protocol 1.5.0
createDefinition()
Section titled “createDefinition()”createDefinition(
name):ComponentDefinitionRef
Creates a new component definition with the given name. If the name already exists, SketchUp appends a randomized suffix to make it unique.
The returned ref is only valid within this operation. To access
the definition after the operation ends, convert it with
entityForRef(defRef).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the name of the component |
Returns
Section titled “Returns”reference to the created component definition
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let def = await model.performOperation(op => { const defRef = op.createDefinition('MyComponent'); op.createFace(defRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); return op.entityForRef(defRef);}, 'Create definition');console.log(def);ComponentDefinition for code examples
SDK 2.30.0
createEdge()
Section titled “createEdge()”createEdge(
ref,vertices): readonlyEdgeRef[]
Creates one or more edges connecting the given vertices. Consecutive vertices are connected by edges — for example, four vertices create three edges. SketchUp will automatically intersect the new edges with existing geometry, potentially splitting faces or other edges where they cross.
For creating large amounts of geometry efficiently, use createBuilder
instead — it avoids repeated intersection passes and is much faster for
bulk operations.
Returns EdgeRef handles that are valid only within this operation. To read
an edge’s properties or use it outside the operation callback, call
entityForRef(edgeRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the edges will be created (model, group, or component instance). |
|
|
|
readonly |
The points to connect with edges, in order. Three vertices create two edges (A-B and B-C). |
Returns
Section titled “Returns”readonly EdgeRef[]
References to the newly created edges, in the same order as the vertex segments.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let edges = await model.performOperation(op => { const edgeRefs = op.createEdge(op.model, [ [0, 0, 0], [100, 0, 0], [100, 100, 0] ]); return op.entitiesForRefs(edgeRefs);}, 'Create edges');console.log(edges);- Edge for code examples
- createBuilder
- entityForRef
SDK 2.30.0
createFace()
Section titled “createFace()”createFace(
ref,vertices):FaceRef
Creates a face from an array of 3D points forming a closed loop. The vertices must be coplanar and define a non-degenerate polygon. SketchUp will automatically intersect the new face with existing geometry and may split edges or faces where they overlap.
For creating large amounts of geometry efficiently, use createBuilder
instead — it bypasses intersection while building and only applies it once
at the end.
Returns a FaceRef that’s valid only within this operation. To read the
face’s properties or use it outside the operation callback, call
entityForRef(faceRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the face will be created (model, group, or component instance). |
|
|
|
readonly |
The corner points of the face in 3D space (inches), in order. The last vertex automatically connects back to the first. |
Returns
Section titled “Returns”A reference to the newly created face.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 100, 0], [0, 100, 0] ]); return op.entityForRef(faceRef);}, 'Create rectangle face');console.log(face);- Face for code examples
- createBuilder
- entityForRef
SDK 2.30.0
createGroup()
Section titled “createGroup()”createGroup(
ref):GroupRef
Creates an empty group in the specified container. Groups organize geometry into named, movable clusters — like component instances, but unique (not reusable across the model). After creating a group, you can add faces, edges, or nested groups to it by passing the returned GroupRef as the container to other create methods.
Returns a GroupRef that’s valid only within this operation. To read the
group’s properties or use it outside the operation callback, call
entityForRef(groupRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the group will be created (model, another group, or a component instance). |
Returns
Section titled “Returns”A reference to the newly created empty group.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let group = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.groupSetName(groupRef, 'MyGroup'); const faceRef = op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); return op.entityForRef(groupRef);}, 'Create group with face');console.log(group);- Group for code examples
- entityForRef
SDK 2.30.0
createImage()
Section titled “createImage()”Places an image into the model as a 2D entity. Images are flat rectangles that display a raster graphic — useful for reference photos, logos, or textures that aren’t applied to geometry. You can provide the image data as a data URL, an HTML image element, a Blob, or a fetch request.
The image is positioned by its lower-left corner (origin) and scaled to the given width and height (in inches). It initially faces the user along the model’s axes — you can rotate it afterward with transformation methods.
When options include a fetch or blob resource, this method returns a Promise that resolves once the image data is loaded. Data URLs and HTML elements load synchronously and return an ImageEntityRef directly.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let img = await model.performOperation(async op => { const imgRef = await op.createImage(op.model, { resource: { request: 'https://cdn.habitat.sketchup.com/examples/images/ColorWheel.jpg' }, origin: [0, 0, 0], width: 100, height: 100 }); return op.entityForRef(imgRef);}, 'Create image');console.log(img);ImageEntity for code examples
SDK 2.30.0 Protocol 1.18.0
container
The container where the image will be placed (model, group, or component instance).
options
Configuration including the image source (resource), position (origin), and dimensions (width and height in inches).
Call Signature
Section titled “Call Signature”createImage(
container,options):ImageEntityRef
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”createImage(
container,options):Promise<ImageEntityRef>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”Promise<ImageEntityRef>
Call Signature
Section titled “Call Signature”createImage(
container,options):ImageEntityRef|Promise<ImageEntityRef>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”ImageEntityRef | Promise<ImageEntityRef>
createInstance()
Section titled “createInstance()”createInstance(
ref,componentRef,transform?):ComponentInstanceRef
Places an instance of a component definition into the model. Component instances are reusable copies of a shared definition — editing the definition updates all instances. The optional transformation positions, rotates, and scales the instance relative to its parent container’s axes.
Returns a ComponentInstanceRef that’s valid only within this operation. To
read the instance’s properties or use it outside the operation callback,
call entityForRef(instanceRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the instance will be placed (model, group, or another component instance). |
|
|
|
The component definition to instantiate. |
|
|
|
Optional transformation to apply to the instance. Defaults to identity (origin with no rotation or scaling). |
Returns
Section titled “Returns”A reference to the newly created component instance.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let defs = await model.getDefinitions();if (defs.length === 0) { console.log('there are no definitions');} else { let instance = await model.performOperation(op => { const instanceRef = op.createInstance( op.model, defs[0] ); return op.entityForRef(instanceRef); }, 'Create instance'); console.log(instance);}- ComponentInstance for code examples
- entityForRef
SDK 2.30.0
createSectionPlane()
Section titled “createSectionPlane()”createSectionPlane(
ref,planeCoefficients):SectionPlaneRef
Creates a section plane in the container. The plane cuts
through the model, revealing cross-sectional geometry. Activate
it with sectionPlaneActivate to make the cut visible.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the container or container ref |
|
|
|
the cutting plane as |
Returns
Section titled “Returns”a reference to the created section plane
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.updateRenderingOptions( { DisplaySectionPlanes: true });let sectionPlane = await model.performOperation(op => { const spRef = op.createSectionPlane( op.model, [0, 0, 1, -50] ); return op.entityForRef(spRef);}, 'Create section plane');console.log(sectionPlane);SDK 2.30.0 Protocol 1.13.0
SectionPlane for code examples
createSnap()
Section titled “createSnap()”createSnap(
ref,position,direction,up?):SnapRef
Creates a snap point in the container. Snap points define attachment locations for component instances (like connection points for furniture or fixtures).
The returned SnapRef is only valid within this operation. To
access it after the operation ends, convert it with
entityForRef(snapRef).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the container or container ref |
|
|
|
the position of the snap point |
|
|
|
the direction vector of the snap point |
|
|
|
optional up vector (if omitted, SketchUp determines orientation automatically) |
Returns
Section titled “Returns”a reference to the created snap point
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let snap = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); const snapRef = op.createSnap( groupRef, [25, 25, 0], [0, 0, 1] ); return op.entityForRef(snapRef);}, 'Create snap on group');console.log(snap);- Snap for code examples
- entityForRef
SDK 2.30.0 Protocol 1.17.0
createText()
Section titled “createText()”createText(
ref,text,attachment,vector?):TextRef
Creates a text annotation in the model. Text entities can be screen-facing labels (2D) or leader-line callouts pointing at specific geometry (3D). The attachment point determines where the text’s arrow touches the model, and can optionally reference a nested component instance path so the text follows that geometry when it moves.
If you omit the leader vector, SketchUp creates a 2D screen-space text that always faces the camera. Providing a vector creates a 3D text with a leader line extending from the attachment point in the vector’s direction.
Returns a TextRef that’s valid only within this operation. To read the
text’s properties or use it outside the operation callback, call
entityForRef(textRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the text will be created (model, group, or component instance). |
|
|
|
|
The text string to display. |
|
|
Either a 3D point, or an object with |
|
|
|
Optional leader direction. Omit to create a 2D screen text. |
Returns
Section titled “Returns”A reference to the newly created text entity.
Examples
Section titled “Examples”Create a standalone text entity.
let model = await SketchUpApi.getActiveModel();let text = await model.performOperation(op => { const textRef = op.createText( op.model, 'Hello World', { point: [0, 0, 100] }, [0, 0, 50] ); return op.entityForRef(textRef);}, 'Create text');console.log(text);Create text attached to a vertical edge.
let model = await SketchUpApi.getActiveModel();let edgeText = await model.performOperation(op => { const edgeRefs = op.createEdge(op.model, [ [50, 50, 0], [50, 50, 100] ]); const textRef = op.createText( op.model, 'Edge Label', { point: [50, 50, 50] }, [50, 0, 0] ); return op.entityForRef(textRef);}, 'Create edge text');console.log(edgeText);- Text for code examples
- entityForRef
SDK 2.30.0 Protocol 1.19.0
entitiesApplyTransformation()
Section titled “entitiesApplyTransformation()”entitiesApplyTransformation(
ref,transformation,options?):void
Applies a transformation (move, rotate, or scale) to every entity inside a container in one instruction. You can optionally filter which entity types are affected. This is much more efficient than transforming entities one by one.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the entity container or container reference |
|
|
|
the transformation to apply to all entities |
|
|
|
optional filter to limit which entity types are transformed |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let point = await model.performOperation(op => { const groupRef = op.createGroup(op.model); const pointRef = op.createConstructionPoint( groupRef, [0, 0, 0] ); op.createEdge(groupRef, [ [0, 0, 0], [50, 0, 0] ]); op.entitiesApplyTransformation( groupRef, SketchUpApi.Transformation.translation( [0, 0, 25] ), { filterBy: { types: ['ConstructionPoint'] } } ); return op.entityForRef(pointRef);}, 'Move points in group');console.log(point.position.toArray());// => [0, 0, 25]SDK 1.9.0 Protocol 0.8.0
entitiesClear()
Section titled “entitiesClear()”entitiesClear(
ref):void
Removes all geometry and child entities from a container, leaving it empty. Use this to wipe a group or component’s contents before rebuilding them.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the entity container or container reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let groupEntity = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); return op.entityForRef(groupRef);}, 'Create group with face');
let group = await model.performOperation(op => { op.entitiesClear(groupEntity); return op.entityForRef(groupEntity);}, 'Clear group contents');// undefinedconsole.log(await model.findEntity(group));entitiesSetActivateSectionPlane()
Section titled “entitiesSetActivateSectionPlane()”entitiesSetActivateSectionPlane(
ref,sectionPlaneRef?):void
Activates a specific section plane in a container, or clears
the active section plane. The active plane’s cut is applied to
the view; only one plane can be active per container. Pass
undefined or null to deactivate all section planes in
the container.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the entities container or reference |
|
|
|
|
the section plane to activate, or |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.updateRenderingOptions( { DisplaySectionPlanes: true });let plane = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); const spRef = op.createSectionPlane( groupRef, [0, 0, 1, -25] ); op.entitiesSetActivateSectionPlane( groupRef, spRef ); return op.entityForRef(spRef);}, 'Activate section plane in group');console.log(plane.active);// => trueSDK 2.16.0 Protocol 1.13.0
entitiesSetEdgeProperties()
Section titled “entitiesSetEdgeProperties()”entitiesSetEdgeProperties(
ref,edgeUsageType,edgeProperties):void
Applies edge property changes to all edges in a container that match a given usage type. For example, you can soften all curve edges, or hide all profile edges, in one call. Much more efficient than modifying each edge individually.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the entity container or container reference |
|
|
|
|
the edge usage type to target (e.g. ‘Shared’) |
|
|
the property changes to apply |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let group = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); op.createFace(groupRef, [ [50, 0, 0], [100, 0, 0], [100, 50, 0], [50, 50, 0] ]); op.entitiesSetEdgeProperties( groupRef, SketchUpApi.EdgeUsageType.Shared, { smooth: true, hidden: true } ); return op.entityForRef(groupRef);}, 'Smooth shared mesh edges');let edges = await group.entities.get({ filterBy: { types: ['Edge'] }});let smoothEdges = edges.filter(e => e.smooth);console.log(smoothEdges.length);// => 1createFace()
Section titled “createFace()”createFace(
ref,vertices):FaceRef
Creates a face from an array of 3D points forming a closed loop. The vertices must be coplanar and define a non-degenerate polygon. SketchUp will automatically intersect the new face with existing geometry and may split edges or faces where they overlap.
For creating large amounts of geometry efficiently, use createBuilder
instead — it bypasses intersection while building and only applies it once
at the end.
Returns a FaceRef that’s valid only within this operation. To read the
face’s properties or use it outside the operation callback, call
entityForRef(faceRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the face will be created (model, group, or component instance). |
|
|
|
readonly |
The corner points of the face in 3D space (inches), in order. The last vertex automatically connects back to the first. |
Returns
Section titled “Returns”A reference to the newly created face.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 100, 0], [0, 100, 0] ]); return op.entityForRef(faceRef);}, 'Create rectangle face');console.log(face);- Face for code examples
- createBuilder
- entityForRef
SDK 2.30.0
createFaceFromEdges()
Section titled “createFaceFromEdges()”createFaceFromEdges(
ref,edges):FaceRef
Creates a face bounded by the given edges. The edges must form a closed loop. SketchUp will apply face and edge intersection, so use EntitiesBuilder instead for large amounts of geometry.
The returned FaceRef is only valid within this operation. To
access the face after the operation ends, convert it with
entityForRef(faceRef).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the container or container ref |
|
|
|
the edges to use to create the face |
Returns
Section titled “Returns”a reference to the created face
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { const edge1 = op.createEdge(op.model, [[0, 0, 0], [100, 0, 0]])[0]; const edge2 = op.createEdge(op.model, [[100, 0, 0], [100, 100, 0]])[0]; const edge3 = op.createEdge(op.model, [[100, 100, 0], [0, 100, 0]])[0]; const edge4 = op.createEdge(op.model, [[0, 100, 0], [0, 0, 0]])[0]; const faceRef = op.createFaceFromEdges( op.model, [edge1, edge2, edge3, edge4] ); return op.entityForRef(faceRef);}, 'Create face from edges');console.log(face);- Face for code examples
- createBuilder
- entityForRef
SDK 2.30.0 Protocol 1.22.0
faceClearBackTexturePosition()
Section titled “faceClearBackTexturePosition()”faceClearBackTexturePosition(
face):void
Removes the back-side UV texture positioning from a face, reverting to the material’s default tiling. Use this to undo custom UV pin placement on the back of a face.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face to clear positioning from |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create face and position texturelet face = await model.performOperation(async op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); const canvas = document.createElement('canvas'); canvas.width = 200; canvas.height = 200; const ctx = canvas.getContext('2d'); ctx.fillStyle = 'black'; ctx.fillRect(0, 0, 200, 200); ctx.fillStyle = 'yellow'; ctx.beginPath(); ctx.arc(150, 150, 30, 0, Math.PI * 2); ctx.fill(); const texMat = op.createMaterial( 'TexturedBack' ); const b64 = canvas.toDataURL().split(',')[1]; await op.materialSetTextureDataBase64( texMat, b64, 100, 100 ); op.facePositionBackMaterial(faceRef, texMat, [ [0, 0, 0], [0, 0, 0], [100, 0, 0], [1, 0, 0], [100, 0, 50], [1, 1, 0], [0, 0, 50], [0, 1, 0] ] ); return op.entityForRef(faceRef);}, 'Create positioned texture');// Second operation: clear the positioningawait model.performOperation(async op => { op.faceClearBackTexturePosition(face);}, 'Clear back texture position');SDK 2.25.0 Protocol 1.22.0
faceClearBackTextureProjection()
Section titled “faceClearBackTextureProjection()”faceClearBackTextureProjection(
face):void
Resets the back-side texture projection of a face, reverting to the material’s default projection. Use this to remove any custom projection that was applied to the back side.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face to clear projection from |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create face and apply texturelet face = await model.performOperation(async op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); const canvas = document.createElement('canvas'); canvas.width = 200; canvas.height = 200; const ctx = canvas.getContext('2d'); ctx.fillStyle = 'black'; ctx.fillRect(0, 0, 200, 200); ctx.fillStyle = 'blue'; ctx.beginPath(); ctx.arc(50, 150, 30, 0, Math.PI * 2); ctx.fill(); const texMat = op.createMaterial( 'TexturedBack' ); const b64 = canvas.toDataURL().split(',')[1]; await op.materialSetTextureDataBase64( texMat, b64, 100, 100 ); op.facePositionBackMaterial(faceRef, texMat, [ [0, 0, 0], [0, 0, 0], [100, 0, 0], [1, 0, 0], [100, 0, 50], [1, 1, 0], [0, 0, 50], [0, 1, 0] ], [1, -1, 0] // skew the texture ); return op.entityForRef(faceRef);}, 'Create textured face');// Second operation: clear the projectionawait model.performOperation(async op => { op.faceClearBackTextureProjection(face);}, 'Clear back texture projection');SDK 2.25.0 Protocol 1.22.0
faceClearFrontTexturePosition()
Section titled “faceClearFrontTexturePosition()”faceClearFrontTexturePosition(
face):void
Removes the front-side UV texture positioning from a face, reverting to the material’s default tiling. Use this to undo custom UV pin placement.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face to clear positioning from |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create face and position texturelet face = await model.performOperation(async op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); const canvas = document.createElement('canvas'); canvas.width = 200; canvas.height = 200; const ctx = canvas.getContext('2d'); ctx.fillStyle = 'black'; ctx.fillRect(0, 0, 200, 200); ctx.fillStyle = 'green'; ctx.beginPath(); ctx.arc(150, 50, 30, 0, Math.PI * 2); ctx.fill(); const texMat = op.createMaterial( 'TexturedFront' ); const b64 = canvas.toDataURL().split(',')[1]; await op.materialSetTextureDataBase64( texMat, b64, 100, 100 ); op.facePositionFrontMaterial(faceRef, texMat, [ [0, 0, 0], [0, 0, 0], [100, 0, 0], [1, 0, 0], [100, 0, 50], [1, 1, 0], [0, 0, 50], [0, 1, 0] ] ); return op.entityForRef(faceRef);}, 'Create positioned texture');// Second operation: clear the positioningawait model.performOperation(async op => { op.faceClearFrontTexturePosition(face);}, 'Clear front texture position');SDK 2.25.0 Protocol 1.22.0
faceClearFrontTextureProjection()
Section titled “faceClearFrontTextureProjection()”faceClearFrontTextureProjection(
face):void
Removes the front-side texture projection from a face, resetting it to the default flat mapping. Use this when you want to undo a previously applied projection without replacing it.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face to clear projection from |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create face and apply texturelet face = await model.performOperation(async op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); const canvas = document.createElement('canvas'); canvas.width = 200; canvas.height = 200; const ctx = canvas.getContext('2d'); ctx.fillStyle = 'black'; ctx.fillRect(0, 0, 200, 200); ctx.fillStyle = 'red'; ctx.beginPath(); ctx.arc(50, 50, 30, 0, Math.PI * 2); ctx.fill(); const texMat = op.createMaterial( 'TexturedFront' ); const b64 = canvas.toDataURL().split(',')[1]; await op.materialSetTextureDataBase64( texMat, b64, 100, 100 ); op.facePositionFrontMaterial(faceRef, texMat, [ [0, 0, 0], [0, 0, 0], [100, 0, 0], [1, 0, 0], [100, 0, 50], [1, 1, 0], [0, 0, 50], [0, 1, 0] ], [1, -1, 0] // skew the texture ); return op.entityForRef(faceRef);}, 'Create textured face');// Second operation: clear the projectionawait model.performOperation(async op => { op.faceClearFrontTextureProjection(face);}, 'Clear front texture projection');SDK 2.25.0 Protocol 1.22.0
faceFollowMe()
Section titled “faceFollowMe()”faceFollowMe(
face,edges):Promise<boolean>
Sweeps a face along a path of edges, creating a 3D shape (like piping or extrusion along a curve). This is SketchUp’s “Follow Me” tool. The face and path edges may be consumed (deleted) by the operation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the profile face to sweep |
|
|
|
the path to sweep along |
Returns
Section titled “Returns”Promise<boolean>
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Create path: curved edges to sweep along const pathEdges = op.createEdge( op.model, [[0, 0, 0], [50, 50, 0], [100, 100, 0]] ); // Sweep face along path await op.faceFollowMe(faceRef, pathEdges);}, 'Apply follow me sweep');SDK 2.25.0 Protocol 1.22.0
facePositionBackMaterial()
Section titled “facePositionBackMaterial()”facePositionBackMaterial(
face,material,positions,projection):void
Controls how a textured material is mapped onto the back
(reverse) side of a face. Works identically to
facePositionFrontMaterial but targets the opposite side.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
the textured material to position |
|
|
|
1–4 pairs of [model point, UV point] |
|
|
|
|
an optional repeating direction vector |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Create canvas with 4 colored circles const canvas = document.createElement('canvas'); canvas.width = 200; canvas.height = 200; const ctx = canvas.getContext('2d'); ctx.fillStyle = 'black'; ctx.fillRect(0, 0, 200, 200); // Red top-left, green top-right, // blue bottom-left, yellow bottom-right ctx.fillStyle = 'red'; ctx.beginPath(); ctx.arc(50, 50, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'green'; ctx.beginPath(); ctx.arc(150, 50, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'blue'; ctx.beginPath(); ctx.arc(50, 150, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'yellow'; ctx.beginPath(); ctx.arc(150, 150, 30, 0, Math.PI * 2); ctx.fill(); // Create textured material and position const texMat = op.createMaterial( 'TexturedBack' ); const b64 = canvas.toDataURL().split(',')[1]; await op.materialSetTextureDataBase64( texMat, b64, 100, 100 ); op.facePositionBackMaterial(faceRef, texMat, [ [0, 0, 0], [0, 0, 0], [100, 0, 0], [1, 0, 0], [100, 0, 50], [1, 1, 0], [0, 0, 50], [0, 1, 0] ] );}, 'Position back texture');facePositionFrontMaterial()
Section titled “facePositionFrontMaterial()”facePositionFrontMaterial(
face,material,positions,projection?):void
Controls how a textured material is mapped onto the front of a face. You provide pairs of [3D point, UV coordinate] to pin texture corners to specific locations on the face. The material must have a texture — positioning a solid-color material throws.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
the textured material to position |
|
|
|
1–4 pairs of [model point, UV point] |
|
|
|
an optional repeating direction vector |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Create canvas with 4 colored circles const canvas = document.createElement('canvas'); canvas.width = 200; canvas.height = 200; const ctx = canvas.getContext('2d'); ctx.fillStyle = 'black'; ctx.fillRect(0, 0, 200, 200); // Red top-left, green top-right, // blue bottom-left, yellow bottom-right ctx.fillStyle = 'red'; ctx.beginPath(); ctx.arc(50, 50, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'green'; ctx.beginPath(); ctx.arc(150, 50, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'blue'; ctx.beginPath(); ctx.arc(50, 150, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'yellow'; ctx.beginPath(); ctx.arc(150, 150, 30, 0, Math.PI * 2); ctx.fill(); // Create textured material and position const texMat = op.createMaterial( 'TexturedFront' ); const b64 = canvas.toDataURL().split(',')[1]; await op.materialSetTextureDataBase64( texMat, b64, 100, 100 ); op.facePositionFrontMaterial(faceRef, texMat, [ [0, 0, 0], [0, 0, 0], [100, 0, 0], [1, 0, 0], [100, 0, 50], [1, 1, 0], [0, 0, 50], [0, 1, 0] ] );}, 'Position front texture');facePushPull()
Section titled “facePushPull()”facePushPull(
face,distance,copy?):void
Extrudes a face along its normal direction, creating a 3D solid.
Positive values push outward (along the normal), negative values
push inward. If copy is true the original face remains in
place and a new extruded shape is created alongside it.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
the face to extrude |
|
|
|
|
|
extrusion distance in inches (positive = outward) |
|
|
|
|
when true, leaves the original face and creates a new solid |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Extrude the face upward (along Y axis) op.facePushPull(faceRef, 50);}, 'Extrude L-shaped face');SDK 2.2.0 Protocol 1.1.0
faceReverse()
Section titled “faceReverse()”faceReverse(
face):void
Flips a face so the front becomes the back and vice versa. The normal direction reverses, and front/back materials swap sides.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Apply different materials to front/back const red = op.createMaterial('RedFront'); op.materialSetColor( red, new SketchUpApi.Color(200, 50, 50) ); const blue = op.createMaterial('BlueBack'); op.materialSetColor( blue, new SketchUpApi.Color(50, 50, 200) ); op.faceSetFrontMaterial(faceRef, red); op.faceSetBackMaterial(faceRef, blue); // Reverse to swap front/back op.faceReverse(faceRef);}, 'Reverse face');faceSetBackMaterial()
Section titled “faceSetBackMaterial()”faceSetBackMaterial(
face,material):void
Paints the back (reverse) side of a face with a material. The back side is the one facing away from the face’s normal direction.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
the material or material reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Create back material const blue = op.createMaterial('BlueBack'); op.materialSetColor( blue, new SketchUpApi.Color(50, 50, 200) ); op.faceSetBackMaterial(faceRef, blue); return op.entityForRef(faceRef);}, 'Apply back material');console.log(face);faceSetBackMaterialName()
Section titled “faceSetBackMaterialName()”faceSetBackMaterialName(
face,materialName):void
Paints the back (reverse) side of a face with a material looked up by name.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
|
The material’s name, like |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Apply back material by name op.faceSetBackMaterialName(faceRef, 'blue'); return op.entityForRef(faceRef);}, 'Apply back material by name');console.log(face);faceSetEdgeProperties()
Section titled “faceSetEdgeProperties()”faceSetEdgeProperties(
ref,edgeUsageType,edgeProperties):void
Updates edge display properties (soft, smooth, hidden) on all edges of a face that match a particular usage type. Use this to soften or hide interior edges in bulk without targeting each one individually.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
|
which edges to affect (border, interior, etc.) |
|
|
the property changes to apply |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Hide all border edges op.faceSetEdgeProperties(faceRef, SketchUpApi.EdgeUsageType.Any, { hidden: true } );}, 'Hide face edges');faceSetFrontMaterial()
Section titled “faceSetFrontMaterial()”faceSetFrontMaterial(
ref,materialRef):void
Sets the front material on the face, alias of drawingElementSetMaterial
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
the material or material reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Create and apply front material const red = op.createMaterial('RedFront'); op.materialSetColor( red, new SketchUpApi.Color(200, 50, 50) ); op.faceSetFrontMaterial(faceRef, red); return op.entityForRef(faceRef);}, 'Apply front material');console.log(face);Operation.drawingElementSetMaterial
faceSetFrontMaterialName()
Section titled “faceSetFrontMaterialName()”faceSetFrontMaterialName(
ref,materialName):void
Sets the front material on the face by name, alias of drawingElementSetMaterialName
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
|
the name of the material |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Apply front material by name op.faceSetFrontMaterialName(faceRef, 'red'); return op.entityForRef(faceRef);}, 'Apply front material by name');console.log(face);createGroup()
Section titled “createGroup()”createGroup(
ref):GroupRef
Creates an empty group in the specified container. Groups organize geometry into named, movable clusters — like component instances, but unique (not reusable across the model). After creating a group, you can add faces, edges, or nested groups to it by passing the returned GroupRef as the container to other create methods.
Returns a GroupRef that’s valid only within this operation. To read the
group’s properties or use it outside the operation callback, call
entityForRef(groupRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the group will be created (model, another group, or a component instance). |
Returns
Section titled “Returns”A reference to the newly created empty group.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let group = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.groupSetName(groupRef, 'MyGroup'); const faceRef = op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); return op.entityForRef(groupRef);}, 'Create group with face');console.log(group);- Group for code examples
- entityForRef
SDK 2.30.0
groupApplyTransformation()
Section titled “groupApplyTransformation()”groupApplyTransformation(
ref,transformation):void
Multiplies a transformation onto the group’s existing transform.
Use this to move or rotate a group incrementally without losing
its current position — unlike groupSetTransformation which
replaces everything.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the group or group reference |
|
|
|
the transformation to compose on top |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create group at originlet groupRef = await model.performOperation(op => { const ref = op.createGroup(op.model); const { edges } = op.createCircle( ref, [400, 0, 0], [0, 0, 1], 50 ); const faceRef = op.createFaceFromEdges( ref, edges ); op.drawingElementSetMaterialName( faceRef, '#DA70D6' ); op.faceSetBackMaterialName( faceRef, '#DA70D6' ); return op.entityForRef(ref);}, 'Create group with circle');// Second operation: apply relative transformationawait model.performOperation(op => { op.groupApplyTransformation( groupRef, SketchUpApi.Transformation.translation( [0, 100, 0] ) );}, 'Apply group transformation');groupSetDescription()
Section titled “groupSetDescription()”groupSetDescription(
ref,description):void
Sets a human-readable description on a group. This text appears in SketchUp’s Entity Info panel when the group is selected.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the group or group reference |
|
|
|
|
the description text |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const groupRef = op.createGroup(op.model); const { edges } = op.createCircle( groupRef, [0, 0, 0], [0, 0, 1], 50 ); const faceRef = op.createFaceFromEdges( groupRef, edges ); op.drawingElementSetMaterialName( faceRef, '#FF6347' ); op.faceSetBackMaterialName( faceRef, '#FF6347' ); op.groupSetDescription( groupRef, 'A simple circular disc' );}, 'Set group description');groupSetLocked()
Section titled “groupSetLocked()”groupSetLocked(
ref,locked):void
Locks or unlocks a group. Locked groups cannot be moved, edited, or deleted by the user in the viewport — but you can still modify them programmatically.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the group or group reference |
|
|
|
|
|
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const groupRef = op.createGroup(op.model); const { edges } = op.createCircle( groupRef, [100, 0, 0], [0, 0, 1], 50 ); const faceRef = op.createFaceFromEdges( groupRef, edges ); op.drawingElementSetMaterialName( faceRef, '#4682B4' ); op.faceSetBackMaterialName( faceRef, '#4682B4' ); op.groupSetLocked(groupRef, true);}, 'Lock group');groupSetName()
Section titled “groupSetName()”groupSetName(
ref,name):void
Gives a group a user-visible name. This name appears in the Outliner panel and Entity Info.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the group or group reference |
|
|
|
|
the display name, like |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const groupRef = op.createGroup(op.model); const { edges } = op.createCircle( groupRef, [200, 0, 0], [0, 0, 1], 50 ); const faceRef = op.createFaceFromEdges( groupRef, edges ); op.drawingElementSetMaterialName( faceRef, '#32CD32' ); op.faceSetBackMaterialName( faceRef, '#32CD32' ); op.groupSetName(groupRef, 'CircleGroup');}, 'Set group name');groupSetTransformation()
Section titled “groupSetTransformation()”groupSetTransformation(
ref,transformation):void
Replaces a group’s transformation (position, rotation, scale) relative to its parent container. This is an absolute set — any previous transformation is discarded.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the group or group reference |
|
|
|
the new transformation matrix |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();// First operation: create group at originlet groupRef = await model.performOperation(op => { const ref = op.createGroup(op.model); const { edges } = op.createCircle( ref, [300, 0, 0], [0, 0, 1], 50 ); const faceRef = op.createFaceFromEdges( ref, edges ); op.drawingElementSetMaterialName( faceRef, '#FFD700' ); op.faceSetBackMaterialName( faceRef, '#FFD700' ); return op.entityForRef(ref);}, 'Create group with circle');// Second operation: set absolute transformationawait model.performOperation(op => { op.groupSetTransformation( groupRef, SketchUpApi.Transformation.translation( [0, 100, 0] ) );}, 'Set group transformation');instanceSetGluedTo()
Section titled “instanceSetGluedTo()”instanceSetGluedTo(
entity,element):void
Attaches (glues) a component instance or group to a face,
so it moves and rotates with that face. Gluing is how windows
stay in walls and decals stick to surfaces. Pass undefined
to detach the instance from its current face.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the group or component instance to glue |
|
|
|
|
the face to glue it to, or |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Floor face on the X/Y plane const floorRef = op.createFace(op.model, [ [300, 0, 0], [500, 0, 0], [500, 500, 0], [300, 500, 0] ]); const bedDef = await op.loadDefinition({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/models/Bed.skp' } }); // Glueable components must allow gluing op.definitionSetTo2d(bedDef, true); const instanceRef = op.createInstance( op.model, bedDef, SketchUpApi.Transformation.translation( [400, 0, 0] ) ); op.instanceSetGluedTo(instanceRef, floorRef);}, 'Glue instance to floor face');SDK 2.30.0 Protocol 1.18.0
createImage()
Section titled “createImage()”Places an image into the model as a 2D entity. Images are flat rectangles that display a raster graphic — useful for reference photos, logos, or textures that aren’t applied to geometry. You can provide the image data as a data URL, an HTML image element, a Blob, or a fetch request.
The image is positioned by its lower-left corner (origin) and scaled to the given width and height (in inches). It initially faces the user along the model’s axes — you can rotate it afterward with transformation methods.
When options include a fetch or blob resource, this method returns a Promise that resolves once the image data is loaded. Data URLs and HTML elements load synchronously and return an ImageEntityRef directly.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let img = await model.performOperation(async op => { const imgRef = await op.createImage(op.model, { resource: { request: 'https://cdn.habitat.sketchup.com/examples/images/ColorWheel.jpg' }, origin: [0, 0, 0], width: 100, height: 100 }); return op.entityForRef(imgRef);}, 'Create image');console.log(img);ImageEntity for code examples
SDK 2.30.0 Protocol 1.18.0
container
The container where the image will be placed (model, group, or component instance).
options
Configuration including the image source (resource), position (origin), and dimensions (width and height in inches).
Call Signature
Section titled “Call Signature”createImage(
container,options):ImageEntityRef
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”createImage(
container,options):Promise<ImageEntityRef>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”Promise<ImageEntityRef>
Call Signature
Section titled “Call Signature”createImage(
container,options):ImageEntityRef|Promise<ImageEntityRef>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”ImageEntityRef | Promise<ImageEntityRef>
imageApplyTransformation()
Section titled “imageApplyTransformation()”imageApplyTransformation(
entity,transformation):void
Multiplies the image’s current transformation by the given
transformation, moving or rotating it relative to its current
position. To set an absolute position instead, use
imageSetTransformation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the image to transform |
|
|
|
the transformation to compound with the current one |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let imgEntity = await model.performOperation( async op => { const imgRef = await op.createImage(op.model, { resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/images/ColorWheel.jpg' }, origin: [300, 0, 0], width: 50, height: 50 }); return op.entityForRef(imgRef); }, 'Create image');
let rotated = await model.performOperation(op => { op.imageApplyTransformation( imgEntity, SketchUpApi.Transformation.rotation( [300, 0, 0], [0, 0, 1], Math.PI / 4 ) ); return op.entityForRef(imgEntity);}, 'Rotate image 45 degrees');console.log(rotated.zrotation);// => 0.7853981633974483SDK 2.21.0 Protocol 1.18.0
imageSetDimensions()
Section titled “imageSetDimensions()”imageSetDimensions(
entity,options):void
Resizes an image entity in the model. Width and height are in inches (model units). If you supply only one dimension, the aspect ratio is preserved.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the image to resize |
|
|
|
{ |
the new |
|
|
|
‐ |
|
|
|
‐ |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let img = await model.performOperation(async op => { const imgRef = await op.createImage(op.model, { resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/images/ColorWheel.jpg' }, origin: [100, 0, 0], width: 50, height: 50 }); op.imageSetDimensions(imgRef, { width: 100, height: 100 }); return op.entityForRef(imgRef);}, 'Resize image');console.log(img.width, img.height);// => 100 100SDK 2.21.0 Protocol 1.18.0
imageSetGluedTo()
Section titled “imageSetGluedTo()”imageSetGluedTo(
entity,element):void
Attaches (glues) an image entity to a face so it moves and
rotates with that face. Useful for decals, photos, and texture
references placed directly on surfaces. Pass undefined to
detach the image from its current face.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the image to glue |
|
|
|
|
the face to attach to, or |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let img = await model.performOperation(async op => { const floorRef = op.createFace(op.model, [ [400, 0, 0], [600, 0, 0], [600, 200, 0], [400, 200, 0] ]); const imgRef = await op.createImage(op.model, { resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/images/ColorWheel.jpg' }, origin: [450, 50, 0], width: 50, height: 50 }); op.imageSetGluedTo(imgRef, floorRef); return op.entityForRef(imgRef);}, 'Glue image to floor');console.log(img.gluedToId !== undefined);// => trueSDK 2.21.0 Protocol 1.18.0
imageSetOrigin()
Section titled “imageSetOrigin()”imageSetOrigin(
entity,origin):void
Moves the image’s anchor point (lower-left corner) to a new position in model space, without changing its rotation or size.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the image to move |
|
|
|
the new anchor position in model coordinates |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let img = await model.performOperation(async op => { const imgRef = await op.createImage(op.model, { resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/images/ColorWheel.jpg' }, origin: [0, 0, 0], width: 50, height: 50 }); op.imageSetOrigin(imgRef, [0, 0, 50]); return op.entityForRef(imgRef);}, 'Move image origin');console.log(img.transform.origin.toArray());// => [0, 0, 50]SDK 2.21.0 Protocol 1.18.0
imageSetTransformation()
Section titled “imageSetTransformation()”imageSetTransformation(
entity,transformation):void
Replaces the image’s transformation with an absolute one,
setting its exact position and orientation in model space.
To move it relative to its current position, use
imageApplyTransformation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the image to reposition |
|
|
|
the new absolute transformation |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let imgEntity = await model.performOperation( async op => { const imgRef = await op.createImage(op.model, { resource: { request: 'https://cdn.habitat.sketchup.com/' + 'examples/images/ColorWheel.jpg' }, origin: [200, 0, 0], width: 50, height: 50 }); return op.entityForRef(imgRef); }, 'Create image');
let moved = await model.performOperation(op => { op.imageSetTransformation( imgEntity, SketchUpApi.Transformation.translation( [200, 100, 0] ) ); return op.entityForRef(imgEntity);}, 'Reposition image');console.log(moved.transform.origin.toArray());// => [200, 100, 0]SDK 2.21.0 Protocol 1.18.0
Material
Section titled “Material”createMaterial()
Section titled “createMaterial()”createMaterial(
name):MaterialRef
Creates a new material with the given name. The material starts with
default properties (solid white, no texture) — use materialSetColor,
materialSetAlpha, materialSetTexture, and related methods to configure
it. Once created, you can apply it to faces, edges, groups, and component
instances.
Material names should be unique within the model. If a material with the same name already exists, SketchUp may append a suffix to make it unique.
Returns a MaterialRef that’s valid only within this operation. To read the
material’s properties or use it outside the operation callback, call
entityForRef(materialRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
The material’s display name, like “BrickRed” or “Glass”. |
Returns
Section titled “Returns”A reference to the newly created material.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let material = await model.performOperation(op => { const matRef = op.createMaterial('BrickRed'); op.materialSetColor( matRef, new SketchUpApi.Color(200, 80, 60) ); return op.entityForRef(matRef);}, 'Create material');console.log(material);- Material for code examples
- entityForRef
facePositionBackMaterial()
Section titled “facePositionBackMaterial()”facePositionBackMaterial(
face,material,positions,projection):void
Controls how a textured material is mapped onto the back
(reverse) side of a face. Works identically to
facePositionFrontMaterial but targets the opposite side.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
the textured material to position |
|
|
|
1–4 pairs of [model point, UV point] |
|
|
|
|
an optional repeating direction vector |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Create canvas with 4 colored circles const canvas = document.createElement('canvas'); canvas.width = 200; canvas.height = 200; const ctx = canvas.getContext('2d'); ctx.fillStyle = 'black'; ctx.fillRect(0, 0, 200, 200); // Red top-left, green top-right, // blue bottom-left, yellow bottom-right ctx.fillStyle = 'red'; ctx.beginPath(); ctx.arc(50, 50, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'green'; ctx.beginPath(); ctx.arc(150, 50, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'blue'; ctx.beginPath(); ctx.arc(50, 150, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'yellow'; ctx.beginPath(); ctx.arc(150, 150, 30, 0, Math.PI * 2); ctx.fill(); // Create textured material and position const texMat = op.createMaterial( 'TexturedBack' ); const b64 = canvas.toDataURL().split(',')[1]; await op.materialSetTextureDataBase64( texMat, b64, 100, 100 ); op.facePositionBackMaterial(faceRef, texMat, [ [0, 0, 0], [0, 0, 0], [100, 0, 0], [1, 0, 0], [100, 0, 50], [1, 1, 0], [0, 0, 50], [0, 1, 0] ] );}, 'Position back texture');facePositionFrontMaterial()
Section titled “facePositionFrontMaterial()”facePositionFrontMaterial(
face,material,positions,projection?):void
Controls how a textured material is mapped onto the front of a face. You provide pairs of [3D point, UV coordinate] to pin texture corners to specific locations on the face. The material must have a texture — positioning a solid-color material throws.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
the textured material to position |
|
|
|
1–4 pairs of [model point, UV point] |
|
|
|
an optional repeating direction vector |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Create canvas with 4 colored circles const canvas = document.createElement('canvas'); canvas.width = 200; canvas.height = 200; const ctx = canvas.getContext('2d'); ctx.fillStyle = 'black'; ctx.fillRect(0, 0, 200, 200); // Red top-left, green top-right, // blue bottom-left, yellow bottom-right ctx.fillStyle = 'red'; ctx.beginPath(); ctx.arc(50, 50, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'green'; ctx.beginPath(); ctx.arc(150, 50, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'blue'; ctx.beginPath(); ctx.arc(50, 150, 30, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'yellow'; ctx.beginPath(); ctx.arc(150, 150, 30, 0, Math.PI * 2); ctx.fill(); // Create textured material and position const texMat = op.createMaterial( 'TexturedFront' ); const b64 = canvas.toDataURL().split(',')[1]; await op.materialSetTextureDataBase64( texMat, b64, 100, 100 ); op.facePositionFrontMaterial(faceRef, texMat, [ [0, 0, 0], [0, 0, 0], [100, 0, 0], [1, 0, 0], [100, 0, 50], [1, 1, 0], [0, 0, 50], [0, 1, 0] ] );}, 'Position front texture');faceSetBackMaterial()
Section titled “faceSetBackMaterial()”faceSetBackMaterial(
face,material):void
Paints the back (reverse) side of a face with a material. The back side is the one facing away from the face’s normal direction.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
the material or material reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Create back material const blue = op.createMaterial('BlueBack'); op.materialSetColor( blue, new SketchUpApi.Color(50, 50, 200) ); op.faceSetBackMaterial(faceRef, blue); return op.entityForRef(faceRef);}, 'Apply back material');console.log(face);faceSetBackMaterialName()
Section titled “faceSetBackMaterialName()”faceSetBackMaterialName(
face,materialName):void
Paints the back (reverse) side of a face with a material looked up by name.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
|
The material’s name, like |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Apply back material by name op.faceSetBackMaterialName(faceRef, 'blue'); return op.entityForRef(faceRef);}, 'Apply back material by name');console.log(face);faceSetFrontMaterial()
Section titled “faceSetFrontMaterial()”faceSetFrontMaterial(
ref,materialRef):void
Sets the front material on the face, alias of drawingElementSetMaterial
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
the material or material reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Create and apply front material const red = op.createMaterial('RedFront'); op.materialSetColor( red, new SketchUpApi.Color(200, 50, 50) ); op.faceSetFrontMaterial(faceRef, red); return op.entityForRef(faceRef);}, 'Apply front material');console.log(face);Operation.drawingElementSetMaterial
faceSetFrontMaterialName()
Section titled “faceSetFrontMaterialName()”faceSetFrontMaterialName(
ref,materialName):void
Sets the front material on the face by name, alias of drawingElementSetMaterialName
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face or face reference |
|
|
|
|
the name of the material |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let face = await model.performOperation(op => { // Create L-shaped face on X/Z plane const faceRef = op.createFace(op.model, [ [0, 0, 0], [100, 0, 0], [100, 0, 50], [50, 0, 50], [50, 0, 100], [0, 0, 100] ]); // Apply front material by name op.faceSetFrontMaterialName(faceRef, 'red'); return op.entityForRef(faceRef);}, 'Apply front material by name');console.log(face);Operation.drawingElementSetMaterialName
loadMaterial()
Section titled “loadMaterial()”loadMaterial(
options):Promise<MaterialRef>
Loads a material from an external resource (URL, Blob, or data
URL) and adds it to the model. The resource must be a valid
.skm (SketchUp Material) file. Use this to import pre-built
materials from a library or CDN.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
resource and loading configuration |
Returns
Section titled “Returns”Promise<MaterialRef>
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const matRef = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); const faceRef = op.createFace(op.model, [ [0, 0, 1], [100, 0, 1], [100, 100, 1], [0, 100, 1] ]); op.drawingElementSetMaterial(faceRef, matRef);}, 'Load material from CDN');SDK 2.30.0 protocol 1.9.0
materialSetAlpha()
Section titled “materialSetAlpha()”materialSetAlpha(
material,alpha):void
Sets the opacity of a material. This controls how transparent the material appears when rendered.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
|
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const matRef = op.createMaterial('Glass'); op.materialSetAlpha(matRef, 0.5);}, 'Set material alpha');materialSetAmbientOcclusionEnabled()
Section titled “materialSetAmbientOcclusionEnabled()”materialSetAmbientOcclusionEnabled(
material,aoEnabled):void
Enables or disables the ambient occlusion (AO) channel for a
PBR material. When disabled, the AO strength setting has no
effect. Enable first, then set the strength with
materialSetAmbientOcclusionStrength. Only available in PBR
workflow on SketchUp 2025+.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
when true, AO crevice-darkening is active |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let matRef = await model.performOperation(async op => { const mat = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); op.materialSetAmbientOcclusionEnabled(mat, true); return mat;}, 'Enable AO');SDK 2.12.0 Protocol 1.9.0
materialSetAmbientOcclusionStrength()
Section titled “materialSetAmbientOcclusionStrength()”materialSetAmbientOcclusionStrength(
material,aoStrength):void
Controls how pronounced ambient occlusion crevice-darkening appears on the material. Only applies to PBR materials with AO enabled.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
value from 0.0 (no effect) to 1.0 (full darkening) |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let matRef = await model.performOperation(async op => { const mat = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); op.materialSetAmbientOcclusionEnabled(mat, true); op.materialSetAmbientOcclusionStrength(mat, 0.8); return mat;}, 'Set AO strength');SDK 2.12.0 Protocol 1.9.0
materialSetColor()
Section titled “materialSetColor()”materialSetColor(
material,color):void
Changes the base color of a material. If the material also has a texture, the color will tint or show through transparent areas — setting the color does not remove the texture.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
the new color (use |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const matRef = op.createMaterial('WallPaint'); op.materialSetColor( matRef, new SketchUpApi.Color(100, 150, 200) );}, 'Set material color');materialSetColorizeType()
Section titled “materialSetColorizeType()”materialSetColorizeType(
material,colorizeType):void
Controls how the material’s color blends with its texture. The colorize type determines the blending algorithm — for example, tinting, shifting, or replacing the texture’s hue with the material color.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
the blending algorithm to use |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const mat = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); op.materialSetColor(mat, new SketchUpApi.Color(200, 100, 50) ); op.materialSetColorizeType(mat, SketchUpApi.ColorizeType.Tint );}, 'Set colorize type');SDK 2.15.0 Protocol 1.12.0
materialSetMetallicFactor()
Section titled “materialSetMetallicFactor()”materialSetMetallicFactor(
material,metallicFactor):void
Controls how metallic the material appears. At 0.0 the surface looks like a dielectric (plastic, wood); at 1.0 it looks fully metallic (steel, gold). Only applies to PBR materials with metalness enabled.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
value from 0.0 (non-metal) to 1.0 (fully metallic) |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const mat = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); op.materialSetMetalnessEnabled(mat, true); op.materialSetMetallicFactor(mat, 0.9);}, 'Set metallic factor');SDK 2.12.0 Protocol 1.9.0
materialSetMetalnessEnabled()
Section titled “materialSetMetalnessEnabled()”materialSetMetalnessEnabled(
material,metalnessEnabled):void
Enables or disables the metalness channel for a PBR material.
When disabled, the metallic factor has no effect. Enable first,
then set the intensity with materialSetMetallicFactor. Only
available in PBR workflow on SketchUp 2025+.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
when true, the metallic appearance is active |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const mat = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); op.materialSetMetalnessEnabled(mat, true);}, 'Enable metalness');SDK 2.12.0 Protocol 1.9.0
materialSetName()
Section titled “materialSetName()”materialSetName(
material,name):void
Renames a material. The new name must be unique among all materials in the model — SketchUp will error if there’s a collision.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
the new name, like |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const matRef = op.createMaterial('Material1'); op.materialSetName(matRef, 'CeramicTile');}, 'Rename material');materialSetNormalEnabled()
Section titled “materialSetNormalEnabled()”materialSetNormalEnabled(
material,normalEnabled):void
Enables or disables the normal map channel for a PBR material.
When disabled, the bump effect has no visual effect. Enable
first, then set the intensity with materialSetNormalScale.
Only available in PBR workflow on SketchUp 2025+.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
when true, the normal map bump effect is active |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const mat = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); op.materialSetNormalEnabled(mat, true);}, 'Enable normal map');SDK 2.12.0 Protocol 1.9.0
materialSetNormalScale()
Section titled “materialSetNormalScale()”materialSetNormalScale(
material,normalScale):void
Controls the intensity of the normal map’s bump effect. Higher values make the surface appear more deeply textured; 0.0 disables the visual effect without removing the map. Only applies to PBR materials with normal mapping enabled.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
intensity multiplier (0.0 = flat, typical range 0.0–2.0) |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const mat = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); op.materialSetNormalEnabled(mat, true); op.materialSetNormalScale(mat, 1.5);}, 'Set normal scale');SDK 2.12.0 Protocol 1.9.0
materialSetNormalStyle()
Section titled “materialSetNormalStyle()”materialSetNormalStyle(
material,style):void
Chooses the convention used to interpret the normal map texture. Different authoring tools export normal maps in different formats (OpenGL vs DirectX style) — this setting ensures SketchUp reads the green channel correctly.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
the normal map convention to use |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const mat = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); op.materialSetNormalStyle(mat, SketchUpApi.MaterialNormalStyle.OpenGL );}, 'Set normal style');SDK 2.12.0 Protocol 1.9.0
materialSetRoughnessEnabled()
Section titled “materialSetRoughnessEnabled()”materialSetRoughnessEnabled(
material,roughnessEnabled):void
Enables or disables the roughness channel for a PBR material.
When disabled, the roughness factor has no effect. Enable first,
then set the value with materialSetRoughnessFactor. Only
available in PBR workflow on SketchUp 2025+.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
when true, the roughness channel is active |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const mat = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); op.materialSetRoughnessEnabled(mat, true);}, 'Enable roughness');SDK 2.12.0 Protocol 1.9.0
materialSetRoughnessFactor()
Section titled “materialSetRoughnessFactor()”materialSetRoughnessFactor(
material,roughnessFactor):void
Controls how rough or smooth the material’s surface appears. At 0.0 the surface is mirror-smooth (like polished chrome); at 1.0 it’s fully rough (like unfinished concrete). Only applies to PBR materials with roughness enabled.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
value from 0.0 (mirror) to 1.0 (fully rough) |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const mat = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); op.materialSetRoughnessEnabled(mat, true); op.materialSetRoughnessFactor(mat, 0.6);}, 'Set roughness factor');SDK 2.12.0 Protocol 1.9.0
materialSetTexture()
Section titled “materialSetTexture()”materialSetTexture(
material,texture,options?):void
Assigns a texture image to a material by copying an existing
Texture object. Pass undefined to remove the texture and
revert the material to solid color only. The optional
textureType controls which PBR channel receives the texture
(standard, normal map, metallic, etc.).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material to assign the texture to |
|
|
|
|
the texture to copy, or |
|
|
{ |
optional PBR texture type |
|
|
‐ |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const srcMatRef = await op.loadMaterial({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'materials/metal/Metal_Cladding_01_1K.skm' } }); const srcMat = op.entityForRef(srcMatRef); const matRef = op.createMaterial('CopyTex'); op.materialSetTexture(matRef, srcMat.texture);}, 'Copy texture to material');SDK 2.12.0 Protocol 1.9.0
materialSetTextureDataBase64()
Section titled “materialSetTextureDataBase64()”materialSetTextureDataBase64(
material,base64Data,options?):void
Sets the material’s texture from a base64-encoded image string. Supports JPEG and PNG formats. This is the most common way to apply textures from canvas-generated images or fetched assets.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
the base64-encoded image data (no |
|
|
{ |
texture type (standard or PBR channel) |
|
|
‐ |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const matRef = op.createMaterial('CanvasTex'); // Create a simple texture on canvas const canvas = document.createElement('canvas'); canvas.width = 64; canvas.height = 64; const ctx = canvas.getContext('2d'); ctx.fillStyle = '#FF6B6B'; ctx.fillRect(0, 0, 64, 64); const b64 = canvas.toDataURL().split(',')[1]; await op.materialSetTextureDataBase64(matRef, b64 );}, 'Set material texture from base64');SDK 1.6.0 Protocol 0.5.0
materialSetTextureFromHtmlImage()
Section titled “materialSetTextureFromHtmlImage()”materialSetTextureFromHtmlImage(
material,element,options_or_type?,quality?):void
Sets the material’s texture from an <img> element already
loaded in the DOM. The image is internally converted to a data
URL using canvas — see the MDN docs for supported type/quality
options.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference |
|
|
|
|
the html element to convert into an image |
|
|
|
options for setting the texture (Added in SDK 2.12.0) or a deprecated type string |
|
|
|
deprecated quality parameter |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const matRef = op.createMaterial('ImgTex'); const img = document.createElement('img'); img.src = 'data:image/svg+xml,%3Csvg...%3E'; await img.decode(); op.materialSetTextureFromHtmlImage(matRef, img);}, 'Set material texture from image');https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL for valid type and quality parameters
SDK 1.6.0 Protocol 0.5.0
materialSetTextureImageRep()
Section titled “materialSetTextureImageRep()”materialSetTextureImageRep(
material,options):void
Applies a texture to the material from raw pixel data (image
rep). The imageData length must equal
(width * (bitsPerPixel / 8) + rowPadding) * height.
The native byte order is RGB(A) on macOS and BGR(A) on Windows. Supplying a non-native byte order incurs a performance cost as the SDK must swap channels before sending to SketchUp.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material to apply the texture to |
|
|
|
|
‐ |
Returns
Section titled “Returns”void
https://ruby.sketchup.com/Sketchup/ImageRep.html#set_data-instance_method Image Rep Ruby documentation
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const matRef = op.createMaterial('TexturedMat'); // 8x8 red pixels (3 bytes per pixel RGB) const pixelData = new Uint8Array(8 * 8 * 3); for (let i = 0; i < pixelData.length; i += 3) { pixelData[i] = 255; // R pixelData[i + 1] = i % 255; // G pixelData[i + 2] = 0; // B } op.materialSetTextureImageRep(matRef, { width: 8, height: 8, bitsPerPixel: 24, rowPadding: 0, imageData: [...pixelData].map(p => String.fromCharCode(p)).join('') });}, 'Set material texture from image rep');purgeUnusedMaterials()
Section titled “purgeUnusedMaterials()”purgeUnusedMaterials():
void
Removes all materials from the model that are not applied to any face, group, or component instance. Useful for reducing file size after deleting geometry that used those materials.
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { // Create unused material (not applied to any geometry) op.createMaterial('UnusedMat'); // Purge removes it op.purgeUnusedMaterials();}, 'Purge unused materials');SDK 2.30.0
removeMaterial()
Section titled “removeMaterial()”removeMaterial(
material):void
Permanently removes a material from the model. Any faces that were using this material revert to the default (no material / inherited from parent).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material or material reference to remove |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const matRef = op.createMaterial('TempMaterial'); op.removeMaterial(matRef);}, 'Remove material');SDK 2.30.0
setCurrentMaterial()
Section titled “setCurrentMaterial()”setCurrentMaterial(
material):void
Sets the “active” material in the model — the one shown in
SketchUp’s Materials panel and applied when the user paints
with the Paint Bucket tool. Pass undefined to clear it.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the material to activate, or |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const matRef = op.createMaterial('ActiveMat'); op.materialSetColor( matRef, new SketchUpApi.Color(150, 200, 100) ); op.setCurrentMaterial(matRef);}, 'Set current material');SDK 2.30.0
modelDeleteAttribute()
Section titled “modelDeleteAttribute()”modelDeleteAttribute(
path,key):void
Removes an attribute from the model’s attribute dictionary. The path identifies which dictionary (or nested dictionary) contains the key. Must not be empty.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the dictionary path (e.g. |
|
|
|
the attribute key to delete |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation((op) => { op.modelDeleteAttribute('MyExtension', 'ConfigValue');}, 'Delete model attribute');model = await model.refresh();
console.log( model.attributes.hasValue('MyExtension'));modelDeleteAttributes()
Section titled “modelDeleteAttributes()”modelDeleteAttributes(
path):void
Removes an entire attribute dictionary (and all its keys) from the model. The path identifies which dictionary to delete. Must not be empty.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the dictionary path (e.g. |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation((op) => { op.modelSetAttribute('MyExtension', 'version', '1.0');}, 'Set attribute');model = await model.refresh();
let hasAttr = model.attributes.hasValue( 'MyExtension', 'version');console.log('Before delete:', hasAttr);
await model.performOperation((op) => { op.modelDeleteAttributes('MyExtension');}, 'Delete attributes');model = await model.refresh();
hasAttr = model.attributes.hasValue( 'MyExtension', 'version');console.log('After delete:', hasAttr);modelLoadSchemaFromUrl()
Section titled “modelLoadSchemaFromUrl()”modelLoadSchemaFromUrl(
input,init?):Promise<void>
Loads an IFC or custom classification schema from a URL into the model. Once loaded, you can classify entities using the schema’s types. The URL should point to a valid SketchUp classification schema file.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the fetch RequestInfo or URL pointing to the schema |
|
|
|
optional fetch request initialization parameters |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async (op) => { await op.modelLoadSchemaFromUrl( 'https://example.com/schema.skc' );}, 'Load schema');console.log('Schema loaded');NOTE: This method will fail if the schema with the same name already exists in the model, check the existence of the schema by name model.getClassifications() before calling this method.
SDK 2.5.0 Protocol 1.3.0
modelSetActivePath()
Section titled “modelSetActivePath()”modelSetActivePath(
path):void
Opens a group or component for editing, as if the user had double-clicked into it. The path must be a valid chain from the model root to the target container — the operation will fail if the path is invalid. Pass an empty array to return to the model root.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
( |
the path from the root of the model through subsequent groups and instances |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let instances = await model.entities.get({filterBy: {types: ['ComponentInstance']}});if (instances.length > 0) { await model.performOperation((op) => { op.modelSetActivePath([instances[0]]); }, 'Activate first component'); let activePath = await model.getActivePath();
console.log(activePath);} else { console.log('No component instances available.');}SDK 2.17.0 Protocol 1.14.0
modelSetAttribute()
Section titled “modelSetAttribute()”modelSetAttribute(
path,key,value):void
Stores a custom key/value pair in one of the model’s attribute dictionaries. Attributes let you attach arbitrary data to the model — useful for plugin state or metadata.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
The dictionary path (must not be empty), like
|
|
|
|
the attribute key |
|
|
the value to set |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation((op) => { op.modelSetAttribute('MyExtension', 'ConfigValue', true);}, 'Set model name');model = await model.refresh();
console.log(model.attributes.getValue('MyExtension', 'ConfigValue'));modelSetAxes()
Section titled “modelSetAxes()”modelSetAxes(
origin,xaxis,yaxis,zaxis):void
Repositions the model’s global axes. The three axis vectors must be mutually orthogonal — the operation will fail otherwise.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the new origin point (in inches) |
|
|
|
the red axis direction (must be unit length) |
|
|
|
the green axis direction (must be unit length) |
|
|
|
the blue axis direction (must be unit length) |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation((op) => { op.modelSetAxes([100,100,0],[1,0,0],[0,1,0],[0,0,-1]);}, 'Invert and offset axes');let axes = await model.getAxes();
console.log(axes);modelSetCRSLocation()
Section titled “modelSetCRSLocation()”modelSetCRSLocation(
location):void
Sets or clears the model’s geographic coordinate reference
system (CRS) location. This geo-locates the model in real-world
coordinates. Pass undefined to clear the location.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the CRS data, or |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let crs = new SketchUpApi.CRSLocation({ name: 'EPSG:27700', eastings: 530000, northings: 180000, height: 0, scale: SketchUpApi.CRSScale.Meters});await model.performOperation((op) => { op.modelSetCRSLocation(crs);}, 'Set CRS location');console.log('CRS location set');SDK 2.28.0 Protocol 1.25.0
modelSetName()
Section titled “modelSetName()”modelSetName(
name):void
Changes the model’s internal name. This is not the same as the window title (which comes from the file name on disk).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the model name |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation((op) => { op.modelSetName('New Model Name');}, 'Set model name');model = await model.refresh();
console.log(model.name);modelUnloadSchema()
Section titled “modelUnloadSchema()”modelUnloadSchema(
schemaName):void
Removes a previously loaded classification schema from the model. Any entities classified with this schema will lose their classification data.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the name of the schema to unload |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let schemaUrl = 'https://cdn.habitat.sketchup.com/' + 'classifications/schemas/IFC2x3.skc';await model.performOperation(async (op) => { await op.modelLoadSchemaFromUrl(schemaUrl);}, 'Load IFC schema');await model.performOperation((op) => { op.modelUnloadSchema('IFC2x3');}, 'Unload IFC schema');console.log('Schema unloaded');SDK 2.5.0 Protocol 1.3.0
Operation
Section titled “Operation”
readonlymodel:Model
readonlyname:string
currentStatus
Section titled “currentStatus”Get Signature
Section titled “Get Signature”get currentStatus():
"open"|"committed"|"aborted"|"closed_backend"
Returns the local lifecycle state. This value may lag behind
SketchUp’s actual state — call synchronize() if you need a
guaranteed-fresh answer.
Operation.synchronize to ensure this value is up to date
Returns
Section titled “Returns”"open" | "committed" | "aborted" | "closed_backend"
the current status of the operation
status
Section titled “status”Get Signature
Section titled “Get Signature”get status():
"open"|"committed"|"aborted"|"closed_backend"
The current lifecycle state of this operation. Starts as 'open'
and transitions to 'committed' or 'aborted' when you finish.
Returns
Section titled “Returns”"open" | "committed" | "aborted" | "closed_backend"
abort()
Section titled “abort()”abort():
Promise<OperationAbortResult>
Aborts this operation, discarding all queued instructions. The
model reverts to the state before the operation started. Only
call this if you used model.startOperation() — when using
model.performOperation(), abort happens automatically on error.
Returns
Section titled “Returns”Promise<OperationAbortResult>
a promise with the abort result.
commit()
Section titled “commit()”commit():
Promise<OperationCommitResult>
Commits this operation, applying all queued instructions to the
model. Only call this if you used model.startOperation() —
when using model.performOperation(), commit happens automatically.
Returns
Section titled “Returns”Promise<OperationCommitResult>
a promise with the commit result.
flush()
Section titled “flush()”flush():
void
Sends any buffered instructions to SketchUp immediately instead of waiting for the next automatic batch. Useful when you want to ensure progress before continuing with more instructions.
Returns
Section titled “Returns”void
SDK 2.21.0
synchronize()
Section titled “synchronize()”synchronize():
Promise<OperationStatusResult>
Waits until all instructions queued so far have been processed by SketchUp. Use this when you need to read back geometry that you just created earlier in the same operation. Overuse will hurt performance — each call is a full round-trip.
Returns
Section titled “Returns”Promise<OperationStatusResult>
a promise containing the operation status
Throws
Section titled “Throws”Error if the backend operation is already closed
createScene()
Section titled “createScene()”createScene(
name?,properties?,index?):SceneRef
Creates a scene that captures the current state of the model. Scenes (also called pages) save camera position, visible tags, active section planes, shadow settings, and other view properties so you can return to the same configuration later. They’re essential for presentations, construction sequences, and design reviews.
You can specify which properties to save — by default, all properties are captured. The scene is inserted at the given index in the scene list, or appended to the end if no index is provided.
Returns a SceneRef that’s valid only within this operation. To read the
scene’s properties or use it outside the operation callback, call
entityForRef(sceneRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
|
The scene’s display name. If undefined, SketchUp generates a name like “Scene 1”. |
|
|
|
|
Which model properties to capture (camera, tags, styles, etc.). Defaults to all properties. |
|
|
|
|
Where to insert the scene in the list (0-based). Defaults to the end. |
Returns
Section titled “Returns”A reference to the newly created scene.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const sceneRef = op.createScene('MyScene'); return op.entityForRef(sceneRef);}, 'Create scene');console.log(scene);Create a scene capturing only the camera:
let model = await SketchUpApi.getActiveModel();let cameraScene = await model.performOperation(op => { const sceneRef = op.createScene( 'CameraOnly', { use_camera: true } ); return op.entityForRef(sceneRef);}, 'Create camera scene');console.log(cameraScene);- Scene for code examples
- entityForRef
SDK 2.30.0 Protocol 1.7.0
removeScene()
Section titled “removeScene()”removeScene(
scene):void
Permanently deletes a scene from the model. The scene tab and all its saved settings (camera, tag visibility, rendering options) are removed and cannot be recovered. This action cannot be undone.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference to delete |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const sceneRef = op.createScene('Temporary'); const before = op.entityForRef(sceneRef); op.removeScene(sceneRef); return before;}, 'Remove scene');console.log(scene.name);// => "Temporary"SDK 2.30.0 Protocol 1.7.0
sceneReorder()
Section titled “sceneReorder()”sceneReorder(
scene,index):void
Moves a scene to a different position in the scene tab order. Scenes are displayed left-to-right in SketchUp’s scene tabs; index 0 is the leftmost position. This affects the tab order but not the scene’s saved settings.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference to move |
|
|
|
|
the target zero-based tab position |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const firstRef = op.createScene('First'); op.createScene('Second'); op.sceneReorder(firstRef, 1);}, 'Reorder scenes');let scenes = await model.getScenes();console.log(scenes.map(s => s.name));// => ["Second", "First"]SDK 2.10.0 Protocol 1.7.0
sceneSetAnimationDelayTime()
Section titled “sceneSetAnimationDelayTime()”sceneSetAnimationDelayTime(
scene,animationDelayTime):void
Sets how long SketchUp pauses on this scene (in seconds) before transitioning to the next scene during an animation playback. A delay of 0 means the transition starts immediately.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
|
pause duration in seconds before transitioning |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const sceneRef = op.createScene('Long Pause'); op.sceneSetAnimationDelayTime(sceneRef, 3); return op.entityForRef(sceneRef);}, 'Set scene delay time');console.log(scene.animation.delayTime);// => 3SDK 2.10.0 Protocol 1.7.0
sceneSetAnimationTransitionTime()
Section titled “sceneSetAnimationTransitionTime()”sceneSetAnimationTransitionTime(
scene,animationTransitionTime):void
Sets how long (in seconds) the animated transition into this scene takes. During playback, SketchUp interpolates camera position and other properties from the previous scene over this duration before settling on this scene.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
|
transition duration in seconds |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const sceneRef = op.createScene('Slow Transition'); op.sceneSetAnimationTransitionTime(sceneRef, 5); return op.entityForRef(sceneRef);}, 'Set scene transition time');console.log(scene.animation.transitionTime);// => 5SDK 2.10.0 Protocol 1.7.0
sceneSetAxes()
Section titled “sceneSetAxes()”sceneSetAxes(
scene,origin,xaxis,yaxis,zaxis):void
Sets the custom axes for a scene, overriding the model’s default
axes when the scene is activated. Only takes effect if the scene
has use_axes enabled — set this via sceneSetProperties first.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
the origin of the axes |
|
|
|
the x-axis direction vector |
|
|
|
the y-axis direction vector |
|
|
|
the z-axis direction vector |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const sceneRef = op.createScene( 'Custom Axes', { use_axes: true } ); op.sceneSetAxes( sceneRef, [50, 50, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1] ); return op.entityForRef(sceneRef);}, 'Set scene axes');console.log(scene.axes.origin);// => Point3d { x: 50, y: 50, z: 0 }SDK 2.10.0 Protocol 1.7.0
sceneSetCamera()
Section titled “sceneSetCamera()”sceneSetCamera(
scene,camera):void
Sets the saved camera viewpoint for a scene. When the user
activates this scene, SketchUp will animate to the stored
camera position. Only takes effect if the scene has
use_camera enabled.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
the camera viewpoint to store for this scene |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const sceneRef = op.createScene( 'Front View', { use_camera: true } ); const cam = SketchUpApi.Camera.default() .setOrientation( [0, -500, 200], [0, 0, 0], [0, 0, 1] ) .setFieldOfView(35); op.sceneSetCamera(sceneRef, cam.build()); return op.entityForRef(sceneRef);}, 'Set scene camera');console.log(scene.camera.fieldOfView);// => 35SDK 2.10.0 Protocol 1.7.0
sceneSetDescription()
Section titled “sceneSetDescription()”sceneSetDescription(
scene,description):void
Sets the description for a scene. The description is visible in the Scenes panel alongside the scene name and can explain what the scene captures or when to use it.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
|
the description text |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const sceneRef = op.createScene('Overview'); op.sceneSetDescription( sceneRef, 'Wide shot of the whole site' ); return op.entityForRef(sceneRef);}, 'Set scene description');console.log(scene.description);// => "Wide shot of the whole site"SDK 2.10.0 Protocol 1.7.0
sceneSetDrawingElementVisibility()
Section titled “sceneSetDrawingElementVisibility()”sceneSetDrawingElementVisibility(
scene,element,visible):void
Stores the visibility state of a drawing element in a scene.
When the user activates this scene, the element is shown or
hidden accordingly. Only takes effect if the scene has
use_hidden_objects enabled. The element must be at the model
root, or be a component instance or section plane.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
the drawing element or element reference |
|
|
|
|
whether the element should be visible in this scene |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); const sceneRef = op.createScene( 'Hide Group', { use_hidden_objects: true } ); op.sceneSetDrawingElementVisibility( sceneRef, groupRef, false ); return op.entityForRef(sceneRef);}, 'Hide element in scene');let hidden = await scene.getHiddenElements();console.log(hidden.length);// => 1SDK 2.10.0 Protocol 1.7.0
sceneSetIncludedInAnimation()
Section titled “sceneSetIncludedInAnimation()”sceneSetIncludedInAnimation(
scene,includedInAnimation):void
Controls whether this scene is played back during a SketchUp animation. When false, the scene is skipped — the animation jumps from the previous scene to the next one. The scene tab still appears; it’s just excluded from playback.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
|
when false, this scene is skipped during animation |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const sceneRef = op.createScene('Skip Me'); op.sceneSetIncludedInAnimation(sceneRef, false); return op.entityForRef(sceneRef);}, 'Exclude scene from animation');console.log(scene.animation.included);// => falseSDK 2.10.0 Protocol 1.7.0
sceneSetName()
Section titled “sceneSetName()”sceneSetName(
scene,name):void
Renames a scene. The name appears in the scene’s tab at the bottom of the SketchUp viewport. If the name is not unique, SketchUp will append a suffix to make it unique.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
|
the new tab name for the scene |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const sceneRef = op.createScene('Draft'); op.sceneSetName(sceneRef, 'Final Render'); return op.entityForRef(sceneRef);}, 'Rename scene');console.log(scene.name);// => "Final Render"SDK 2.10.0 Protocol 1.7.0
sceneSetProperties()
Section titled “sceneSetProperties()”sceneSetProperties(
scene,properties):void
Configures which aspects of the model a scene saves and
restores. Properties are flags like use_camera,
use_hidden_tags, use_hidden_objects, and use_rendering_options.
When the user activates the scene, only the enabled properties
are applied. Omitted properties are left unchanged.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
|
the partial properties to set, any properties not included will be left alone |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const sceneRef = op.createScene('Camera Only'); op.sceneSetProperties(sceneRef, { use_camera: true, use_hidden_tags: false }); return op.entityForRef(sceneRef);}, 'Set scene properties');console.log(scene.properties.use_camera);// => trueSDK 2.10.0 Protocol 1.7.0
sceneSetTagFolderVisibility()
Section titled “sceneSetTagFolderVisibility()”sceneSetTagFolderVisibility(
scene,folder,visible):void
Stores the visibility state of a tag folder in a scene. All
tags in the folder are affected when the scene is activated.
Only takes effect if the scene has use_hidden_tags enabled.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
the tag folder or folder reference |
|
|
|
|
whether the tag folder should be visible in this scene |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const folderRef = op.createTagFolder('MEP'); const sceneRef = op.createScene( 'No MEP', { use_hidden_tags: true } ); op.sceneSetTagFolderVisibility( sceneRef, folderRef, false ); return op.entityForRef(sceneRef);}, 'Hide tag folder in scene');let hidden = await scene.getHiddenTagFolders();console.log(hidden.map(f => f.name));// => ["MEP"]SDK 2.10.0 Protocol 1.7.0
sceneSetTagVisibility()
Section titled “sceneSetTagVisibility()”sceneSetTagVisibility(
scene,tag,visible):void
Stores the visibility state of a tag in a scene. When the user
activates this scene, SketchUp shows or hides the tag
accordingly. Only takes effect if the scene has
use_hidden_tags enabled.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
the tag or tag reference |
|
|
|
|
whether the tag should be visible in this scene |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let scene = await model.performOperation(op => { const tagRef = op.createTag('Furniture'); const sceneRef = op.createScene( 'No Furniture', { use_hidden_tags: true } ); op.sceneSetTagVisibility(sceneRef, tagRef, false); return op.entityForRef(sceneRef);}, 'Hide tag in scene');let hidden = await scene.getHiddenTags();console.log(hidden.map(t => t.name));// => ["Furniture"]SDK 2.10.0 Protocol 1.7.0
sceneUpdate()
Section titled “sceneUpdate()”sceneUpdate(
scene,properties):void
Updates the scene by capturing the current model state for the
given properties. Unlike sceneSetProperties, which directly
sets property values, this method re-captures what SketchUp
currently shows — equivalent to “unset and re-set” the desired
property. Excluded and false properties are not updated.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the scene or scene reference |
|
|
|
|
the scene properties to re-capture from the current model state |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let sceneEntity = await model.performOperation(op => { const sceneRef = op.createScene( 'Updating View', { use_camera: true } ); return op.entityForRef(sceneRef);}, 'Create scene');
await model.view.setCamera( SketchUpApi.Camera.default() .setOrientation( [0, -800, 400], [0, 0, 0], [0, 0, 1] ) .build());
let updated = await model.performOperation(op => { op.sceneUpdate(sceneEntity, { use_camera: true }); return op.entityForRef(sceneEntity);}, 'Recapture scene camera');console.log(updated.camera.eye);// => Point3d { x: 0, y: -800, z: 400 }SDK 2.10.0 Protocol 1.7.0
SectionPlane
Section titled “SectionPlane”createSectionPlane()
Section titled “createSectionPlane()”createSectionPlane(
ref,planeCoefficients):SectionPlaneRef
Creates a section plane in the container. The plane cuts
through the model, revealing cross-sectional geometry. Activate
it with sectionPlaneActivate to make the cut visible.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the container or container ref |
|
|
|
the cutting plane as |
Returns
Section titled “Returns”a reference to the created section plane
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.updateRenderingOptions( { DisplaySectionPlanes: true });let sectionPlane = await model.performOperation(op => { const spRef = op.createSectionPlane( op.model, [0, 0, 1, -50] ); return op.entityForRef(spRef);}, 'Create section plane');console.log(sectionPlane);SDK 2.30.0 Protocol 1.13.0
SectionPlane for code examples
entitiesSetActivateSectionPlane()
Section titled “entitiesSetActivateSectionPlane()”entitiesSetActivateSectionPlane(
ref,sectionPlaneRef?):void
Activates a specific section plane in a container, or clears
the active section plane. The active plane’s cut is applied to
the view; only one plane can be active per container. Pass
undefined or null to deactivate all section planes in
the container.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the entities container or reference |
|
|
|
|
the section plane to activate, or |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.updateRenderingOptions( { DisplaySectionPlanes: true });let plane = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); const spRef = op.createSectionPlane( groupRef, [0, 0, 1, -25] ); op.entitiesSetActivateSectionPlane( groupRef, spRef ); return op.entityForRef(spRef);}, 'Activate section plane in group');console.log(plane.active);// => trueSDK 2.16.0 Protocol 1.13.0
sectionPlaneActivate()
Section titled “sectionPlaneActivate()”sectionPlaneActivate(
ref):void
Activates a section plane so its cut is visible and applied to the model view. Only one section plane can be active per container at a time — activating one automatically deactivates any previously active plane in the same container.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the section plane or section plane reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.updateRenderingOptions( { DisplaySectionPlanes: true });let plane = await model.performOperation(op => { const spRef = op.createSectionPlane( op.model, [0, 0, 1, -50] ); op.sectionPlaneActivate(spRef); return op.entityForRef(spRef);}, 'Activate section plane');console.log(plane.active);// => trueSDK 2.16.0 Protocol 1.13.0
sectionPlaneDeactivate()
Section titled “sectionPlaneDeactivate()”sectionPlaneDeactivate(
ref):void
Deactivates a section plane, restoring the full model view. The section plane remains in the model but its cut is no longer applied to the viewport.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the section plane or section plane reference |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.updateRenderingOptions( { DisplaySectionPlanes: true });let plane = await model.performOperation(op => { const spRef = op.createSectionPlane( op.model, [0, 0, 1, -50] ); op.sectionPlaneActivate(spRef); op.sectionPlaneDeactivate(spRef); return op.entityForRef(spRef);}, 'Deactivate section plane');console.log(plane.active);// => falseSDK 2.16.0 Protocol 1.13.0
sectionPlaneSetName()
Section titled “sectionPlaneSetName()”sectionPlaneSetName(
ref,name):void
Sets a display name for the section plane. The name appears
in the Outliner panel and helps identify which cut each plane
represents, like "North Elevation Cut".
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the section plane or section plane reference |
|
|
|
|
the display name |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.updateRenderingOptions( { DisplaySectionPlanes: true });let plane = await model.performOperation(op => { const spRef = op.createSectionPlane( op.model, [0, 0, 1, -50] ); op.sectionPlaneSetName( spRef, 'North Elevation Cut' ); return op.entityForRef(spRef);}, 'Name section plane');console.log(plane.name);// => "North Elevation Cut"SDK 2.16.0 Protocol 1.13.0
sectionPlaneSetPlane()
Section titled “sectionPlaneSetPlane()”sectionPlaneSetPlane(
ref,plane):void
Repositions and reorients a section plane by setting new plane coefficients. The plane cuts the model at the defined position and angle, revealing cross-sections of the geometry.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the section plane or section plane reference |
|
|
|
the new plane as |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.updateRenderingOptions( { DisplaySectionPlanes: true });let plane = await model.performOperation(op => { const spRef = op.createSectionPlane( op.model, [0, 0, 1, -50] ); op.sectionPlaneSetPlane(spRef, [0, 0, 1, -100]); return op.entityForRef(spRef);}, 'Reposition section plane');console.log(plane.plane.d);// => -100SDK 2.16.0 Protocol 1.13.0
sectionPlaneSetSymbol()
Section titled “sectionPlaneSetSymbol()”sectionPlaneSetSymbol(
ref,symbol):void
Sets the short symbol label displayed on the section plane’s
indicator arrow in the viewport, like "A" or "01".
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the section plane or section plane reference |
|
|
|
|
the short symbol label, like |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.updateRenderingOptions( { DisplaySectionPlanes: true });let plane = await model.performOperation(op => { const spRef = op.createSectionPlane( op.model, [0, 0, 1, -50] ); op.sectionPlaneSetSymbol(spRef, 'A'); return op.entityForRef(spRef);}, 'Set section plane symbol');console.log(plane.symbol);// => "A"SDK 2.16.0 Protocol 1.13.0
Shadow Info
Section titled “Shadow Info”shadowInfoSetCity()
Section titled “shadowInfoSetCity()”shadowInfoSetCity(
city,scene?):void
Sets the city label in the shadow info. This is a display-only
string that appears alongside the shadow settings — it does not
affect sun position calculations (use shadowInfoSetLatitude
and shadowInfoSetLongitude for that).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the city name to display, like |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetCountry()
Section titled “shadowInfoSetCountry()”shadowInfoSetCountry(
country,scene?):void
Sets the country label in the shadow info. Like shadowInfoSetCity,
this is a display-only string and does not affect sun position
calculations.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the country name to display, like |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetDark()
Section titled “shadowInfoSetDark()”shadowInfoSetDark(
dark,scene?):void
Sets the shadow darkness intensity, controlling how dark the shadow areas appear. Higher values produce darker, more pronounced shadows; lower values create lighter, softer shadows.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the shadow darkness, from 0 (lightest) to 100 (darkest) |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetDaylightSavings()
Section titled “shadowInfoSetDaylightSavings()”shadowInfoSetDaylightSavings(
daylightSavings,scene?):void
Controls whether daylight saving time is applied when computing shadow positions. When true, the shadow time is adjusted forward by one hour relative to standard time.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
when true, daylight saving time offset is applied |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetDisplayNorth()
Section titled “shadowInfoSetDisplayNorth()”shadowInfoSetDisplayNorth(
displayNorth,scene?):void
Shows or hides the True North indicator line in the viewport. This line marks the direction of True North in the model, which may differ from the green axis if a north angle offset has been set.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
when true, the north indicator line is visible |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetDisplayOnAllFaces()
Section titled “shadowInfoSetDisplayOnAllFaces()”shadowInfoSetDisplayOnAllFaces(
displayOnAllFaces,scene?):void
Controls whether shadows appear on ALL faces, including those not directly facing the sun. When false, only sun-facing faces receive shadows. Enabling this is more realistic but can slow rendering on complex models.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
when true, shadows render on all faces regardless of sun angle |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetDisplayOnGroundPlane()
Section titled “shadowInfoSetDisplayOnGroundPlane()”shadowInfoSetDisplayOnGroundPlane(
displayOnGroundPlane,scene?):void
Controls whether shadows are cast onto the virtual ground plane (Z = 0). Enabling this shows shadows falling on the ground even when no geometry exists there.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
when true, shadows render on the Z=0 ground plane |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetDisplayShadows()
Section titled “shadowInfoSetDisplayShadows()”shadowInfoSetDisplayShadows(
displayShadows,scene?):void
The master toggle for shadow rendering. When false, no shadows are drawn regardless of other shadow settings. Turning shadows off can significantly speed up rendering and navigation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
when true, shadow rendering is enabled |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetEdgesCastShadows()
Section titled “shadowInfoSetEdgesCastShadows()”shadowInfoSetEdgesCastShadows(
edgesCastShadows,scene?):void
Controls whether edges (as well as faces) cast shadows. When enabled, thin geometry like wires or mullions cast visible line shadows on surfaces beneath them.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
when true, edges cast shadows in addition to faces |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetLatitude()
Section titled “shadowInfoSetLatitude()”shadowInfoSetLatitude(
latitude,scene?):void
Sets the latitude used to compute the sun position for shadow rendering. This controls sun angle only — it does not change the model’s geographic location set via geo-location.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the latitude in degrees (−90 to 90) |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetLight()
Section titled “shadowInfoSetLight()”shadowInfoSetLight(
light,scene?):void
Sets the sunlight intensity for non-shadowed areas. Higher values make lit areas brighter and more washed out; lower values create a softer, more overcast look.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the light intensity, from 0 (dimmest) to 100 (brightest) |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetLongitude()
Section titled “shadowInfoSetLongitude()”shadowInfoSetLongitude(
longitude,scene?):void
Sets the longitude used to compute the sun position for shadow rendering. This controls sun angle only — it does not change the model’s geographic location set via geo-location.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the longitude in degrees (−180 to 180) |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetNorthAngle()
Section titled “shadowInfoSetNorthAngle()”shadowInfoSetNorthAngle(
northAngle,scene?):void
Sets the angle between the model’s green axis and True North, used to orient the sun for shadow rendering. Setting this to a non-zero value offsets north from the green axis and may break exports to geo-referenced formats.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the north angle in degrees |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetShadowTimeEpochSeconds()
Section titled “shadowInfoSetShadowTimeEpochSeconds()”shadowInfoSetShadowTimeEpochSeconds(
epochSeconds,scene?):void
Sets the date and time used for shadow calculations, expressed as a Unix timestamp (seconds since 1970-01-01 UTC). This determines the sun angle, so the same scene will look different at noon in June versus noon in December.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the Unix timestamp for the shadow time |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetTZOffset()
Section titled “shadowInfoSetTZOffset()”shadowInfoSetTZOffset(
tzOffset,scene?):void
Sets the UTC timezone offset used when computing shadow time.
For example, -8 means Pacific Standard Time (UTC−8). This
adjusts how the shadow time epoch maps to a local clock time
for sun position calculations.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the hours offset from UTC, like |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
shadowInfoSetUseSunForAllShading()
Section titled “shadowInfoSetUseSunForAllShading()”shadowInfoSetUseSunForAllShading(
useSunForAllShading,scene?):void
When enabled, SketchUp uses the sun direction for all ambient shading, even when shadows are off. This creates a shading effect that looks like sunlight without full shadow rendering, which is faster and still gives a sense of depth.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
when true, sun direction drives ambient shading |
|
|
since 2.10.0 when supplied sets the value for the shadow info associated with the scene rather than the model |
Returns
Section titled “Returns”void
createSnap()
Section titled “createSnap()”createSnap(
ref,position,direction,up?):SnapRef
Creates a snap point in the container. Snap points define attachment locations for component instances (like connection points for furniture or fixtures).
The returned SnapRef is only valid within this operation. To
access it after the operation ends, convert it with
entityForRef(snapRef).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the container or container ref |
|
|
|
the position of the snap point |
|
|
|
the direction vector of the snap point |
|
|
|
optional up vector (if omitted, SketchUp determines orientation automatically) |
Returns
Section titled “Returns”a reference to the created snap point
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let snap = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); const snapRef = op.createSnap( groupRef, [25, 25, 0], [0, 0, 1] ); return op.entityForRef(snapRef);}, 'Create snap on group');console.log(snap);- Snap for code examples
- entityForRef
SDK 2.30.0 Protocol 1.17.0
snapSetPose()
Section titled “snapSetPose()”snapSetPose(
ref,position,direction?,up?):void
Sets the position and/or orientation of an existing Snap point
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the Snap or SnapRef to modify |
|
|
|
the new position of the snap point |
|
|
|
optional direction vector; if omitted, SketchUp preserves current orientation |
|
|
|
optional up vector (requires direction to be specified) |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let snap = await model.performOperation(op => { const groupRef = op.createGroup(op.model); op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); const snapRef = op.createSnap( groupRef, [25, 25, 0], [0, 0, 1] ); op.snapSetPose( snapRef, [25, 25, 10], [0, 0, -1] ); return op.entityForRef(snapRef);}, 'Reposition snap on group');console.log(snap.position.toArray());// => [25, 25, 10]console.log(snap.direction.toArray());// => [0, 0, -1]SDK 2.20.0 Protocol 1.17.0
createDuplicateStyle()
Section titled “createDuplicateStyle()”createDuplicateStyle(
style):StyleRef
Duplicates an existing style, creating a new style with an auto-generated unique name and description. Useful for creating variations of a style without modifying the original.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the style to duplicate |
Returns
Section titled “Returns”Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let duplicate = await model.performOperation( async op => { const styleRef = await op.loadStyle({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'styles/defaults/Wireframe.style' } }); const dupRef = op.createDuplicateStyle(styleRef); return op.entityForRef(dupRef); }, 'Duplicate style');console.log(duplicate.name);// => "Wireframe Copy"Style for code examples
SDK 2.30.0
loadStyle()
Section titled “loadStyle()”loadStyle(
options):Promise<StyleRef>
Loads a style from the source. For a full list of default SketchUp styles use https://cdn.habitat.sketchup.com/styles/index.html.
This action cannot be undone.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
{ |
‐ |
|
|
|
When true, an existing style will be reused if one matches the resource. As a side effect, the loaded style becomes the selected style. Defaults to true. |
|
|
|
‐ |
Returns
Section titled “Returns”Promise<StyleRef>
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let style = await model.performOperation(async op => { const styleRef = await op.loadStyle({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'styles/defaults/Wireframe.style' } }); return op.entityForRef(styleRef);}, 'Load style');console.log(style.name);// => "Wireframe"SDK 2.30.0 Protocol 1.23.0
purgeUnusedStyles()
Section titled “purgeUnusedStyles()”purgeUnusedStyles():
void
Purges any unused styles from the model. This action cannot be undone.
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { await op.loadStyle({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'styles/defaults/Wireframe.style' } }); op.purgeUnusedStyles();}, 'Purge unused styles');let styles = await model.getStyles();let names = styles.map(s => s.name);console.log(names.includes('Wireframe'));// => falseSDK 2.30.0 Protocol 1.23.0
removeStyle()
Section titled “removeStyle()”removeStyle(
style):void
Removes a style from the model. This action cannot be undone.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
‐ |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let style = await model.performOperation(async op => { const styleRef = await op.loadStyle({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'styles/defaults/HiddenLine.style' } }); const before = op.entityForRef(styleRef); op.removeStyle(styleRef); return before;}, 'Remove style');console.log(style.name);// => "HiddenLine"SDK 2.30.0 Protocol 1.23.0
setSelectedStyle()
Section titled “setSelectedStyle()”setSelectedStyle(
style):void
Sets the selected style to the given instance. This action cannot be undone.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let selected = await model.performOperation( async op => { const styleRef = await op.loadStyle({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'styles/defaults/Wireframe.style' } }); op.setSelectedStyle(styleRef); return op.entityForRef(styleRef); }, 'Select style');console.log(selected.name);// => "Wireframe"SDK 2.30.0 Protocol 1.23.0
styleSetDescription()
Section titled “styleSetDescription()”styleSetDescription(
style,description):void
Sets the description of the style. This action cannot be undone.
If the style is the active style, the change may be reverted
when updateActiveStyle is called.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
‐ |
|
|
|
|
‐ |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let style = await model.performOperation(async op => { const styleRef = await op.loadStyle({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'styles/defaults/Wireframe.style' } }); op.styleSetDescription( styleRef, 'Outline-only presentation style' ); return op.entityForRef(styleRef);}, 'Set style description');console.log(style.description);// => "Outline-only presentation style"SDK 2.26.0 Protocol 1.23.0
styleSetName()
Section titled “styleSetName()”styleSetName(
style,name):void
Sets the name of the style. This action cannot be undone. If
the style is the active style, the change may be reverted when
updateActiveStyle is called.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
‐ |
|
|
|
|
‐ |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let style = await model.performOperation(async op => { const styleRef = await op.loadStyle({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'styles/defaults/Wireframe.style' } }); op.styleSetName(styleRef, 'My Wireframe'); return op.entityForRef(styleRef);}, 'Rename style');console.log(style.name);// => "My Wireframe"SDK 2.26.0 Protocol 1.23.0
styleUpdateRenderingOptions()
Section titled “styleUpdateRenderingOptions()”styleUpdateRenderingOptions(
style,update):void
Updates the rendering options for a style. Internally this selects the style, applies the rendering option changes, updates the selected style, then restores the previous selection.
Not all rendering option properties are supported for styles
(fog properties, for example). To fully configure a scene’s
rendering, call styleUpdateRenderingOptions followed by
sceneUpdateRenderingOptions.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
‐ |
|
|
|
‐ |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let style = await model.performOperation( async op => { const styleRef = await op.loadStyle({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'styles/defaults/Wireframe.style' } }); op.styleUpdateRenderingOptions(styleRef, { BackgroundColor: '#FFFFFF' }); return op.entityForRef(styleRef); }, 'Update style rendering options');let options = await style.getRenderingOptions();console.log(options.BackgroundColor.toHex());// => "#FFFFFFFF"updateSelectedStyle()
Section titled “updateSelectedStyle()”updateSelectedStyle():
void
Updates the selected style to match the settings of the active style. This action cannot be undone.
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(async op => { const styleRef = await op.loadStyle({ resource: { request: 'https://cdn.habitat.sketchup.com/' + 'styles/defaults/Wireframe.style' } }); op.setSelectedStyle(styleRef);}, 'Select style');
await model.updateRenderingOptions({ BackgroundColor: '#FF0000'});
await model.performOperation(op => { op.updateSelectedStyle();}, 'Save changes to style');
let selected = await model.getSelectedStyle();console.log(selected.info.hasBeenModified);// => falseSDK 2.30.0 Protocol 1.23.0
createTag()
Section titled “createTag()”createTag(
name,parent?):TagRef
Creates a tag (layer) with the given name under the parent.
If the name is already taken, this will return a reference to that existing tag
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the name of the tag |
|
|
optionally supplied parent to create the tag under. |
Returns
Section titled “Returns”Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let tag = await model.performOperation(op => { const tagRef = op.createTag('MyLayer'); return op.entityForRef(tagRef);}, 'Create tag');console.log(tag);console.log('Open the tag manager to see the new tag');SDK 2.30.0
drawingElementSetTag()
Section titled “drawingElementSetTag()”drawingElementSetTag(
ref,tag):void
Assigns a tag (layer) to a drawing element. Tags control visibility — when a tag is hidden, all entities on that tag disappear from view.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the drawing element or drawing element reference |
|
|
|
the tag to assign |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); const tagRef = op.createTag('Floors'); op.drawingElementSetTag(faceRef, tagRef);}, 'Assign tag to face');console.log('Tag assigned');drawingElementSetTagName()
Section titled “drawingElementSetTagName()”drawingElementSetTagName(
ref,tagName):void
Assigns a tag to a drawing element by the tag’s name string. Convenient when you know the tag name but don’t have a TagRef.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the drawing element or drawing element reference |
|
|
|
|
the display name of the tag, like |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const faceRef = op.createFace(op.model, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]); op.createTag('Floors'); op.drawingElementSetTagName(faceRef, 'Floors');}, 'Assign tag by name');console.log('Tag assigned by name');removeTag()
Section titled “removeTag()”removeTag(
ref,removeEntities?):void
Permanently deletes a tag from the model. When removeEntities
is false (the default), any entities on this tag are reassigned
to the default “Untagged” tag rather than deleted.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
the tag or tag reference |
|
|
|
|
|
when true, entities on this tag are also deleted |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let tags = await model.performOperation(op => { const tagRef = op.createTag('Scratch'); const before = op.entityForRef(tagRef); op.removeTag(tagRef); return { before };}, 'Remove tag');console.log(tags.before.name);// => "Scratch"SDK 2.30.0
removeTagFromFolder()
Section titled “removeTagFromFolder()”removeTagFromFolder(
ref,tagFolderRef):void
Removes a tag from a folder and moves it back to the top-level tag manager. The tag itself is not deleted — it remains in the model, just no longer nested under that folder.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag or tag reference to un-nest |
|
|
|
the folder to remove the tag from |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let tag = await model.performOperation(op => { const folderRef = op.createTagFolder('Structural'); const tagRef = op.createTag('Beams', folderRef); op.removeTagFromFolder(tagRef, folderRef); return op.entityForRef(tagRef);}, 'Un-nest tag from folder');console.log(tag.folderRef);// => undefinedSDK 2.30.0
tagAssignParent()
Section titled “tagAssignParent()”tagAssignParent(
ref,parent):void
Moves a tag into a different folder, or back to the top-level
tag manager. Pass the TagManager as parent to place the tag
at the root level (outside any folder).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag or tag reference to move |
|
|
|
the folder to move the tag into, or TagManager for root |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let tag = await model.performOperation(op => { const folderRef = op.createTagFolder('Framing'); const tagRef = op.createTag('Joists'); op.tagAssignParent(tagRef, folderRef); return op.entityForRef(tagRef);}, 'Move tag into folder');console.log(tag.folderRef !== undefined);// => truetagSetColor()
Section titled “tagSetColor()”tagSetColor(
ref,color):void
Alters the color of the tag, used in the Color By Tag functionality in SketchUp
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag or tag reference |
|
|
|
the color of the tag |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let tag = await model.performOperation(op => { const tagRef = op.createTag('Plumbing'); op.tagSetColor( tagRef, new SketchUpApi.Color(0, 100, 200) ); return op.entityForRef(tagRef);}, 'Set tag color');console.log(tag.color.toHex());// => "#0064c8"tagSetName()
Section titled “tagSetName()”tagSetName(
ref,name):void
Alters the name of the tag, if the name is not unique this will result in an error
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag or tag reference |
|
|
|
|
the new name |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let tag = await model.performOperation(op => { const tagRef = op.createTag('Walls'); op.tagSetName(tagRef, 'Exterior Walls'); return op.entityForRef(tagRef);}, 'Rename tag');console.log(tag.name);// => "Exterior Walls"tagSetVisible()
Section titled “tagSetVisible()”tagSetVisible(
ref,visible):void
Shows or hides all entities on the tag Visibility is hierarchical, an entity will only display if all the parent folders and its tag are visible.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag or tag reference |
|
|
|
|
true if the entities are visible |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let tag = await model.performOperation(op => { const tagRef = op.createTag('Furniture'); op.tagSetVisible(tagRef, false); return op.entityForRef(tagRef);}, 'Hide tag');console.log(tag.visible);// => falseTag Folder
Section titled “Tag Folder”createTag()
Section titled “createTag()”createTag(
name,parent?):TagRef
Creates a tag (layer) with the given name under the parent.
If the name is already taken, this will return a reference to that existing tag
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the name of the tag |
|
|
optionally supplied parent to create the tag under. |
Returns
Section titled “Returns”Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let tag = await model.performOperation(op => { const tagRef = op.createTag('MyLayer'); return op.entityForRef(tagRef);}, 'Create tag');console.log(tag);console.log('Open the tag manager to see the new tag');SDK 2.30.0
createTagFolder()
Section titled “createTagFolder()”createTagFolder(
name,parent?):TagFolderRef
Creates a tag folder, there are no requirements for the uniqueness of the name
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the name of the folder |
|
|
optionally a parent to create the folder on |
Returns
Section titled “Returns”Examples
Section titled “Examples”Create a tag folder.
let model = await SketchUpApi.getActiveModel();let folder = await model.performOperation(op => { const folderRef = op.createTagFolder('MyFolder'); return op.entityForRef(folderRef);}, 'Create tag folder');console.log(folder);Create a tag under a folder.
let model = await SketchUpApi.getActiveModel();let tag = await model.performOperation(op => { const folderRef = op.createTagFolder('MyFolder'); const tagRef = op.createTag('MyTag', folderRef); return op.entityForRef(tagRef);}, 'Create tag in folder');console.log(tag);SDK 2.30.0
removeTagFolder()
Section titled “removeTagFolder()”removeTagFolder(
ref,parent?):void
Removes a tag folder from the model
Folders and Tags will be reassigned to the parent of the deleted folder
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag folder or tag folder reference |
|
|
|
when supplied, the folder is only removed if the parent is the same as supplied |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let folder = await model.performOperation(op => { const folderRef = op.createTagFolder('Temporary'); const before = op.entityForRef(folderRef); op.removeTagFolder(folderRef); return before;}, 'Remove tag folder');console.log(folder.name);// => "Temporary"SDK 2.30.0
removeTagFromFolder()
Section titled “removeTagFromFolder()”removeTagFromFolder(
ref,tagFolderRef):void
Removes a tag from a folder and moves it back to the top-level tag manager. The tag itself is not deleted — it remains in the model, just no longer nested under that folder.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag or tag reference to un-nest |
|
|
|
the folder to remove the tag from |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let tag = await model.performOperation(op => { const folderRef = op.createTagFolder('Structural'); const tagRef = op.createTag('Beams', folderRef); op.removeTagFromFolder(tagRef, folderRef); return op.entityForRef(tagRef);}, 'Un-nest tag from folder');console.log(tag.folderRef);// => undefinedSDK 2.30.0
tagAssignParent()
Section titled “tagAssignParent()”tagAssignParent(
ref,parent):void
Moves a tag into a different folder, or back to the top-level
tag manager. Pass the TagManager as parent to place the tag
at the root level (outside any folder).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag or tag reference to move |
|
|
|
the folder to move the tag into, or TagManager for root |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let tag = await model.performOperation(op => { const folderRef = op.createTagFolder('Framing'); const tagRef = op.createTag('Joists'); op.tagAssignParent(tagRef, folderRef); return op.entityForRef(tagRef);}, 'Move tag into folder');console.log(tag.folderRef !== undefined);// => truetagFolderAssignParent()
Section titled “tagFolderAssignParent()”tagFolderAssignParent(
ref,parent):void
Moves a tag folder into a different parent folder, creating
nested folder hierarchies, or back to the top-level tag
manager. Pass the TagManager as parent to place the folder
at the root level.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag folder or tag folder reference to move |
|
|
|
the new parent folder, or TagManager for root |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let folder = await model.performOperation(op => { const parentRef = op.createTagFolder('Building'); const childRef = op.createTagFolder('Floor 1'); op.tagFolderAssignParent(childRef, parentRef); return op.entityForRef(childRef);}, 'Nest tag folder');console.log(folder.folderRef !== undefined);// => truetagFolderSetName()
Section titled “tagFolderSetName()”tagFolderSetName(
ref,name):void
Renames a tag folder. The name appears in the Tags panel to group related tags. Names do not need to be unique.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag folder or folder reference |
|
|
|
|
the new folder name |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let folder = await model.performOperation(op => { const folderRef = op.createTagFolder('MEP'); op.tagFolderSetName( folderRef, 'Mechanical & Electrical' ); return op.entityForRef(folderRef);}, 'Rename tag folder');console.log(folder.name);// => "Mechanical & Electrical"tagFolderSetVisible()
Section titled “tagFolderSetVisible()”tagFolderSetVisible(
ref,visible):void
Shows or hides all entities on the tag folder. Visibility is hierarchical, an entity will only display if all the parent folders and its tag are visible.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag or tag reference |
|
|
|
|
true if the entities are visible |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let folder = await model.performOperation(op => { const folderRef = op.createTagFolder('Site'); op.tagFolderSetVisible(folderRef, false); return op.entityForRef(folderRef);}, 'Hide tag folder');console.log(folder.visible);// => falsecreateText()
Section titled “createText()”createText(
ref,text,attachment,vector?):TextRef
Creates a text annotation in the model. Text entities can be screen-facing labels (2D) or leader-line callouts pointing at specific geometry (3D). The attachment point determines where the text’s arrow touches the model, and can optionally reference a nested component instance path so the text follows that geometry when it moves.
If you omit the leader vector, SketchUp creates a 2D screen-space text that always faces the camera. Providing a vector creates a 3D text with a leader line extending from the attachment point in the vector’s direction.
Returns a TextRef that’s valid only within this operation. To read the
text’s properties or use it outside the operation callback, call
entityForRef(textRef) before the operation ends.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The container where the text will be created (model, group, or component instance). |
|
|
|
|
The text string to display. |
|
|
Either a 3D point, or an object with |
|
|
|
Optional leader direction. Omit to create a 2D screen text. |
Returns
Section titled “Returns”A reference to the newly created text entity.
Examples
Section titled “Examples”Create a standalone text entity.
let model = await SketchUpApi.getActiveModel();let text = await model.performOperation(op => { const textRef = op.createText( op.model, 'Hello World', { point: [0, 0, 100] }, [0, 0, 50] ); return op.entityForRef(textRef);}, 'Create text');console.log(text);Create text attached to a vertical edge.
let model = await SketchUpApi.getActiveModel();let edgeText = await model.performOperation(op => { const edgeRefs = op.createEdge(op.model, [ [50, 50, 0], [50, 50, 100] ]); const textRef = op.createText( op.model, 'Edge Label', { point: [50, 50, 50] }, [50, 0, 0] ); return op.entityForRef(textRef);}, 'Create edge text');console.log(edgeText);- Text for code examples
- entityForRef
SDK 2.30.0 Protocol 1.19.0
textSetArrowType()
Section titled “textSetArrowType()”textSetArrowType(
ref,arrowType):void
Sets the arrowhead style at the leader’s attachment point. Values come from TextArrowType: None, Slash, Dot, Closed Arrow, or Open Arrow.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the text or text reference |
|
|
|
the arrowhead style |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const textRef = op.createText( op.model, 'Closed arrow', { point: [0, 0, 100] }, [0, 50, 0] ); op.textSetArrowType( textRef, SketchUpApi.TextArrowType.Closed );}, 'Set text arrow type');SDK 2.22.0 Protocol 1.19.0
textSetAttachedTo()
Section titled “textSetAttachedTo()”textSetAttachedTo(
ref,attachment):void
Changes what geometry this text label is attached to. The attachment includes the position and an instance path that navigates to the target entity inside nested groups or components. An instance path is required.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the text or text reference |
|
|
|
|
the new attachment location and instance path |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const textRef = op.createText( op.model, 'Attached to point', { point: [1050, 0, 100] }, [0, 50, 0] ); // Attach the text to a construction point const pointRef = op.createConstructionPoint( op.model, [1050, 0, 100] ); op.textSetAttachedTo(textRef, { point: [1050, 0, 100], instancePath: [pointRef], });}, 'Set text attached to');SDK 2.22.0 Protocol 1.19.0
textSetDisplayLeader()
Section titled “textSetDisplayLeader()”textSetDisplayLeader(
ref,displayLeader):void
Shows or hides the leader line for a text entity. A text entity can have a leader configured but temporarily hidden — this toggles its visibility without removing the leader.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the text or text reference |
|
|
|
|
when true, the leader line is visible |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const textRef = op.createText( op.model, 'No leader', { point: [150, 0, 100] }, [0, 50, 0] ); op.textSetDisplayLeader(textRef, false);}, 'Hide text leader');SDK 2.22.0 Protocol 1.19.0
textSetLeaderType()
Section titled “textSetLeaderType()”textSetLeaderType(
ref,leaderType):void
Sets how the leader line behaves in 3D space. Values come from TextLeaderType: View (leader stays flat to the screen) or Model (leader is fixed in 3D and rotates with the model).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the text or text reference |
|
|
|
the leader behavior in 3D space |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const textRef = op.createText( op.model, 'Model leader', { point: [900, 0, 100] }, [0, 50, 0] ); op.textSetLeaderType( textRef, SketchUpApi.TextLeaderType.Model );}, 'Set text leader type');SDK 2.22.0 Protocol 1.19.0
textSetLineWeight()
Section titled “textSetLineWeight()”textSetLineWeight(
ref,lineWeight):void
Sets the thickness of the leader line in pixels. A weight of 1 produces a thin line; higher values produce a bolder stroke. This affects only the leader line, not the text itself.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the text or text reference |
|
|
|
|
the leader line thickness in pixels |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const textRef = op.createText( op.model, 'Bold leader', { point: [750, 0, 100] }, [0, 50, 0] ); op.textSetLineWeight(textRef, 4);}, 'Set text line weight');SDK 2.22.0 Protocol 1.19.0
textSetPoint()
Section titled “textSetPoint()”textSetPoint(
ref,point):void
Moves the text anchor — the position of the text box itself in 3D model space. This does not affect the leader attachment point; it only repositions where the label text appears.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the text or text reference |
|
|
|
the new anchor position for the text box |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const textRef = op.createText( op.model, 'Moved anchor', { point: [300, 0, 100] }, [0, 50, 0] ); // Move the text anchor further along Y op.textSetPoint(textRef, [300, 50, 150]);}, 'Set text point');SDK 2.22.0 Protocol 1.19.0
textSetText()
Section titled “textSetText()”textSetText(
ref,text):void
Replaces the displayed label string of a text entity with new content. The string appears in the viewport as the label text.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the text or text reference |
|
|
|
|
the new label string to display |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const textRef = op.createText( op.model, 'Old label', { point: [600, 0, 100] }, [0, 50, 0] ); op.textSetText(textRef, 'New label');}, 'Set text content');SDK 2.22.0 Protocol 1.19.0
textSetVector()
Section titled “textSetVector()”textSetVector(
ref,vector):void
Sets the leader vector, which points from the text anchor toward the attachment point. The length of this vector determines how far the leader extends from the label.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the text or text reference |
|
|
|
the vector from the text box to the attachment point |
Returns
Section titled “Returns”void
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();await model.performOperation(op => { const textRef = op.createText( op.model, 'Longer leader', { point: [450, 0, 100] }, [0, 50, 0] ); // Extend the leader further along Y op.textSetVector(textRef, [0, 100, 0]);}, 'Set text vector');SDK 2.22.0 Protocol 1.19.0
Deprecated
Section titled “Deprecated”arcCreate()
Section titled “arcCreate()”arcCreate(
container,center,xaxis,normal,radius,startAngle,endAngle,numSegments?):ArcCurveAndComponents
Alias of createArc
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”ArcCurveAndComponents
SDK 2.23.0 Protocol 1.20.0
circleCreate()
Section titled “circleCreate()”circleCreate(
container,center,normal,radius,numSegments?):ArcCurveAndComponents
Alias of createCircle
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”ArcCurveAndComponents
SDK 2.23.0 Protocol 1.20.0
componentAddClassification()
Section titled “componentAddClassification()”componentAddClassification(
ref,schemaName,schemaType):void
Alias of definitionAddClassification
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentCreate()
Section titled “componentCreate()”componentCreate(
name):ComponentDefinitionRef
Alias of createDefinition
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”componentForRef()
Section titled “componentForRef()”componentForRef(
ref):Promise<ComponentDefinition>
Finds a ComponentDefinition from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component reference |
Returns
Section titled “Returns”Promise<ComponentDefinition>
a promise containing the component
componentInstanceApplyTransformation()
Section titled “componentInstanceApplyTransformation()”componentInstanceApplyTransformation(
ref,transformation):void
Alias of instanceApplyTransformation
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”void
componentInstanceCreate()
Section titled “componentInstanceCreate()”componentInstanceCreate(
ref,componentRef,transform?):ComponentInstanceRef
Alias of createInstance
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”componentInstanceForRef()
Section titled “componentInstanceForRef()”componentInstanceForRef(
ref):Promise<ComponentInstance>
Finds a ComponentInstance from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the component instance reference |
Returns
Section titled “Returns”Promise<ComponentInstance>
a promise containing the component instance
componentInstanceSetGluedTo()
Section titled “componentInstanceSetGluedTo()”componentInstanceSetGluedTo(
entity,element):void
Alias of instanceSetGluedTo
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentInstanceSetLocked()
Section titled “componentInstanceSetLocked()”componentInstanceSetLocked(
ref,value):void
Alias of instanceSetLocked
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentInstanceSetName()
Section titled “componentInstanceSetName()”componentInstanceSetName(
ref,value):void
Alias of instanceSetName
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentInstanceSetTransformation()
Section titled “componentInstanceSetTransformation()”componentInstanceSetTransformation(
ref,transformation):void
Alias of instanceSetTransformation
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”void
componentInstancesForRefs()
Section titled “componentInstancesForRefs()”componentInstancesForRefs(
refs):Promise<readonlyComponentInstance[]>
Finds ComponentInstances from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the component instance references |
Returns
Section titled “Returns”Promise<readonly ComponentInstance[]>
a promise containing the component instances in the order specified
componentRemoveClassification()
Section titled “componentRemoveClassification()”componentRemoveClassification(
ref,schemaName,schemaType):void
Alias of definitionRemoveClassification
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”void
SDK 2.5.0 Protocol 1.3.0
componentSetClassificationValue()
Section titled “componentSetClassificationValue()”componentSetClassificationValue(
ref,path,value):void
Alias of definitionSetClassificationValue
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentSetDescription()
Section titled “componentSetDescription()”componentSetDescription(
ref,value):void
Alias of definitionSetDescription
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentSetName()
Section titled “componentSetName()”componentSetName(
ref,value):void
Alias of definitionSetName
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentSetNoScaleMask()
Section titled “componentSetNoScaleMask()”componentSetNoScaleMask(
ref,value):void
Alias of definitionSetNoScaleMask
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentSetShadowsToFaceSun()
Section titled “componentSetShadowsToFaceSun()”componentSetShadowsToFaceSun(
ref,value):void
Alias of definitionSetShadowsToFaceSun
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentSetTo2d()
Section titled “componentSetTo2d()”componentSetTo2d(
ref,value):void
Alias of definitionSetTo2d
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentSetToCutOpening()
Section titled “componentSetToCutOpening()”componentSetToCutOpening(
ref,value):void
Alias of definitionSetToCutOpening
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentSetToFaceCamera()
Section titled “componentSetToFaceCamera()”componentSetToFaceCamera(
ref,value):void
Alias of definitionSetToFaceCamera
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
componentSetToSnapTo()
Section titled “componentSetToSnapTo()”componentSetToSnapTo(
ref,value):void
Alias of definitionSetToSnapTo
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”void
componentsForRefs()
Section titled “componentsForRefs()”componentsForRefs(
refs):Promise<readonlyComponentDefinition[]>
Finds Components from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the component references |
Returns
Section titled “Returns”Promise<readonly ComponentDefinition[]>
a promise containing the components in the order specified
componentsLoad()
Section titled “componentsLoad()”componentsLoad(
blob,options?):Promise<ComponentDefinitionRef>
Loads the blob as a component ref
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the binary representation of the component |
|
|
|
component loading options |
Returns
Section titled “Returns”Promise<ComponentDefinitionRef>
SDK 2.6.0 Protocol 1.4.0
Throws
Section titled “Throws”ComponentLoadError if SketchUp cannot load the component from the binary
componentsLoadFromUrl()
Section titled “componentsLoadFromUrl()”componentsLoadFromUrl(
input,init?,options?):Promise<ComponentDefinitionRef>
Loads a component from the url
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the fetch RequestInfo or URL |
|
|
|
optional fetch request initialization parameters |
|
|
|
component loading options |
Returns
Section titled “Returns”Promise<ComponentDefinitionRef>
SDK 2.6.0 Protocol 1.4.0
Throws
Section titled “Throws”ComponentLoadError if SketchUp cannot load the component from the binary or if the endpoint returns a non-2xx status code
componentsPurgeUnused()
Section titled “componentsPurgeUnused()”componentsPurgeUnused():
void
Alias of purgeUnusedDefinitions
Returns
Section titled “Returns”void
componentsRemove()
Section titled “componentsRemove()”componentsRemove(
ref):void
Alias of removeDefinition
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”void
constructionLineCreate()
Section titled “constructionLineCreate()”constructionLineCreate(
ref,start,end,stipple?):ConstructionLineRef
Alias of createConstructionLine
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”SDK 2.7.0 Protocol 1.5.0
constructionLineForRef()
Section titled “constructionLineForRef()”constructionLineForRef(
ref):Promise<ConstructionLine>
Finds a constructionLine from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the constructionLine reference |
Returns
Section titled “Returns”Promise<ConstructionLine>
a promise containing the ConstructionLine
constructionLinesForRefs()
Section titled “constructionLinesForRefs()”constructionLinesForRefs(
refs):Promise<readonlyConstructionLine[]>
Finds ConstructionLines from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the construction lines references |
Returns
Section titled “Returns”Promise<readonly ConstructionLine[]>
a promise containing the ConstructionLine in the order specified
constructionPointCreate()
Section titled “constructionPointCreate()”constructionPointCreate(
ref,point):ConstructionPointRef
Alias of createConstructionPoint
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”SDK 2.7.0 Protocol 1.5.0
constructionPointForRef()
Section titled “constructionPointForRef()”constructionPointForRef(
ref):Promise<ConstructionPoint>
Finds a constructionPoint from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the constructionPoint reference |
Returns
Section titled “Returns”Promise<ConstructionPoint>
a promise containing the ConstructionPoint
constructionPointsForRefs()
Section titled “constructionPointsForRefs()”constructionPointsForRefs(
refs):Promise<readonlyConstructionPoint[]>
Finds ConstructionPoints from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the construction points references |
Returns
Section titled “Returns”Promise<readonly ConstructionPoint[]>
a promise containing the ConstructionPoint in the order specified
curveCreate()
Section titled “curveCreate()”curveCreate(
container,points):CurveAndComponents
Alias of createCurve
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”CurveAndComponents
SDK 2.23.0 Protocol 1.20.0
curveCreateByWeldingEdges()
Section titled “curveCreateByWeldingEdges()”curveCreateByWeldingEdges(
edges):Promise<CurveRef[]>
Alias of createCurveByWeldingEdges
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”Promise<CurveRef[]>
SDK 2.23.0 Protocol 1.20.0
dimensionLinearCreate()
Section titled “dimensionLinearCreate()”dimensionLinearCreate(
container,start,end,offset):DimensionLinearRef
Alias of createDimensionLinear
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”SDK 2.23.0 Protocol 1.20.0
dimensionRadialCreate()
Section titled “dimensionRadialCreate()”dimensionRadialCreate(
container,arcCurve,leaderBreakPoint):DimensionRadialRef
Alias of createDimensionRadial
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”SDK 2.23.0 Protocol 1.20.0
drawingElementForRef()
Section titled “drawingElementForRef()”drawingElementForRef(
ref):Promise<DrawingElement>
Finds a DrawingElement from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the drawing element reference |
Returns
Section titled “Returns”Promise<DrawingElement>
a promise containing the drawing element
drawingElementsForRefs()
Section titled “drawingElementsForRefs()”drawingElementsForRefs(
refs):Promise<readonlyDrawingElement[]>
Finds DrawingElements from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the drawing element references |
Returns
Section titled “Returns”Promise<readonly DrawingElement[]>
a promise containing the drawing elements in the order specified
edgeCreate()
Section titled “edgeCreate()”edgeCreate(
ref,vertices): readonlyEdgeRef[]
Alias of createEdge
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
readonly |
Returns
Section titled “Returns”readonly EdgeRef[]
edgeForRef()
Section titled “edgeForRef()”edgeForRef(
ref):Promise<Edge>
Finds a Edge from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the edge reference |
Returns
Section titled “Returns”Promise<Edge>
a promise containing the edge
edgesForRefs()
Section titled “edgesForRefs()”edgesForRefs(
refs):Promise<readonlyEdge[]>
Finds Edges from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the edge references |
Returns
Section titled “Returns”Promise<readonly Edge[]>
a promise containing the edges in the order specified
faceCreate()
Section titled “faceCreate()”faceCreate(
ref,vertices):FaceRef
Alias of createFace
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
readonly |
Returns
Section titled “Returns”faceCreateFromEdges()
Section titled “faceCreateFromEdges()”faceCreateFromEdges(
ref,edges):FaceRef
Alias of createFaceFromEdges
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”SDK 2.25.0 Protocol 1.22.0
faceForRef()
Section titled “faceForRef()”faceForRef(
ref):Promise<Face>
Finds a Face from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the face reference |
Returns
Section titled “Returns”Promise<Face>
a promise containing the face
facesForRefs()
Section titled “facesForRefs()”facesForRefs(
refs):Promise<readonlyFace[]>
Finds Faces from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the face references |
Returns
Section titled “Returns”Promise<readonly Face[]>
a promise containing the faces in the order specified
groupCreate()
Section titled “groupCreate()”groupCreate(
ref):GroupRef
Alias of createGroup
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”groupForRef()
Section titled “groupForRef()”groupForRef(
ref):Promise<Group>
Finds a Group from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the group reference |
Returns
Section titled “Returns”Promise<Group>
a promise containing the group
groupsForRefs()
Section titled “groupsForRefs()”groupsForRefs(
refs):Promise<readonlyGroup[]>
Finds Groups from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the group references |
Returns
Section titled “Returns”Promise<readonly Group[]>
a promise containing the groups in the order specified
imageCreate()
Section titled “imageCreate()”Call Signature
Section titled “Call Signature”imageCreate(
container,options):ImageEntityRef
Alias of createImage
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”SDK 2.21.0 Protocol 1.18.0
Call Signature
Section titled “Call Signature”imageCreate(
container,options):Promise<ImageEntityRef>
Alias of createImage
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”Promise<ImageEntityRef>
SDK 2.21.0 Protocol 1.18.0
imageForRef()
Section titled “imageForRef()”imageForRef(
ref):Promise<ImageEntity>
Finds a Image from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the image reference |
Returns
Section titled “Returns”Promise<ImageEntity>
a promise containing the group
imagesForRefs()
Section titled “imagesForRefs()”imagesForRefs(
refs):Promise<readonlyImageEntity[]>
Finds Images from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the image references |
Returns
Section titled “Returns”Promise<readonly ImageEntity[]>
a promise containing the images in the order specified
materialForRef()
Section titled “materialForRef()”materialForRef(
ref):Promise<Material>
Finds a Material from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the material reference |
Returns
Section titled “Returns”Promise<Material>
a promise containing the material
materialsAdd()
Section titled “materialsAdd()”materialsAdd(
name):MaterialRef
Alias of createMaterial
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”materialsForRefs()
Section titled “materialsForRefs()”materialsForRefs(
refs):Promise<readonlyMaterial[]>
Finds Materials from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the material references |
Returns
Section titled “Returns”Promise<readonly Material[]>
a promise containing the materials in the order specified
materialsLoad()
Section titled “materialsLoad()”materialsLoad(
blob,options?):Promise<MaterialRef>
Loads a material from a binary blob of data (must be a valid skm file)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the data blob |
|
|
|
material loading options |
Returns
Section titled “Returns”Promise<MaterialRef>
SDK 2.12.0 protocol 1.9.0
materialsLoadDataUrl()
Section titled “materialsLoadDataUrl()”materialsLoadDataUrl(
dataUrl,options?):Promise<MaterialRef>
Loads a material from a binary blob of data (must be a valid skm file)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the data url |
|
|
|
material loading options |
Returns
Section titled “Returns”Promise<MaterialRef>
SDK 2.12.0 protocol 1.9.0
materialsLoadFromUrl()
Section titled “materialsLoadFromUrl()”materialsLoadFromUrl(
input,init?,options?):Promise<MaterialRef>
Loads a material from the given URL
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
the input url |
|
|
|
the request options for the http request |
|
|
|
material loading options |
Returns
Section titled “Returns”Promise<MaterialRef>
SDK 2.12.0 protocol 1.9.0
materialsPurgeUnused()
Section titled “materialsPurgeUnused()”materialsPurgeUnused():
void
Alias of purgeUnusedMaterials
Returns
Section titled “Returns”void
materialsRemove()
Section titled “materialsRemove()”materialsRemove(
material):void
Alias of removeMaterial
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”void
materialsSetCurrent()
Section titled “materialsSetCurrent()”materialsSetCurrent(
material):void
Alias of setCurrentMaterial
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”void
ngonCreate()
Section titled “ngonCreate()”ngonCreate(
container,center,normal,radius,numSegments?):ArcCurveAndComponents
Alias of createNgon
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”ArcCurveAndComponents
SDK 2.23.0 Protocol 1.20.0
sceneCreate()
Section titled “sceneCreate()”sceneCreate(
name?,properties?,index?):SceneRef
Alias of createScene
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”SDK 2.10.0 Protocol 1.7.0
sceneForRef()
Section titled “sceneForRef()”sceneForRef(
ref):Promise<Scene>
Finds a Tag from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag reference |
Returns
Section titled “Returns”Promise<Scene>
a promise containing the tag
sceneRemove()
Section titled “sceneRemove()”sceneRemove(
scene):void
Alias of removeScene
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”void
SDK 2.10.0 Protocol 1.7.0
sectionPlaneCreate()
Section titled “sectionPlaneCreate()”sectionPlaneCreate(
ref,planeCoefficients):SectionPlaneRef
Alias of createSectionPlane
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”SDK 2.16.0 Protocol 1.13.0
sectionPlaneForRef()
Section titled “sectionPlaneForRef()”sectionPlaneForRef(
ref):Promise<SectionPlane>
Finds a sectionPlane from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the sectionPlane reference |
Returns
Section titled “Returns”Promise<SectionPlane>
a promise containing the SectionPlane
SDK 2.16.0 Protocol 1.13.0
sectionPlanesForRefs()
Section titled “sectionPlanesForRefs()”sectionPlanesForRefs(
refs):Promise<readonlySectionPlane[]>
Finds SectionPlanes from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the section planes references |
Returns
Section titled “Returns”Promise<readonly SectionPlane[]>
a promise containing the SectionPlanes in the order specified
SDK 2.16.0 Protocol 1.13.0
snapCreate()
Section titled “snapCreate()”snapCreate(
ref,position,direction,up?):SnapRef
Alias of createSnap
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”SDK 2.20.0 Protocol 1.17.0
snapForRef()
Section titled “snapForRef()”snapForRef(
ref):Promise<Snap>
Finds a snap from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the snap reference |
Returns
Section titled “Returns”Promise<Snap>
a promise containing the Snap
styleCreateDuplicate()
Section titled “styleCreateDuplicate()”styleCreateDuplicate(
style):StyleRef
Alias of createDuplicateStyle
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”stylesLoad()
Section titled “stylesLoad()”stylesLoad(
options):Promise<StyleRef>
Alias of loadStyle
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
{ |
|
|
|
|
|
|
Returns
Section titled “Returns”Promise<StyleRef>
SDK 2.26.0 Protocol 1.23.0
stylesPurgeUnused()
Section titled “stylesPurgeUnused()”stylesPurgeUnused():
void
Alias of purgeUnusedStyles
Returns
Section titled “Returns”void
SDK 2.26.0 Protocol 1.23.0
stylesRemove()
Section titled “stylesRemove()”stylesRemove(
style):void
Alias of removeStyle
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”void
SDK 2.26.0 Protocol 1.23.0
stylesSetSelected()
Section titled “stylesSetSelected()”stylesSetSelected(
style):void
Alias of setSelectedStyle
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”void
SDK 2.26.0 Protocol 1.23.0
stylesUpdateSelected()
Section titled “stylesUpdateSelected()”stylesUpdateSelected():
void
Alias of updateSelectedStyle
Returns
Section titled “Returns”void
SDK 2.26.0 Protocol 1.23.0
tagCreate()
Section titled “tagCreate()”tagCreate(
name,parent?):TagRef
Alias of createTag
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”tagFolderCreate()
Section titled “tagFolderCreate()”tagFolderCreate(
name,parent?):TagFolderRef
Alias of createTagFolder
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”tagFolderForRef()
Section titled “tagFolderForRef()”tagFolderForRef(
ref):Promise<TagFolder>
Finds a TagFolder from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag folder reference |
Returns
Section titled “Returns”Promise<TagFolder>
a promise containing the tag folder
tagFolderRemove()
Section titled “tagFolderRemove()”tagFolderRemove(
ref,parent?):void
Alias of removeTagFolder
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”void
tagFoldersForRefs()
Section titled “tagFoldersForRefs()”tagFoldersForRefs(
refs):Promise<readonlyTagFolder[]>
Finds TagFolders from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the tag folder references |
Returns
Section titled “Returns”Promise<readonly TagFolder[]>
a promise containing the tag folders in the order specified
tagForRef()
Section titled “tagForRef()”tagForRef(
ref):Promise<Tag>
Finds a Tag from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the tag reference |
Returns
Section titled “Returns”Promise<Tag>
a promise containing the tag
tagRemove()
Section titled “tagRemove()”tagRemove(
ref,removeEntities?):void
Alias of removeTag
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”void
tagRemoveFromFolder()
Section titled “tagRemoveFromFolder()”tagRemoveFromFolder(
ref,tagFolderRef):void
Alias of removeTagFromFolder
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”void
tagsForRefs()
Section titled “tagsForRefs()”tagsForRefs(
refs):Promise<readonlyTag[]>
Finds Tags from the supplied references
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
the tag references |
Returns
Section titled “Returns”Promise<readonly Tag[]>
a promise containing the tags in the order specified
textCreate()
Section titled “textCreate()”textCreate(
ref,text,attachment,vector?):TextRef
Alias of createText
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”SDK 2.22.0 Protocol 1.19.0
textForRef()
Section titled “textForRef()”textForRef(
ref):Promise<Text>
Finds a text from the supplied reference
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the text reference |
Returns
Section titled “Returns”Promise<Text>
a promise containing the Text