Patterns
Patterns
Section titled “Patterns”app.activeDocument.patterns
Description
Section titled “Description”A collection of Pattern objects in a document.
Properties
Section titled “Properties”Patterns.length
Section titled “Patterns.length”app.activeDocument.patterns.length
Description
Section titled “Description”Number of elements in the collection.
Number; read-only.
Patterns.parent
Section titled “Patterns.parent”app.activeDocument.patterns.parent
Description
Section titled “Description”The object’s container.
Object; read-only.
Patterns.typename
Section titled “Patterns.typename”app.activeDocument.patterns.typename
Description
Section titled “Description”The class name of the object.
String; read-only.
Methods
Section titled “Methods”Patterns.add()
Section titled “Patterns.add()”app.activeDocument.patterns.add()
Description
Section titled “Description”Creates a new object.
Returns
Section titled “Returns”Patterns.getByName()
Section titled “Patterns.getByName()”app.activeDocument.patterns.getByName(name)
Description
Section titled “Description”Get the first element in the collection with the provided name.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
name | String | Name of element to get |
Returns
Section titled “Returns”Patterns.index()
Section titled “Patterns.index()”app.activeDocument.patterns.index(itemKey)
Description
Section titled “Description”Gets an element from the collection.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
itemKey | String, Number | String or number key |
Returns
Section titled “Returns”Patterns.removeAll()
Section titled “Patterns.removeAll()”app.activeDocument.patterns.removeAll()
Description
Section titled “Description”Deletes all elements in the collection.
Returns
Section titled “Returns”Nothing.
Example
Section titled “Example”Removing a pattern
Section titled “Removing a pattern”// 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;}