Back to Uxp Photoshop

Layers

src/pages/ps_reference/classes/layers.md

2.2.01.5 KB
Original Source

Layers

A collections class allowing for array access into the applications list of layers on a document, while also providing familiar methods from ExtendScript, like getByName

javascript
// Iterate through all the top layers of frontmost document
app.activeDocument.layers.forEach(h => console.log(h.name));

Indexable

▪ [index: number]: Layer

Used to access the layers in the collection.

javascript
// Iterate through all the top layers of frontmost document
app.activeDocument.layers.forEach(h => console.log(h.name));

Properties

NameTypeAccessMin VersionDescription
lengthnumberR22.5Number of Layer elements in this collection.
typenamestringR22.5The name for this object collection: Layers.

Methods

add

<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">22.5</span>

async : Promise<Layer>

Create a new layer.

javascript
let newDoc1 = await app.activeDocument.layers.add();

getByName

<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">22.5</span>

Layer

Find the first layer with the matching name.

Parameters

NameType
namestring