Skip to content

Layer

app.activeDocument.layers[index]

A layer in an Illustrator document. Layers may contain nested layers, which are called sublayers in the user interface.

The layer object contains all of the page items in the specific layer as elements.

Your script can access page items as elements of either the Layer object or as elements of the Document object. When accessing page items as elements of a layer, only objects in that layer can be accessed. To access page items throughout the entire document, be sure to refer to them as contained by the document.


app.activeDocument.layers[index].artworkKnockout

Is this object used to create a knockout, and if so, what kind of knockout. You cannot set this value to KnockoutState.Unknown.

KnockoutState


app.activeDocument.layers[index].blendingMode

The mode used when compositing an object.

BlendModes


app.activeDocument.layers[index].color

The layer’s selection mark color.

RGBColor


app.activeDocument.layers[index].compoundPathItems

The compound path items contained in this layer.

CompoundPathItems; read-only.


app.activeDocument.layers[index].dimPlacedImages

If true, placed images should be rendered as dimmed in this layer.

Boolean.


app.activeDocument.layers[index].graphItems

The graph items contained in this layer.

GraphItems; read-only.


app.activeDocument.layers[index].groupItems

The group items contained in this layer.

GroupItems; read-only.


app.activeDocument.layers[index].hasSelectedArtwork

If true, an object in this layer has been selected; set to false to deselect all objects in the layer.

Boolean.


app.activeDocument.layers[index].isIsolated

If true, this object is isolated.

Boolean.


app.activeDocument.layers[index].layers

The layers contained in this layer.

Layers; read-only.


app.activeDocument.layers[index].legacyTextItems

The legacy text items in this layer.

LegacyTextItems; read-only.


app.activeDocument.layers[index].locked

If true, this layer is editable; set to false to lock the layer.

Boolean.


app.activeDocument.layers[index].meshItems

The mesh items contained in this layer.

MeshItems; read-only.


app.activeDocument.layers[index].name

The name of this layer.

String.


app.activeDocument.layers[index].nonNativeItems

The non-native art items in this layer.

NonNativeItems


app.activeDocument.layers[index].opacity

The opacity of the layer.

Range: 0.0 to 100.0.

Number (double).


app.activeDocument.layers[index].pageItems

The page items (all art item classes) contained in this layer.

PageItems


app.activeDocument.layers[index].parent

The document or layer that contains this layer.

Document or Layer; read-only.


app.activeDocument.layers[index].pathItems

The path items contained in this layer.

PathItems; read-only.


app.activeDocument.layers[index].placedItems

The placed items contained in this layer.

PlacedItems; read-only.


app.activeDocument.layers[index].pluginItems

The plug-in items contained in this layer.

PluginItems; read-only.


app.activeDocument.layers[index].preview

If true, this layer should be displayed using preview mode.

Boolean.


app.activeDocument.layers[index].printable

If true, this layer should be printed when printing the document.

Boolean.


app.activeDocument.layers[index].rasterItems

The raster items contained in this layer.

RasterItems; read-only.


app.activeDocument.layers[index].sliced

If true, the layer item is sliced.

Default: false.

Boolean.


app.activeDocument.layers[index].symbolItems

The symbol items contained in the layer.

SymbolItems; read-only.


app.activeDocument.layers[index].textFrames

The text art items contained in this layer.

TextFrameItems; read-only.


app.activeDocument.layers[index].typename

The class name of the referenced object.

String; read-only.


app.activeDocument.layers[index].visible

If true, this layer is visible.

Boolean.


app.activeDocument.layers[index].zOrderPosition

The position of this layer within the stacking order of layers in the document.

Number (long); read-only.


app.activeDocument.layers[index].move(relativeObject, insertionLocation)

Moves the object.

ParameterTypeDescription
relativeObjectObjectObject to move element within
insertionLocationElementPlacement, optionalLocation to move element to

Layer


app.activeDocument.layers[index].remove()

Deletes this object.

Nothing.


app.activeDocument.layers[index].zOrder(ZOrderCmd)

Arranges the layer’s position in the stacking order of the containing layer or document (parent) of this object.

ParameterTypeDescription
zOrderCmdZOrderMethodStacking order arrangement method

Nothing.


// Moves the bottom layer to become the topmost layer
if (documents.length > 0) {
var countOfLayers = activeDocument.layers.length;
if (countOfLayers > 1) {
var bottomLayer = activeDocument.layers[countOfLayers - 1];
bottomLayer.zOrder(ZOrderMethod.BRINGTOFRONT);
} else {
alert("The active document only has only 1 layer");
}
}