Skip to content

CompoundPathItem

app.activeDocument.activeLayer.compoundPathItems[index]

A compound path. These objects are composed of multiple intersecting paths, resulting in transparent interior spaces where the component paths overlap. The pathItems property provides access to the paths that make up the compound path.

Paths contained within a compound path or group in a document are returned as individual paths when a script asks for the paths contained in the document. However, paths contained in a compound path or group are not returned when a script asks for the paths in a layer that contains the compound path or group.

All paths within a compound path share property values. Therefore, if you set the value of a property of any one of the paths in the compound path, the properties of all other component paths are updated with the new value.


app.activeDocument.activeLayer.compoundPathItems[index].artworkKnockout

Is this object used to create a knockout, and if so, what kind of knockout.

KnockoutState


app.activeDocument.activeLayer.compoundPathItems[index].blendingMode

The mode used when compositing an object.

BlendModes


app.activeDocument.activeLayer.compoundPathItems[index].controlBounds

The bounds of the object including stroke width and controls.

Array of 4 numbers; read-only.


app.activeDocument.activeLayer.compoundPathItems[index].editable

If true, this item is editable.

Boolean; read-only.


app.activeDocument.activeLayer.compoundPathItems[index].geometricBounds

The bounds of the object excluding stroke width.

Array of 4 numbers; read-only.


app.activeDocument.activeLayer.compoundPathItems[index].height

The height of the compound path item excluding stroke width.

Number (double).


app.activeDocument.activeLayer.compoundPathItems[index].hidden

If true, this compound path item is hidden.

Boolean.


app.activeDocument.activeLayer.compoundPathItems[index].isIsolated

If true, this object is isolated.

Boolean.


app.activeDocument.activeLayer.compoundPathItems[index].layer

The layer to which this compound path item belongs.

Layer; read-only.


app.activeDocument.activeLayer.compoundPathItems[index].left

The position of the left side of the item (in points, measured from the left side of the page).

Number (double).


app.activeDocument.activeLayer.compoundPathItems[index].locked

If true, this compound path item is locked.

Boolean.


app.activeDocument.activeLayer.compoundPathItems[index].name

The name of this compound path item.

String.


app.activeDocument.activeLayer.compoundPathItems[index].note

The note assigned to this item.

String.


app.activeDocument.activeLayer.compoundPathItems[index].opacity

The opacity of the object.

Range: 0.0 to 100.0

Number (double).


app.activeDocument.activeLayer.compoundPathItems[index].parent

The parent of this object.

Layer or GroupItem; read-only.


app.activeDocument.activeLayer.compoundPathItems[index].pathItems

The path art items in this compound path.

PathItems; read-only.


app.activeDocument.activeLayer.compoundPathItems[index].position

The position (in points) of the top left corner of the compoundPathItem object in the format [x, y]. Does not include stroke weight.

Array of 2 numbers.


app.activeDocument.activeLayer.compoundPathItems[index].selected

If true, this compound path item is selected.

Boolean.


app.activeDocument.activeLayer.compoundPathItems[index].sliced

If true, the item is sliced.

Default: false

Boolean.


app.activeDocument.activeLayer.compoundPathItems[index].tags

The tags contained in this object.

Tags; read-only.


app.activeDocument.activeLayer.compoundPathItems[index].top

The position of the top of the item (in points, measured from the bottom of the page).

Number (double).


app.activeDocument.activeLayer.compoundPathItems[index].typename

The class name of the referenced object.

String; read-only.


app.activeDocument.activeLayer.compoundPathItems[index].uRL

The value of the Adobe URL tag assigned to this compound path item.

String.


app.activeDocument.activeLayer.compoundPathItems[index].visibilityVariable

The visibility variable bound to the item.

Variant.


app.activeDocument.activeLayer.compoundPathItems[index].visibleBounds

The visible bounds of the compound path item including stroke width.

Array of 4 numbers; read-only.


app.activeDocument.activeLayer.compoundPathItems[index].width

The width of the compound path item excluding stroke width.

Number (double).


app.activeDocument.activeLayer.compoundPathItems[index].wrapInside

If true, the text frame object should be wrapped inside this object.

Boolean.


app.activeDocument.activeLayer.compoundPathItems[index].wrapOffset

The offset to use when wrapping text around this object.

Number (double).


app.activeDocument.activeLayer.compoundPathItems[index].wrapped

If true, wrap text frame objects around this object (text frame must be above the object).

Boolean.


app.activeDocument.activeLayer.compoundPathItems[index].zOrderPosition

The position of this art item within the stacking order of the group or layer (Parent) that contains the art item.

Number (long); read-only.


app.activeDocument.activeLayer.compoundPathItems[index].duplicate([relativeObject][,insertionLocation])

Creates a duplicate of the selected object.

ParameterTypeDescription
relativeObjectObject, optionalObject to duplicate to
insertionLocationElementPlacement, optionalLocation to insert element

CompoundPathItem


app.activeDocument.activeLayer.compoundPathItems[index].move(relativeObject, insertionLocation)

Moves the object.

ParameterTypeDescription
relativeObjectObjectObject to move element within
insertionLocationElementPlacement, optionalLocation to move element to

Nothing.


app.activeDocument.activeLayer.compoundPathItems[index].remove()

Deletes this object.

Nothing.


app.activeDocument.activeLayer.compoundPathItems[index].resize(
scaleX,
scaleY
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,changeLineWidths]
[,scaleAbout]
)

Scales the art item where scaleX is the horizontal scaling factor and scaleY is the vertical scaling factor. 100.0 = 100%.

ParameterTypeDescription
scaleXNumber (double)Horizontal scaling factor
scaleYNumber (double)Vertical scaling factor
changePositionsBoolean, optionalWhether to effect art object positions and orientations
changeFillPatternsBoolean, optionalWhether to transform fill patterns
changeFillGradientsBoolean, optionalWhether to transform fill gradients
changeStrokePatternBoolean, optionalWhether to transform stroke patterns
changeLineWidthsNumber (double), optionalThe amount to scale line widths
scaleAboutTransformation, optionalThe point to use as anchor, to transform about

Nothing.


app.activeDocument.activeLayer.compoundPathItems[index].rotate(
angle
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,rotateAbout]
)

Rotates the art item relative to the current rotation. The object is rotated counter-clockwise if the angle value is positive, clockwise if the value is negative.

ParameterTypeDescription
angleNumber (double)The angle amount to rotate the element
changePositionsBoolean, optionalWhether to effect art object positions and orientations
changeFillPatternsBoolean, optionalWhether to transform fill patterns
changeFillGradientsBoolean, optionalWhether to transform fill gradients
changeStrokePatternBoolean, optionalWhether to transform stroke patterns
rotateAboutTransformation, optionalThe point to use as anchor, to transform about

Nothing.


app.activeDocument.activeLayer.compoundPathItems[index].transform(
transformationMatrix
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,changeLineWidths]
[,transformAbout]
)

Transforms the art item by applying a transformation matrix.

ParameterTypeDescription
transformationMatrixMatrixTransformation matrix to apply
changePositionsBoolean, optionalWhether to change Positions
changeFillPatternsBoolean, optionalWhether to change Fill Patterns
changeFillGradientsBoolean, optionalWhether to change Fill Gradients
changeStrokePatternBoolean, optionalWhether to change Stroke Pattern
changeLineWidthsNumber (double), optionalThe amount to scale line widths
transformAboutTransformation, optionalThe point to use as anchor, to transform about

Nothing.


app.activeDocument.activeLayer.compoundPathItems[index].translate(
deltaX
[,deltaY]
[,transformObjects]
[,transformFillPatterns]
[,transformFillGradients]
[,transformStrokePatterns]
)

Repositions the art item relative to the current position, where deltaX is the horizontal offset and deltaY is the vertical offset.

ParameterTypeDescription
deltaXNumber (double), optionalHorizontal offset
deltaYNumber (double), optionalVertical offset
transformObjectsBoolean, optionalWhether to transform Objects
transformFillPatternsBoolean, optionalWhether to transform Fill Patterns
transformFillGradientsBoolean, optionalWhether to transform Fill Gradients
transformStrokePatternsBoolean, optionalWhether to transform Stroke Patterns

Nothing.


app.activeDocument.activeLayer.compoundPathItems[index].zOrder(zOrderCmd)

Arranges the art item’s position in the stacking order of the group or layer (parent) of this object.

ParameterTypeDescription
zOrderCmdZOrderMethodStacking order arrangement method

Nothing.


// Selects all paths not part of a compound path
if ( app.documents.length > 0 ) {
var doc = app.activeDocument;
var count = 0;
if ( doc.pathItems.length > 0 ) {
var thePaths = doc.pathItems;
var numPaths = thePaths.length;
for ( var i = 0; i < doc.pathItems.length; i++ ) {
var pathArt = doc.pathItems[i];
if ( pathArt.parent.typename != "compoundPathItem" ) {
pathArt.selected = true;
count++;
}
}
}

Creating and modifying a compound path item

Section titled “Creating and modifying a compound path item”
// Creates a new compound path item containing 3 path
// items, then sets the width and the color of the stroke
// to all items in the compound path
if (app.documents.length > 0) {
var doc = app.activeDocument;
var newCompoundPath = doc.activeLayer.compoundPathItems.add();
// Create the path items
var newPath = newCompoundPath.pathItems.add();
newPath.setEntirePath(Array(Array(30, 50), Array(30, 100)));
newPath = newCompoundPath.pathItems.add();
newPath.setEntirePath(Array(Array(40, 100), Array(100, 100)));
newPath = newCompoundPath.pathItems.add();
newPath.setEntirePath(Array(Array(100, 110), Array(100, 300)));
// Set stroke and width properties of the compound path
newPath.stroked = true;
newPath.strokeWidth = 3.5;
newPath.strokeColor = app.activeDocument.swatches[3].color;
}