Swatches
Swatches
Section titled “Swatches”app.activeDocument.swatches
Description
Section titled “Description”The collection of Swatch objects in the document.
Properties
Section titled “Properties”Swatches.length
Section titled “Swatches.length”app.activeDocument.swatches.length
Description
Section titled “Description”Number of elements in the collection.
Number; read-only.
Swatches.parent
Section titled “Swatches.parent”app.activeDocument.swatches.parent
Description
Section titled “Description”The object’s container.
Object; read-only.
Swatches.typename
Section titled “Swatches.typename”app.activeDocument.swatches.typename
Description
Section titled “Description”The class name of the object.
String; read-only.
Methods
Section titled “Methods”Swatches.add()
Section titled “Swatches.add()”app.activeDocument.swatches.add()
Description
Section titled “Description”Creates a new Swatch object.
Returns
Section titled “Returns”Swatches.getByName()
Section titled “Swatches.getByName()”app.activeDocument.swatches.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”Swatches.getSelected()
Section titled “Swatches.getSelected()”app.activeDocument.swatches.getSelected()
Description
Section titled “Description”Gets selected swatches in the document.
Returns
Section titled “Returns”List of Swatch
Swatches.index()
Section titled “Swatches.index()”app.activeDocument.swatches.index(itemKey)
Description
Section titled “Description”Gets an element from the collection.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
itemKey | String, Number | Key of element to get |
Returns
Section titled “Returns”Swatches.removeAll()
Section titled “Swatches.removeAll()”app.activeDocument.swatches.removeAll()
Description
Section titled “Description”Deletes all elements in the collection.
Returns
Section titled “Returns”Nothing.
Example
Section titled “Example”Finding and deleting a swatch
Section titled “Finding and deleting a swatch”// Deletes swatch 4 from the current documentif ( app.documents.length > 0 ) { if (app.activeDocument.swatches.length > 4) { var swatchToDelete = app.activeDocument.swatches[3]; swatchToDelete.remove(); }}