DuAEF.DuAE.Layer

After Effects layer methods

Methods

static addNull(layer) → {Layer}

Adds a new Null object just above a layer, at the same position
Parameters:
Name Type Description
layer Layer The layer
Returns:
Layer - the null

static addPseudoEffect(layer, preset, matchName, nameopt) → {PropertyGroup|null}

This method is a workaround to AE API method layer.applyPreset to work like addProperty when adding pseudoEffects
Parameters:
Name Type Attributes Description
layer Layer The layer
preset File The preset file
matchName string The pseudo Effect matchName.
name string <optional>
The name to set on the effect
Returns:
PropertyGroup | null - The effect or null if anything went wrong

static align(layers, target, positionopt, rotationopt, scaleopt, opacityopt)

Aligns the layers' transformations (position, rotation, scale) to another layer
Parameters:
Name Type Attributes Default Description
layers Array.<Layer> | LayerCollection The layers to align.
target Layer The reference layer.
position boolean <optional>
true True to align position.
rotation boolean <optional>
true True to align orientation.
scale boolean <optional>
true True to align scale.
opacity boolean <optional>
false True to align opcacity.

static alignOpacity(layer, target)

Aligns a layer's opcaity to another layer
Parameters:
Name Type Description
layer Layer The layer to align.
target Layer The reference layer.

static alignOrientation(layer, target)

Aligns a layer's orientation to another layer
Parameters:
Name Type Description
layer Layer The layer to align.
target Layer The reference layer.

static alignPosition(layer, target)

Aligns a layer in position to another layer
Parameters:
Name Type Description
layer Layer The layer to align.
target Layer The reference layer.

static alignScale(layer, target)

Aligns a layer's scale to another layer
Parameters:
Name Type Description
layer Layer The layer to align.
target Layer The reference layer.

static applyPreset(layer, preset, matchName) → {PropertyGroup|null}

Adds an animation preset on the layer.
Be careful as layer selection will be kept but not properties selection,
and this can result in an "invalid object" if referencing a property.
Parameters:
Name Type Description
layer Layer The layer
preset File The preset file
matchName string The pseudo Effect matchName
Returns:
PropertyGroup | null - The effect corresponding to matchName or null if anything went wrong

static autoDuration(layer, preExpressionopt)

Sets the In and Out points of a layer according to its opacity (cuts at 0%)
Parameters:
Name Type Attributes Default Description
layer Layer The layer
preExpression boolean <optional>
false Whether to check for the opacity post or pre-expression value

static copyToComp(layers, destinationComp, withPropertyLinksopt) → {Array.<Layer>}

Copies the layers to another comp
Parameters:
Name Type Attributes Default Description
layers Array.<Layer> The layers to copy and paste
destinationComp CompItem The composition to copy to
withPropertyLinks boolean <optional>
false Add expressions on the properties to link them to the orriginal layers
Works only on 12.0 and above, ignored on 11.0 (CS6) and below
Returns:
Array.<Layer> - The new layers

static doLayers(method, undoGroupNameopt)

Runs a function on all the layers
Parameters:
Name Type Attributes Description
method function The function to run on the layers, which takes a layer as its only argument.
undoGroupName string <optional>
The name of the undoGroup created before the execution. If not provided, there will not be any undoGroup created.

static firstKeyFrameTime(layer, selected) → {float|null}

Gets the time of the first keyFrame
Parameters:
Name Type Description
layer Array.<Layer> | LayerCollection The layer
selected boolean true to check selected keyframes only
Returns:
float | null - The keyframe time or null if there are no keyframe

static getAnim(layer, selectedopt, timeRangeopt) → {LayerAnim}

Gets all animations on the layer in the whole timeline or in the time range
The first KeyFrame._time will be adjusted relatively to the start of the time range (if provided) instead of the startTime of the composition.
Parameters:
Name Type Attributes Default Description
layer Layer The layer.
selected boolean <optional>
false true to get only selected keyframes.
timeRange Array.<float> <optional>
The time range, an array of two time values, in seconds.
Returns:
LayerAnim - The animation.

static getAnims(layers, selectedopt, timeRangeopt) → {Array.<LayerAnim>}

Gets all animations on the layers in the whole timeline or in the time range
The first KeyFrame._time will be adjusted relatively to the start of the time range (if provided) instead of the startTime of the composition.
Parameters:
Name Type Attributes Default Description
layers Array.<Layer> | LayerCollection The layers.
selected boolean <optional>
false true to get only selected keyframes.
timeRange Array.<float> <optional>
The time range, an array of two time values, in seconds.
Returns:
Array.<LayerAnim> - The animations.

static getChildren(layer) → {Array.<Layer>}

Gets the children of a layer
Parameters:
Name Type Description
layer Layer The layer.
Returns:
Array.<Layer> - All the children of the layer

static getDistance(layer1, layer2) → {int}

Measures the distance between two layers
Parameters:
Name Type Description
layer1 Layer The first layer
layer2 Layer The second layer
Returns:
int - The distance (in pixels)

static getPuppetPins(layer) → {Array.<PropertyInfo>}

Gets all the (selected) puppet pins found on the layer.
Will return all puppet pins if there is no puppet selection.
Parameters:
Name Type Description
layer Layer The layer
Returns:
Array.<PropertyInfo> - The properties

static getRelation(layer1, layer2) → {int|null}

Checks if a layer is a descendant of another layer
Parameters:
Name Type Description
layer1 Layer The first layer
layer2 Layer The second layer
Returns:
int | null - the degree of relation. 0 if layer1 is not a relative of layer2,
negative if layer2 is a descendant of layer1, positive if layer2 is an ancestor.
null if the two layers are not in the same composition or if they are the same layer.

static getSelectedProps(layer, filteropt, strictopt, caseSensitiveopt) → {Array.<PropertyBase>}

Gets the After Effects selected properties in the layer
Parameters:
Name Type Attributes Default Description
layer Layer The layer
filter PropertyType | PropertyValueType | string | function <optional>
A filter to get only a certain type, or value type, or property name or matchName.
A function which take one PropertyBase as argument can be used to filter the properties: the Property will be returned if the function returns true.
strict boolean <optional>
false If a string filter is provided, wether to search for the exact name/matchName or if it contains the filter.
caseSensitive boolean <optional>
true If a string filter is provided, and not strict is false, does the search have to be case sensitive?
Returns:
Array.<PropertyBase> - The selected properties, an empty Array if nothing active or selected

static getTransformMatrix(layer) → {Matrix}

Gets the transformation matrix of the layer from the compostion.
Use Matrix.applyToPoint(point) to transform any coordinate with the matrix returned by this method.
Parameters:
Name Type Description
layer Array.<Layer> the layer
Returns:
Matrix - The coordinates.

static getWorldPos(layer, pointopt) → {Array.<float>}

Gets the world coordinates of the point of a layer
Parameters:
Name Type Attributes Default Description
layer Layer The layer
point Array.<float> <optional>
layer.transform.anchorPoint.value the point
Returns:
Array.<float> - The world coordinates of the layer

static haveSelectedKeys(layers) → {boolean}

Checks if the layers have some selected keyframes
Parameters:
Name Type Description
layers Array.<Layer> | LayerCollection The layers
Returns:
boolean - true if the layers have at least one selected keyframe

static lockScale(layer, allAEVersionsopt)

Locks the scale with an expression so its value cannot be changed
Parameters:
Name Type Attributes Default Description
layer Layer The layer
allAEVersions bool <optional>
false true to lock scale even on CS6 and older
Those older versions will display the scale property when typing the "U" shorcut when it's locked.

static moveLayerToProperty(layer, prop)

Moves a layer to the coordinates of a spatial property
Parameters:
Name Type Description
layer Layer The layer
prop Property | PropertyInfo The property

static newUniqueEffectName(newName, layer, incrementopt) → {string}

Generates a new unique name for an effect
Parameters:
Name Type Attributes Default Description
newName string The wanted new name
layer Layer The layer
increment boolean <optional>
true true to automatically increment the new name if it already ends with a digit
Returns:
string - The unique name, with a new number at the end if needed.

static newUniqueMarkerName(newName, layer, incrementopt) → {string}

Generates a new unique name for a marker for this comp
Parameters:
Name Type Attributes Default Description
newName string The wanted new name
layer Layer The comp
increment boolean <optional>
true true to automatically increment the new name if it already ends with a digit
Returns:
string - The unique name, with a new number at the end if needed.

static parent(layers, parentopt, unparentedOnlyopt)

Parents all (unparented) layers
Parameters:
Name Type Attributes Default Description
layers Layer | LayerCollection | Array.<Layer> The layers to parent
parent Layer <optional>
The parent. If not defined, will use the last layer of the list
unparentedOnly boolean <optional>
true True to parent only layers which do not have a parent yet

static parentChain(layers)

Parents all the layers together beginning by the end of the array
Parameters:
Name Type Description
layers Array.<Layer> The layers to parent

static reverseAnims(anims)

Reverses the times of the keyframes to reverse the animation
Parameters:
Name Type Description
anims Array.<LayerAnim> | LayerAnim The animation

static sequence(layers, expropt)

Creates a sequence with the layers, but using opacities. This enables more possibilities to rig them, like with the Connector
Parameters:
Name Type Attributes Description
layers Array.<Layer> | LayerCollection The layers
expr string <optional>
An expression to add to the opacity of the layers

static setAllAnims(layers, anims, timeopt, ignoreNameopt, setExpressionopt, onlyKeyframesopt, replaceopt, whiteListopt, offsetopt, reverseopt)

Sets the animations on the layers.
If you need to set only on the same layers (same index, same name), use DuAEF.DuAE.Layer.setAnims.
Parameters:
Name Type Attributes Default Description
layers Array.<Layer> | LayerCollection The layers.
If there are more layers than animations, the layers array will be truncated.
anims Array.<LayerAnim> The layer animations.
If there are more animations than layers, the animations array will be truncated.
time float <optional>
comp.time The time where to begin the animation
ignoreName boolean <optional>
false true to set the anim even if name of the property do not match the name animation.
This way, only the type of property (i.e. matchName) is checked.
setExpression boolean <optional>
false Set the expression on the property
onlyKeyframes boolean <optional>
true If false, the value of properties without keyframes will be set too.
replace boolean <optional>
false true to remove any existing keyframe on the properties before adding new keyframes
whiteList Array.<string> <optional>
A list of matchNames used as a white list for properties to set anims.
Can be the matchName of a propertyGroup to set all the subproperties.
offset boolean <optional>
false true to offset the current value, instead of replacing it
reverse boolean <optional>
false true to reverse the keyframes (in time)
Note: the remaining animations which are returned will already be reversed, do not set this to true again if you plan to set them later.

static setAnim(layer, anims, timeopt, ignoreNameopt, setExpressionopt, onlyKeyframesopt, replaceopt, propertyWhiteListopt, offsetopt, reverseopt) → {boolean}

Sets the property animation on the property
Parameters:
Name Type Attributes Default Description
layer Layer The layer.
anims LayerAnim The animation
time float <optional>
comp.time The time where to begin the animation
ignoreName boolean <optional>
false true to set the anim even if name of the property do not match the name of the animation.
This way, only the type of property (i.e. matchName) is checked.
setExpression boolean <optional>
false Set the expression on the property
onlyKeyframes boolean <optional>
true If false, the value of properties without keyframes will be set too.
replace boolean <optional>
false true to remove any existing keyframe on the properties before adding new keyframes
propertyWhiteList Array.<string> <optional>
A list of matchNames used as a white list for properties to set anims.
Can be the matchName of a propertyGroup to set all the subproperties.
offset boolean <optional>
false true to offset the current value, instead of replacing it
reverse boolean <optional>
false true to reverse the keyframes (in time)
Returns:
boolean - true if the anim was actually set.

static setAnims(layers, anims, timeopt, ignoreNameopt, setExpressionopt, onlyKeyframesopt, replaceopt, whiteListopt, offsetopt, reverseopt) → {Array.<LayerAnim>}

Sets the animations on the corresponding layers.
The animation will be set only on layers with the same name and index.
To set all animations on all layers, not checking their names or indices, use DuAEF.DuAE.Layer.setAllAnims.
Parameters:
Name Type Attributes Default Description
layers Array.<Layer> | LayerCollection The layers.
anims Array.<LayerAnim> The layer animations
time float <optional>
comp.time The time where to begin the animation
ignoreName boolean <optional>
false true to set the anim even if name of the property do not match the name animation.
This way, only the type of property (i.e. matchName) is checked.
setExpression boolean <optional>
false Set the expression on the property
onlyKeyframes boolean <optional>
true If false, the value of properties without keyframes will be set too.
replace boolean <optional>
false true to remove any existing keyframe on the properties before adding new keyframes
whiteList Array.<string> <optional>
A list of matchNames used as a white list for properties to set anims.
Can be the matchName of a propertyGroup to set all the subproperties.
offset boolean <optional>
false true to offset the current value, instead of replacing it
reverse boolean <optional>
false true to reverse the keyframes (in time)
Note: the remaining animations which are returned will already be reversed, do not set this to true again if you plan to set them later.
Returns:
Array.<LayerAnim> - The animations which were not set (no corresponding layers)

static sortByIndex(layers) → {Array.<Layer>}

Sort the layers by their indices. Returns a new Array, the original array or collection is not changed.
Parameters:
Name Type Description
layers Array.<Layer> | LayerCollection The layers to sort
Returns:
Array.<Layer> - The sorted array

static sortByParent(layers) → {Array.<Layer>}

Sort the layers by their parenting (root at first index 0)
Parameters:
Name Type Description
layers Array.<Layer> | Collection The layers to sort
Returns:
Array.<Layer> - The sorted array

static toggleEditMode(layer)

(Un)parent the children of the layer.< br/> When children are unparented, an effect is added and the name of the layer is changed to show the "edit mode" is enabled.
When toggled again, the effect is removed, and the name is restored.
Parameters:
Name Type Description
layer Layer The layer to toggle.

static unparent(layers)

Un-parents all the layers
Parameters:
Name Type Description
layers Array.<Layer> The layers