Skip to content

Spots

app.activeDocument.spots

A collection of SpotColor objects in a document.


app.activeDocument.spots.length

Number of elements in the collection.

Number; read-only.


app.activeDocument.spots.parent

The object’s container.

Object; read-only.


app.activeDocument.spots.typename

The class name of the object.

String; read-only.


app.activeDocument.spots.add()

Creates a new object.

Spot


app.activeDocument.spots.getByName(name)

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

ParameterTypeDescription
nameStringName of element to get

Spot


app.activeDocument.spots.index(itemKey)

Gets an element from the collection.

ParameterTypeDescription
itemKeyString, NumberKey of element to get

Spot


app.activeDocument.spots.removeAll()

Deletes all elements in the collection.

Nothing.


// Deletes all spots colors from the current document
if ( app.documents.length > 0 ) {
var spotCount = app.activeDocument.spots.length;
if (spotCount > 0) {
app.activeDocument.spots.removeAll();
}
}

// Defines and applies a new spot color in the current document,
// then applies the color to the first path item
if (app.documents.length > 0 && app.activeDocument.pathItems.length > 0) {
// Define the new color value
var newRGBColor = new RGBColor();
newRGBColor.red = 255;
newRGBColor.green = 0;
newRGBColor.blue = 0;
// Create the new spot
var newSpot = app.activeDocument.spots.add();
// Define the new SpotColor as 80% of the RGB color
newSpot.name = "Scripted Red spot";
newSpot.tint = 80;
newSpot.color = newRGBColor;
// Apply a 50% tint of the new spot color to the frontmost path item.
// Create a spotcolor object, set the tint value,
var newSpotColor = new SpotColor();
newSpotColor.spot = newSpot;
newSpotColor.tint = 50;
// Use the spot color to set the fill color
var frontPath = app.activeDocument.pathItems[0];
frontPath.filled = true;
frontPath.fillColor = newSpotColor;
}