Skip to content

avlayer

app.project.item(index).layer(index)

The AVLayer object provides an interface to those layers that contain AVItem objects (composition layers, footage layers, solid layers, text layers, and sound layers).

AVLayer is a subclass of Layer object. All methods and attributes of Layer, in addition to those listed below, are available when working with AVLayer.

AVLayer is a base class for TextLayer object, so AVLayer attributes and methods are available when working with TextLayer objects.

Different types of layers have different AE properties. AVLayer has the following properties and property groups:

  • Marker
  • Time Remap
  • Motion Trackers
  • Masks
  • Effects
  • Transform
  • Anchor Point
  • Position
  • Scale
  • Orientation
  • X Rotation
  • Y Rotation
  • Rotation
  • Opacity
  • Layer Styles
  • Geometry Options // Ray-traced 3D
  • Material Options
  • Casts Shadows
  • Light Transmission
  • Accepts Shadows
  • Accepts Lights
  • Appears in Reflections // Ray-traced 3D
  • Ambient
  • Diffuse
  • Specular Intensity
  • Specular Shininess
  • Metal
  • Reflection Intensity // Ray-traced 3D
  • Reflection Sharpness // Ray-traced 3D
  • Reflection Rolloff // Ray-traced 3D
  • Transparency // Ray-traced 3D
  • Transparency Rolloff // Ray-traced 3D
  • Index of Refraction // Ray-traced 3D
  • Audio
  • AudioLevels

If the first item in the project is a CompItem, and the first layer of that CompItem is an AVLayer, the following sets the layer quality, startTime, and inPoint.

var firstLayer = app.project.item(1).layer(1);
firstLayer.quality = LayerQuality.BEST;
firstLayer.startTime = 1;
firstLayer.inPoint = 2;

app.project.item(index).layer(index).adjustmentLayer

true if the layer is an adjustment layer.

Boolean; read/write.


app.project.item(index).layer(index).audioActive

true if the layer’s audio is active at the current time. For this value to be true, audioEnabled must be true, no other layer with audio may be soloing unless this layer is soloed too, and the time must be between the inPoint and outPoint of this layer.

Boolean; read-only.


app.project.item(index).layer(index).audioEnabled

When true, the layer’s audio is enabled. This value corresponds to the audio toggle switch in the Timeline panel.

Boolean; read/write.


app.project.item(index).layer(index).blendingMode

The blending mode of the layer.

A BlendingMode enumerated value; read/write. One of:

  • BlendingMode.ADD
  • BlendingMode.ALPHA_ADD
  • BlendingMode.CLASSIC_COLOR_BURN
  • BlendingMode.CLASSIC_COLOR_DODGE
  • BlendingMode.CLASSIC_DIFFERENCE
  • BlendingMode.COLOR
  • BlendingMode.COLOR_BURN
  • BlendingMode.COLOR_DODGE
  • BlendingMode.DANCING_DISSOLVE
  • BlendingMode.DARKEN
  • BlendingMode.DARKER_COLOR
  • BlendingMode.DIFFERENCE
  • BlendingMode.DISSOLVE
  • BlendingMode.DIVIDE
  • BlendingMode.EXCLUSION
  • BlendingMode.HARD_LIGHT
  • BlendingMode.HARD_MIX
  • BlendingMode.HUE
  • BlendingMode.LIGHTEN
  • BlendingMode.LIGHTER_COLOR
  • BlendingMode.LINEAR_BURN
  • BlendingMode.LINEAR_DODGE
  • BlendingMode.LINEAR_LIGHT
  • BlendingMode.LUMINESCENT_PREMUL
  • BlendingMode.LUMINOSITY
  • BlendingMode.MULTIPLY
  • BlendingMode.NORMAL
  • BlendingMode.OVERLAY
  • BlendingMode.PIN_LIGHT
  • BlendingMode.SATURATION
  • BlendingMode.SCREEN
  • BlendingMode.SUBTRACT
  • BlendingMode.SILHOUETE_ALPHA - note the mispelling of ‘SILHOUETTE’!
  • BlendingMode.SILHOUETTE_LUMA
  • BlendingMode.SOFT_LIGHT
  • BlendingMode.STENCIL_ALPHA
  • BlendingMode.STENCIL_LUMA
  • BlendingMode.SUBTRACT
  • BlendingMode.VIVID_LIGHT

app.project.item(index).layer(index).canSetCollapseTransformation

true if it is legal to change the value of the collapseTransformation attribute on this layer.

Boolean; read-only.


app.project.item(index).layer(index).canSetTimeRemapEnabled

true if it is legal to change the value of the timeRemapEnabled attribute on this layer.

Boolean; read-only.


app.project.item(index).layer(index).collapseTransformation

true if collapse transformation is on for this layer.

Boolean; read/write.


app.project.item(index).layer(index).effectsActive

true if the layer’s effects are active, as indicated by the <f> icon next to it in the user interface.

Boolean; read/write.


app.project.item(index).layer(index).environmentLayer

true if this is an environment layer in a Ray-traced 3D composition. Setting this attribute to true automatically makes the layer 3D (threeDLayer becomes true).

Boolean; read/write.


app.project.item(index).layer(index).frameBlending

true if frame blending is enabled for the layer.

Boolean; read-only.


app.project.item(index).layer(index).frameBlendingType

The type of frame blending to perform when frame blending is enabled for the layer.

A FrameBlendingType enumerated value; read/write. One of:

  • FrameBlendingType.FRAME_MIX
  • FrameBlendingType.NO_FRAME_BLEND
  • FrameBlendingType.PIXEL_MOTION

app.project.item(index).layer(index).guideLayer

true if the layer is a guide layer.

Boolean; read/write.


app.project.item(index).layer(index).hasAudio

true if the layer contains an audio component, regardless of whether it is audio-enabled or soloed.

Boolean; read-only.


app.project.item(index).layer(index).hasTrackMatte

true if this layer has track matte. When true, this layer’s trackMatteType value controls how the matte is applied.

See AVLayer.trackMatteType for available track matte types.

Boolean; read-only.


app.project.item(index).layer(index).height

The height of the layer in pixels.

Floating-point value; read-only.


app.project.item(index).layer(index).isNameFromSource

true if the layer has no expressly set name, but contains a named source. In this case, layer.name has the same value as layer.source.name. false if the layer has an expressly set name, or if the layer does not have a source.

Boolean; read-only.


app.project.item(index)layer(index).isTrackMatte

true if this layer is being used as a track matte.

Boolean; read-only.


app.project.item(index).layer(index).motionBlur

true if motion blur is enabled for the layer.

Boolean; read/write.


app.project.item(index).layer(index).preserveTransparency

true if preserve transparency is enabled for the layer.

Boolean; read/write.


app.project.item(index).layer(index).quality

The quality with which this layer is displayed.

A LayerQuality enumerated value; read/write. One of:

  • LayerQuality.BEST
  • LayerQuality.DRAFT
  • LayerQuality.WIREFRAME

app.project.item(index).layer(index).samplingQuality

Set/get layer sampling method (bicubic or bilinear)

A LayerSamplingQuality enumerated value; read/write. One of:

  • LayerSamplingQuality.BICUBIC
  • LayerSamplingQuality.BILINEAR

app.project.item(index).layer(index).source

The source AVItem for this layer. The value is null in a Text layer. Use AVLayer.replaceSource() to change the value.

AVItem object; read-only.


app.project.item(index).layer(index).threeDLayer

true if this is a 3D layer.

Boolean; read/write.


app.project.item(index).layer(index).threeDPerChar

true if this layer has the Enable Per-character 3D switch set, allowing its characters to be animated off the plane of the text layer. Applies only to text layers.

Boolean; read/write.


app.project.item(index).layer(index).timeRemapEnabled

true if time remapping is enabled for this layer.

Boolean; read/write.


app.project.item(index).layer(index).trackMatteLayer

Returns the track matte layer for this layer. Returns null if this layer has no track matte layer.

AVLayer object; read only.


app.project.item(index).layer(index).trackMatteType

This is a Legacy API we don’t recommend using for setting Track Matte Type in new scripts. Please consider using the latest track matte APIs AVLayer.setTrackMatte() and AVLayer.removeTrackMatte() for your tasks.

If this layer has a track matte, specifies the way the track matte is applied. Specifying the TrackMatteType.NO_TRACK_MATTE type will remove the track matte for this layer and reset the track matte type.

A TrackMatteType enumerated value; read/write. One of:

  • TrackMatteType.ALPHA
  • TrackMatteType.ALPHA_INVERTED
  • TrackMatteType.LUMA
  • TrackMatteType.LUMA_INVERTED
  • TrackMatteType.NO_TRACK_MATTE
// Returns the current track matte type for myLayer
var type = myLayer.trackMatteType;
// *** We recommend using the new Track Matte APIs for the operations below (See Warning) ***
// Changes the track matte type for myLayer to TrackMatteType.ALPHA_INVERTED
myLayer.trackMatteType = TrackMatteType.ALPHA_INVERTED;
// Removes the track matte and also resets the type
myLayer.trackMatteType = TrackMatteType.NO_TRACK_MATTE;

app.project.item(index).layer(index).width

The width of the layer in pixels.

Floating-point value; read-only.


app.project.item(index).layer(index).addToMotionGraphicsTemplate(comp)

Adds the layer to the Essential Graphics Panel for the specified composition.

Returns true if the layer is successfully added, or otherwise false.

If the layer cannot be added, it is either because it is not a layer type for which media can be replaced (referred to as Media Replacement Layers), or the layer has already been added to the EGP for that composition. After Effects will present a warning dialog if the layer cannot be added to the EGP.

Use the AVLayer.canAddToMotionGraphicsTemplate() method to test whether the layer can be added to a Motion Graphics template.

ParameterTypeDescription
compCompItem objectThe composition where you wish to add the property to the EGP.

Boolean.


app.project.item(index).layer(index).addToMotionGraphicsTemplateAs(comp, name)

Adds the layer to the Essential Graphics Panel for the specified composition.

Returns true if the layer is successfully added, or otherwise false.

If the layer cannot be added, it is either because it is not a layer type for which media can be replaced (referred to as Media Replacement Layers), or the layer has already been added to the EGP for that composition. After Effects will present a warning dialog if the layer cannot be added to the EGP.

Use the AVLayer.canAddToMotionGraphicsTemplate() method to test whether the layer can be added to a Motion Graphics template.

ParameterTypeDescription
compCompItem objectThe composition where you wish to add the property to the EGP.
nameStringThe new name.

Boolean.


app.project.item(index).layer(index).audioActiveAtTime(time)

Returns true if this layer’s audio will be active at the specified time.

For this method to return true, audioEnabled must be true, no other layer with audio may be soloing unless this layer is soloed too, and the time must be between the inPoint and outPoint of this layer.

ParameterTypeDescription
timeFloating-point valueThe time, in seconds.

Boolean.


app.project.item(index).layer(index).calculateTransformFromPoints(pointTopLeft, pointTopRight, pointBottomRight)

Calculates a transformation from a set of points in this layer.

ParameterTypeDescription
pointTopLeftArray of floating-point values, [x, y, z]The top left point coordinates.
pointTopRightArray of floating-point values, [x, y, z]The top right point coordinates.
pointBottomRightArray of floating-point values, [x, y, z]The bottom right point coordinates.

An Object with the transformation properties set.

var newLayer = comp.layers.add(newFootage);
newLayer.threeDLayer = true;
newLayer.blendingMode = BlendingMode.ALPHA_ADD;
var transform = newLayer.calculateTransformFromPoints(tl, tr, bl);
for (var sel in transform) {
newLayer.transform[sel].setValue(transform[sel]);
}

app.project.item(index).layer(index).canAddToMotionGraphicsTemplate(comp)

Test whether or not the layer can be added to the Essential Graphics Panel for the specified composition.

Returns true if the layer can be added, or otherwise false.

If the layer cannot be added, it is either because it is not a layer type for which media can be replaced (referred to as Media Replacement Layers), or the layer has already been added to the EGP for that composition.

Media Replacement layers are recognized as AVLayers with an AVLayer.source set to a FootageItem object (with specific source types) or a CompItem object.

The AVLayer needs to comply with the restrictions below in order to be treated as a Media Replacement layer:

ParameterTypeDescription
compCompItem objectThe composition where you wish to add the property to the EGP.

Boolean.


app.project.item(index).layer(index).compPointToSource()

Converts composition coordinates, such as sourcePointToComp, to layer coordinates.

This value only reflects the first character in the text layer at the current time.

ParameterTypeDescription
sourcePointToCompArray of floating-point values, [x, y]Position array of composition coordinates

Array of ([X,Y]) position coordinates; read-only.


app.project.item(index).layer(index).openInViewer()

Opens the layer in a Layer panel, and moves the Layer panel to front and gives it focus.

None.

Viewer object for the Layer panel, or null if the layer could not be opened (e.g., for text or shape layers, which cannot be opened in the Layer panel).


app.project.item(index).layer(index).removeTrackMatte()

Removes the track matte for this layer while preserving the TrackMatteType. See AVLayer.setTrackMatte() for another way of removing track matte.

None.

Nothing.

// Sets the track matte layer of myLayer with otherLayer as LUMA type
myLayer.setTrackMatte(otherLayer, TrackMatteType.LUMA);
// Removes the track matte for myLayer but preserves the LUMA type
myLayer.removeTrackMatte();
// Still returns TrackMatteType.LUMA
alert(myLayer.trackMatteType);

app.project.item(index).layer(index).replaceSource(newSource, fixExpressions)

Replaces the source for this layer.

If this method is performed on a null layer, the layers isNull attribute is not changed from true. This causes the layer not to be visible in comp viewer and renders.

ParameterTypeDescription
newSourceAVItem objectThe new source AVItem object.
fixExpressionsBooleantrue to adjust expressions for the new source, otherwise false.
!!! warning
This feature can be resource-intensive; if replacing a large amount of footage, do this only at the end of the operation. See also Project.autoFixExpressions().

Nothing.


app.project.item(index).layer(index).setTrackMatte(trackMatteLayer, trackMatteType)

Sets the track matte layer and type for this layer. Passing in null to trackMatteLayer parameter removes the track matte. See AVLayer.removeTrackMatte() for another way of removing track matte.

ParameterTypeDescription
trackMatteLayerAVLayerThe layer to be used as the track matte layer.
trackMatteTypeTrackMatteType enumThe type of the track matte to be used.

Passing in TrackMatteType.NO_TRACK_MATTE as type is invalid and will result in no-op.

Nothing

// Sets the track matte layer of myLayer with otherLayer as Alpha type
myLayer.setTrackMatte(otherLayer, TrackMatteType.ALPHA);
// Keeps the same trackMatteLayer and only changes the track matte type
myLayer.setTrackMatte(myLayer.trackMatteLayer, TrackMatteType.LUMA);
// Changes the track matte layer but keep the same track matte type
myLayer.setTrackMatte(newTrackMatteLayer, myLayer.trackMatteType);
// Removes the track matte for myLayer and sets the new specified TrackMatteType
myLayer.setTrackMatte(null, TrackMatteType.ALPHA);
myLayer.setTrackMatte(null, TrackMatteType.NO_TRACK_MATTE);
// Invalid. Nothing happens
myLayer.setTrackMatte(otherLayer, TrackMatteType.NO_TRACK_MATTE);

app.project.item(index).layer(index).sourcePointToComp()

Converts layer coordinates, such as boxTextPos, to composition coordinates.

This value only reflects the first character in the text layer at the current time.

ParameterTypeDescription
boxTextPosArray of floating-point values, [x, y]A position array of layer coordinates.

Array of ([X,Y]) position coordinates; read-only.

// For a paragraph text layer.
// Converts position in layer coordinates to comp coordinates.
var boxTextCompPos = myTextLayer.sourcePointToComp(boxTextLayerPos);

app.project.item(index).layer(index).sourceRectAtTime(timeT, extents)

Retrieves the rectangle bounds of the layer at the specified time index, corrected for text or shape layer content. Use, for example, to write text that is properly aligned to the baseline.

ParameterTypeDescription
timeTFloating-point valueThe time index, in seconds.
extentsBooleantrue to include the extents, otherwise false. Extents apply to shape layers, increasing the size of the layer bounds as necessary.

A JavaScript object with four attributes, [top, left, width, height].