Materials
The collection of all materials in the model.
Retrieve the materials collection with model.getMaterials().
It provides the full list via values and fast lookups by
name or ID. Because it’s a snapshot, call refresh() if the
model’s materials may have changed since you fetched it.
See the Materials Examples for more ways to use this class.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let materials = await model.getMaterials();
console.log(materials.values.length);// => number of materials in the model
// Look up a material by namelet brick = materials.findMaterialByName( 'Brick_Antique');if (brick) { console.log(brick.color.toHex());}Properties
Section titled “Properties”values
Section titled “values”
readonlyvalues: readonlyMaterial[]
All materials in the model, in no particular order.
Methods
Section titled “Methods”findMaterialById()
Section titled “findMaterialById()”findMaterialById(
id):Material|undefined
Finds a material by its persistent numeric ID. Returns
undefined if no material with that ID exists.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”Material | undefined
findMaterialByName()
Section titled “findMaterialByName()”findMaterialByName(
name):Material|undefined
Finds a material by its internal name (case-sensitive).
Returns undefined if no material with that name exists.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”Material | undefined
refresh()
Section titled “refresh()”refresh():
Promise<Materials>
Re-fetches the material list from SketchUp to pick up any materials created or deleted since this snapshot was taken.
Returns
Section titled “Returns”Promise<Materials>