Skip to content

Patterns

app.activeDocument.patterns

A collection of Pattern objects in a document.


app.activeDocument.patterns.length

Number of elements in the collection.

Number; read-only.


app.activeDocument.patterns.parent

The object’s container.

Object; read-only.


app.activeDocument.patterns.typename

The class name of the object.

String; read-only.


app.activeDocument.patterns.add()

Creates a new object.

Pattern


app.activeDocument.patterns.getByName(name)

Get the first element in the collection with the provided name.

ParameterTypeDescription
nameStringName of element to get

Pattern


app.activeDocument.patterns.index(itemKey)

Gets an element from the collection.

ParameterTypeDescription
itemKeyString, NumberString or number key

Pattern


app.activeDocument.patterns.removeAll()

Deletes all elements in the collection.

Nothing.


// Deletes the last pattern from the current document.
if (app.documents.length > 0) {
var lastIndex = app.activeDocument.patterns.length - 1;
var patternToRemove = app.activeDocument.patterns[lastIndex];
var patternName = patternToRemove.name;
patternToRemove.remove();
// Note after removing Illustrator objects, set the variable that
// referenced the removed object to null, since it is now invalid.
patternToRemove = null;
}