Skip to content

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.


thisComp.activeCamera

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.

Camera


thisComp.bgColor

Returns the background color of the composition.

Array (4-dimensional)


thisComp.displayStartTime

Returns the composition start time, in seconds.

Number


thisComp.duration

Returns the composition duration, in seconds.

Number


thisComp.frameDuration

Returns the duration of a frame, in seconds.

Number


thisComp.height

Returns the composition height, in pixels.

Number


thisComp.marker

Returns a given composition’s Marker property.

Marker Property


thisComp.name

Returns the name of the composition.

String


thisComp.ntscDropFrame

Returns true if the timecode is in drop-frame format.

Boolean


thisComp.numLayers

Returns the number of layers in the composition.

Number


thisComp.pixelAspect

Returns the pixel aspect ratio of the composition.

Number


thisComp.shutterAngle

Returns the shutter-angle value of the composition, in degrees.

Number


thisComp.shutterPhase

Returns the shutter phase of the composition, in degrees.

Number


thisComp.width

Returns the composition width, in pixels.

Number

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];

thisComp.layer(index)

thisComp.layer(name)

thisComp.layer(otherLayer, relIndex)

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.

ParameterTypeDescription
indexNumberLayer name or index to get.
nameString
otherLayerLayerThe “other” layer to start getting layers relative to
relIndexNumberThe number of layers to move above or below the otherLayer

Layer, Light, or Camera object

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;

thisComp.layerByComment(comment)

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.

ParameterTypeDescription
commentStringThe comment to find a layer from

Layer, Light, or Camera object

// note this will match a layer with a comment "Controller" or "Motion Control"
thisComp.layerByComment("Control");