Skip to content

sub-objects

Layer Sub-objects

thisLayer

This category describes items that give you other objects based on the current layer; things like the source (for precomps or footage), effects, masks, sourceRect, etc.

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.


Attributes

Layer.source

thisLayer.source

Description

Returns the source Comp or Footage object for the layer.

Default time is adjusted to the time in the source.

Example:

source.layer(1).position

Type

Comp or Footage


Methods

Layer.effect()

thisLayer.effect(name)

thisLayer.effect(index)

Description

The name value will have After Effects find the effect by its name in the Effect Controls panel. The name can be the default name or a user-defined name. If multiple effects have the same name, the effect closest to the top of the Effect Controls panel is used.

The index value will have After Effects finds the effect by its index in the Effect Controls panel, starting at 1 and counting from the top.

Parameters

ParameterTypeDescription
nameStringEffect name or index to get.
indexNumber

Returns

Effect

Example

Get the “Blurriness” effect by name:

thisLayer.effect("Fast Blur")

Get the first effect on the layer:

thisLayer.effect(1)

Layer.mask()

thisLayer.mask(name)

thisLayer.mask(index)

Description

The name value can be the default name or a user-defined name. If multiple masks have the same name, the first (topmost) mask is used.

The index value will have After Effects finds the mask by its index in the Timeline panel, starting at 1 and counting from the top.

Parameters

ParameterTypeDescription
nameStringEffect name or index to get.
indexNumber

Returns

Effect

Example

Get the mask “Mask 1” by name:

thisLayer.mask("Mask 1")

Get the first mask on the layer:

thisLayer.mask(1)

Layer.sourceRectAtTime()

thisLayer.sourceRectAtTime(t = time, includeExtents = false)

Description

Returns the bounding box of the layer (or the layer’s source).

Parameters

ParameterTypeDescription
tNumberOptional. The specified time (in comp seconds) to apply the smoothing filter to. Defaults to time (the current comp time, in seconds).
includeExtentsBooleanOptional. Only applies to shape layers and paragraph text layers. Defaults to false.
- For shape layers: Increases the size of the layer bounds as necessary.
- For paragraph text layers: Returns the bounds of the paragraph box

Returns

An object with four attributes: {top, left, width, height}

Example

myTextLayer.sourceRectAtTime().width

Layer.sourceTime()

thisLayer.sourceTime([t=time])

Description

Returns the layer source corresponding to time t.

Parameters

ParameterTypeDescription
tNumberOptional. The specified time (in comp seconds) to apply the smoothing filter to. Defaults to time (the current comp time, in seconds).

Returns

Number