sub-objects
Layer Sub-objects
Section titled “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
Section titled “Attributes”Layer.source
Section titled “Layer.source”thisLayer.source
Description
Section titled “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
Methods
Section titled “Methods”Layer.effect()
Section titled “Layer.effect()”thisLayer.effect(name)
thisLayer.effect(index)
Description
Section titled “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
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
name | String | Effect name or index to get. |
index | Number |
Returns
Section titled “Returns”Example
Section titled “Example”Get the “Blurriness” effect by name:
thisLayer.effect("Fast Blur")
Get the first effect on the layer:
thisLayer.effect(1)
Layer.mask()
Section titled “Layer.mask()”thisLayer.mask(name)
thisLayer.mask(index)
Description
Section titled “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
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
name | String | Effect name or index to get. |
index | Number |
Returns
Section titled “Returns”Example
Section titled “Example”Get the mask “Mask 1” by name:
thisLayer.mask("Mask 1")
Get the first mask on the layer:
thisLayer.mask(1)
Layer.sourceRectAtTime()
Section titled “Layer.sourceRectAtTime()”thisLayer.sourceRectAtTime(t = time, includeExtents = false)
Description
Section titled “Description”Returns the bounding box of the layer (or the layer’s source).
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
t | Number | Optional. The specified time (in comp seconds) to apply the smoothing filter to. Defaults to time (the current comp time, in seconds). |
includeExtents | Boolean | Optional. 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
Section titled “Returns”An object with four attributes: {top, left, width, height}
Example
Section titled “Example”myTextLayer.sourceRectAtTime().width
Layer.sourceTime()
Section titled “Layer.sourceTime()”thisLayer.sourceTime([t=time])
Description
Section titled “Description”Returns the layer source corresponding to time t
.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
t | Number | Optional. The specified time (in comp seconds) to apply the smoothing filter to. Defaults to time (the current comp time, in seconds). |
Returns
Section titled “Returns”Number