Skip to content

general

thisLayer

On this page, we’re going to use thisLayer as a sample on how to call these items, however note that any method that returns a Layer will work.


thisLayer.active

Returns true if the Video switch is on for the layer and the current time is in the range from the In point of the layer to the Out point of the layer; false otherwise.

Boolean


thisLayer.audioActive

Returns true if the Audio switch is on for the layer and the current time is in the range from the In point of the layer to the Out point of the layer; false otherwise.

Boolean


thisLayer.enabled

Whether the layer is enabled.

Boolean. true if the Video switch is on for the layer; false otherwise.


thisLayer.hasAudio

Whether the layer has audio.

Boolean. true if the layer has audio or false if it doesn’t.


thisLayer.hasParent

Use the hasParent attribute to determine if a layer has a parent layer. You can use this attribute even if the layer has no parent layer at present.

Boolean. true if the layer has a parent, false if it doesn’t.

The following expression indicates that the layer to which you apply it wiggles based on the position of the parent. If the layer has no parent, then it wiggles based on its own position.

If the layer is given a parent later, then the behavior of the layer changes accordingly:

idx = index;
if (hasParent) {
idx = parent.index;
}
thisComp.layer(idx).position.wiggle(5,20)

thisLayer.hasVideo

Whether the layer has video.

Boolean. true if the layer has audio or false if it doesn’t.


thisLayer.height

Returns the height of the layer, in pixels.

If the layer has a source, this is the same as either the source comp height or the source footage height (as applicable).

Number


thisLayer.index

Returns the index number of the layer in the composition.

Number


thisLayer.inPoint

Returns the In point of the layer, in seconds.

Number


thisLayer.outPoint

Returns the Out point of the layer, in seconds.

Number


thisLayer.parent

Returns the parent Layer object of the layer, if it has one.

You can check whether a layer has a parent with the Layer.hasParent attribute.

Layer, Light, or Camera object

position[0] + parent.width

thisLayer.startTime

Returns the start time of the layer, in seconds.

Number


thisLayer.width

Returns the width of the layer, in pixels.

If the layer has a source, this is the same as either the source comp width or the source footage width (as applicable).

Number


thisLayer.sampleImage(point[, radius=[0.5, 0.5]][, postEffect=true][, t=time])

Samples the color and alpha channel values of a layer and returns the average alpha-weighted value of the pixels within the specified distance of the point as an array: [red, green, blue, alpha].

ParameterTypeDescription
point2-dimensional Number arrayRequired. The point at which to sample, im layer space. The point [0, 0] is the center of the upper-left pixel in the layer.
radius2-dimensional Number arrayOptional. Specifies the horizontal and vertical distance from the sample center to the edges of the sampled rectangle. The default value samples one pixel. Defaults to [0.5, 0.5].
postEffectBooleanOptional. If true, to sample the values after layer masks and effects directly applied to the layer have been rendered. If false, sample values before layer masks and effects. Defaults to true.
tNumberOptional. Defaults to time.

Array (4-dimensional)

This samples a rectangle 4 pixels wide and 3 pixels high, centered around a point 100 pixels down and to the right of the upper-left corner of the layer:

thisComp.layer(1).sampleImage([100, 100], [2, 1.5])