PathItems¶
app.activeDocument.pathItems
Description
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.
Properties¶
PathItems.length¶
app.activeDocument.pathItems.length
Description
Number of elements in the collection.
Type
Number, read-only.
PathItems.parent¶
app.activeDocument.pathItems.parent
Description
The object’s container.
Type
Object, read-only.
PathItems.typename¶
app.activeDocument.pathItems.typename
Description
The class name of the object.
Type
String, read-only.
Methods¶
PathItems.add()¶
app.activeDocument.pathItems.add()
Description
Creates a new object.
Returns
PathItems.ellipse()¶
app.activeDocument.pathItems.ellipse([top][, left][, width][, height][, reversed][, inscribed])
Description
Creates a new pathItem in the shape of an ellipse using the supplied parameters.
Defaults
Parameter |
Value |
---|---|
|
100 pt. |
|
100 pt. |
|
50 pt. |
|
100 pt. |
|
false |
Parameters
Parameter |
Type |
Description |
---|---|---|
|
Number (double), optional |
Top of path |
|
Number (double), optional |
Left of path |
|
Number (double), optional |
Width of path |
|
Number (double), optional |
Height of path |
|
Boolean, optional |
Whether path is reversed |
|
Boolean, optional |
Whether path is inscribed |
Returns
PathItems.getByName()¶
app.activeDocument.pathItems.getByName(name)
Description
Gets the first element in the collection with the specified name.
Parameters
Parameter |
Type |
Description |
---|---|---|
|
String |
Name of element to get |
Returns
PathItems.index()¶
app.activeDocument.pathItems.index(itemKey)
Description
Gets an element from the collection.
Parameters
Parameter |
Type |
Description |
---|---|---|
|
String, Number |
String or number key |
Returns
PathItems.polygon()¶
app.activeDocument.pathItems.polygon([centerX][, centerY][, radius][, sides][, reversed])
Description
Creates a new pathItem
in the shape of an polygon using the supplied parameters.
Defaults
Parameter |
Value |
---|---|
|
200 pt. |
|
300 pt. |
|
50 pt. |
|
8 |
|
false |
Parameters
Parameter |
Type |
Description |
---|---|---|
|
Number (double), optional |
CenterX of path |
|
Number (double), optional |
CenterY of path |
|
Number (double), optional |
Radius of path |
|
Number (long), optional |
Number of sides |
|
Boolean, optional |
Whether path is reversed |
Returns
PathItems.rectangle()¶
app.activeDocument.pathItems.rectangle(top, left, width, height[,reversed])
Description
Creates a new pathItem
in the shape of an polygon using the supplied parameters.
Parameters
Parameter |
Type |
Description |
---|---|---|
|
Number (double) |
Top of path |
|
Number (double) |
Left of path |
|
Number (double) |
Width of path |
|
Number (double) |
Height of path |
|
Boolean, optional |
Whether path is reversed |
Returns
PathItems.removeAll()¶
app.activeDocument.pathItems.removeAll()
Description
Deletes all elements in this collection.
Returns
Nothing
PathItems.roundedRectangle()¶
app.activeDocument.pathItems.roundedRectangle(top, left, width, height[, horizontalRadius][, verticalRadius][, reversed])
Description
Creates a new pathItem in the shape of a rectangle with rounded corners using the supplied parameters.
Defaults
Parameter |
Value |
---|---|
|
15 pt. |
|
20 pt. |
|
false |
Parameters
Parameter |
Type |
Description |
---|---|---|
|
Number (double) |
Top of path |
|
Number (double) |
Left of path |
|
Number (double) |
Width of path |
|
Number (double) |
Height of path |
|
Number (double), optional |
Horizontal radius of rounded corner |
|
Number (double), optional |
Vertical radius of rounded corner |
|
Boolean, optional |
Whether path is reversed |
Returns
PathItems.star()¶
app.activeDocument.pathItems.star([centerX][, centerY][, radius][, innerRadius][, points][, reversed])
Description
Creates a new path item in the shape of a star using the supplied parameters.
Defaults
Parameter |
Value |
---|---|
|
200 pt. |
|
300 pt. |
|
50 pt. |
|
20 pt. |
|
5 |
|
false |
Parameters
Parameter |
Type |
Description |
---|---|---|
|
Number (double), optional |
CenterX of path |
|
Number (double), optional |
CenterY of path |
|
Number (double), optional |
Radius of path |
|
Number (double), optional |
Inner radius of path |
|
Number (long), optional |
Number of points |
|
Boolean, optional |
Whether path is reversed |
Returns
Example¶
Creating shapes¶
// 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]);
}