Skip to content

PathItems

app.activeDocument.pathItems

A collection of PathItem objects.

The methods ellipse, polygon, rectangle, roundedRectangle, and star allow you to create complex path items using straightforward parameters.

If you do not provide any parameters when calling these methods, default values are used.


app.activeDocument.pathItems.length

Number of elements in the collection.

Number; read-only.


app.activeDocument.pathItems.parent

The object’s container.

Object; read-only.


app.activeDocument.pathItems.typename

The class name of the object.

String; read-only.


app.activeDocument.pathItems.add()

Creates a new object.

PathItem


app.activeDocument.pathItems.ellipse(
[top = 100]
[, left = 100]
[, width = 50]
[, height = 100]
[, reversed = false]
[, inscribed]
)

Creates a new pathItem in the shape of an ellipse using the supplied parameters.

ParameterTypeDescription
topNumber (double), optionalTop of path. Defaults to 100 pt.
leftNumber (double), optionalLeft of path. Defaults to 100 pt.
widthNumber (double), optionalWidth of path. Defaults to 50 pt.
heightNumber (double), optionalHeight of path. Defaults to 100 pt.
reversedBoolean, optionalWhether path is reversed. Defaults to false
inscribedBoolean, optionalWhether path is inscribed

PathItem


app.activeDocument.pathItems.getByName(name)

Gets the first element in the collection with the specified name.

ParameterTypeDescription
nameStringName of element to get

PathItem


app.activeDocument.pathItems.index(itemKey)

Gets an element from the collection.

ParameterTypeDescription
itemKeyString, NumberString or number key

PathItem


app.activeDocument.pathItems.polygon(
[centerX = 200]
[, centerY = 300]
[, radius = 50]
[, sides = 8]
[, reversed = false]
)

Creates a new pathItem in the shape of an polygon using the supplied parameters.

ParameterTypeDescription
centerXNumber (double), optionalCenterX of path. Defaults to 200 pt.
centerYNumber (double), optionalCenterY of path. Defaults to 300 pt.
radiusNumber (double), optionalRadius of path. Defaults to 50 pt.
sidesNumber (long), optionalNumber of sides. Defaults to 8
reversedBoolean, optionalWhether path is reversed. Defaults to false

PathItem


app.activeDocument.pathItems.rectangle(top, left, width, height[,reversed])

Creates a new pathItem in the shape of an polygon using the supplied parameters.

ParameterTypeDescription
topNumber (double)Top of path
leftNumber (double)Left of path
widthNumber (double)Width of path
heightNumber (double)Height of path
reversedBoolean, optionalWhether path is reversed

PathItem


app.activeDocument.pathItems.removeAll()

Deletes all elements in this collection.

Nothing


app.activeDocument.pathItems.roundedRectangle(
top,
left,
width,
height
[,horizontalRadius = 15]
[,verticalRadius = 20]
[,reversed = false]
)

Creates a new pathItem in the shape of a rectangle with rounded corners using the supplied parameters.

ParameterTypeDescription
topNumber (double)Top of path
leftNumber (double)Left of path
widthNumber (double)Width of path
heightNumber (double)Height of path
horizontalRadiusNumber (double), optionalHorizontal radius of rounded corner. Defaults to 15 pt.
verticalRadiusNumber (double), optionalVertical radius of rounded corner. Defaults to 20 pt.
reversedBoolean, optionalWhether path is reversed. Defaults to false

PathItem


app.activeDocument.pathItems.star(
[centerX = 200]
[, centerY = 300]
[, radius = 50]
[, innerRadius = 20]
[, points = 5]
[, reversed = false]
)

Creates a new path item in the shape of a star using the supplied parameters.

ParameterTypeDescription
centerXNumber (double), optionalCenterX of path. Defaults to 200 pt.
centerYNumber (double), optionalCenterY of path. Defaults to 300 pt.
radiusNumber (double), optionalRadius of path. Defaults to 50 pt.
innerRadiusNumber (double), optionalInner radius of path. Defaults to 20 pt.
pointsNumber (long), optionalNumber of points. Defaults to 5
reversedBoolean, optionalWhether path is reversed. Defaults to false

PathItem


// Creates 5 shapes in layer 1 of document 1
// and applies a random graphic style to each
var doc = app.documents.add();
var artLayer = doc.layers[0];
app.defaultStroked = true;
app.defaultFilled = true;
var rect = artLayer.pathItems.rectangle(762.5, 87.5, 425.0, 75.0);
var rndRect = artLayer.pathItems.roundedRectangle(637.5, 87.5, 425.0, 75.0, 20.0, 10.0);
// Create ellipse, 'reversed' is false, 'inscribed' is true
var ellipse = artLayer.pathItems.ellipse(512.5, 87.5, 425.0, 75.0, false, true);
// Create octagon, and 8-sided polygon
var octagon = artLayer.pathItems.polygon(300.0, 325.0, 75.0, 8);
// Create a 4 pointed star
var star = artLayer.pathItems.star(300.0, 125.0, 100.0, 20.0, 4);
for (i = 0; i < artLayer.pathItems.length; i++) {
var styleIndex = Math.round(Math.random() * (doc.graphicStyles.length - 1));
doc.graphicStyles[styleIndex].applyTo(artLayer.pathItems[i]);
}