Skip to content

Texture

The image data behind a textured material.

When a material has an image applied (rather than just a solid color), its texture property holds a Texture instance. The Texture tells you the image dimensions in both pixel space (imageWidth/imageHeight) and model space (width/height in inches), and lets you export the image data for use outside SketchUp.

let model = await SketchUpApi.getActiveModel();
let materials = await model.getMaterials();
// Find a textured material
let textured = materials.values.find(
m => m.texture !== undefined
);
if (textured) {
const tex = textured.texture;
console.log(tex.imageWidth, tex.imageHeight);
// => pixel dimensions (e.g. 512 512)
console.log(tex.width, tex.height);
// => model-space size in inches
}

SDK 2.12.0 Protocol 1.9.0

readonly attributes: Attributes

Custom attribute dictionaries attached to this texture.


readonly color: Color

The average color of this texture image.


readonly height: number

Physical height of the texture in the model, in inches.


readonly id: number

The persistent ID that uniquely identifies this texture.


readonly imageHeight: number

Height of the source image in pixels.


readonly imageWidth: number

Width of the source image in pixels.


readonly type: Texture = EntityType.Texture


readonly width: number

Physical width of the texture in the model, in inches.

get sketchupId(): SketchupId

JS API identifier for this texture. Pass it to API methods that accept a sketchupId.

SketchupId


get typeName(): string

Returns a named variant of the type field.

SDK 2.35.0

string

getImage(fileType, options?): Promise<string>

Exports the texture image as a base64-encoded string in the specified format. Use this to download or display the texture outside of SketchUp.

Parameter Type Description

fileType

ImageFileType

'png', 'jpg', or 'webp'

options?

TextureExportOptions

export options (e.g. colorize settings)

Promise<string>

SDK 2.30.3 Protocol 1.9.0


refresh(): Promise<Texture>

Re-fetches this texture from SketchUp to get its current state (dimensions or color may have changed).

Promise<Texture>


toString(): string

string

export(fileType, options?): Promise<string>

Parameter Type

fileType

ImageFileType

options?

TextureExportOptions

Promise<string>

SDK 2.12.0 Protocol 1.9.0