comp
thisComp
comp("CompName")
layer("layerName").source
These attributes and methods can be called on Comp objects.
These are typically accessed in a few ways, most commonly:
thisComp
to get the Comp object of the active comp the expression is written in,comp("CompName")
to get a specific comp by name,layer("layerName").source
, if referring to a precomp layer, to get the targeted precomp layer’s source comp
On this page, we’re going to use thisComp
as a sample on how to call these items, however note that any method that returns a Comp will work.
Attributes
Section titled “Attributes”Comp.activeCamera
Section titled “Comp.activeCamera”thisComp.activeCamera
Description
Section titled “Description”Returns the Camera object for the camera through which the composition is rendered at the current frame.
This camera is not necessarily the camera through which you are looking in the Composition panel.
Comp.bgColor
Section titled “Comp.bgColor”thisComp.bgColor
Description
Section titled “Description”Returns the background color of the composition.
Array (4-dimensional)
Comp.displayStartTime
Section titled “Comp.displayStartTime”thisComp.displayStartTime
Description
Section titled “Description”Returns the composition start time, in seconds.
Number
Comp.duration
Section titled “Comp.duration”thisComp.duration
Description
Section titled “Description”Returns the composition duration, in seconds.
Number
Comp.frameDuration
Section titled “Comp.frameDuration”thisComp.frameDuration
Description
Section titled “Description”Returns the duration of a frame, in seconds.
Number
Comp.height
Section titled “Comp.height”thisComp.height
Description
Section titled “Description”Returns the composition height, in pixels.
Number
Comp.marker
Section titled “Comp.marker”thisComp.marker
Description
Section titled “Description”Returns a given composition’s Marker property.
Comp.name
Section titled “Comp.name”thisComp.name
Description
Section titled “Description”Returns the name of the composition.
String
Comp.ntscDropFrame
Section titled “Comp.ntscDropFrame”thisComp.ntscDropFrame
Description
Section titled “Description”Returns true
if the timecode is in drop-frame format.
Boolean
Comp.numLayers
Section titled “Comp.numLayers”thisComp.numLayers
Description
Section titled “Description”Returns the number of layers in the composition.
Number
Comp.pixelAspect
Section titled “Comp.pixelAspect”thisComp.pixelAspect
Description
Section titled “Description”Returns the pixel aspect ratio of the composition.
Number
Comp.shutterAngle
Section titled “Comp.shutterAngle”thisComp.shutterAngle
Description
Section titled “Description”Returns the shutter-angle value of the composition, in degrees.
Number
Comp.shutterPhase
Section titled “Comp.shutterPhase”thisComp.shutterPhase
Description
Section titled “Description”Returns the shutter phase of the composition, in degrees.
Number
Comp.width
Section titled “Comp.width”thisComp.width
Description
Section titled “Description”Returns the composition width, in pixels.
Number
Example
Section titled “Example”Apply the following expression to the Position property of a layer to center the layer in the composition frame:
[thisComp.width / 2, thisComp.height / 2];
Methods
Section titled “Methods”Comp.layer()
Section titled “Comp.layer()”thisComp.layer(index)
thisComp.layer(name)
thisComp.layer(otherLayer, relIndex)
Description
Section titled “Description”Return the Layer object with the specified index
or name
.
The index
value refers to the layer order in the Timeline panel.
The name
value refers to the user-specified layer name, or the layer source name if there is no layer name.
If duplicate names exist, After Effects uses the first (topmost) one in the Timeline panel.
If using the otherLayer, relIndex
call, this retrieves the layer that is relIndex
layers above or below otherLayer
.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
index | Number | Layer name or index to get. |
name | String | |
otherLayer | Layer | The “other” layer to start getting layers relative to |
relIndex | Number | The number of layers to move above or below the otherLayer |
Returns
Section titled “Returns”Layer, Light, or Camera object
Example
Section titled “Example”Get the 3rd layer in the current comp:
thisComp.layer(3)
Get the layer named “Solid 1” from the current comp:
thisComp.layer("Solid 1")
Check whether the next layer down in the Timeline panel is active:
const nextLayer = thisComp.layer(thisLayer, 1);nextLayer.active;
Comp.layerByComment()
Section titled “Comp.layerByComment()”thisComp.layerByComment(comment)
Description
Section titled “Description”Retrieves a layer by matching the comment parameter to the value in the layer’s Comment column.
The matches are simple text matches. They will match partial words, and are case sensitive. Matching does not appear to use regular expressions or wildcards. If duplicate comments exist, After Effects uses the first (topmost) one in the Timeline panel.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
comment | String | The comment to find a layer from |
Returns
Section titled “Returns”Layer, Light, or Camera object
Example
Section titled “Example”// note this will match a layer with a comment "Controller" or "Motion Control"thisComp.layerByComment("Control");