Namespace

DuAELayer

DuAELayer

After Effects layer methods

View Source DuAEF_Duik_api.jsxinc, line 26840

Methods

# static addNull(layer) → {Layer}

Adds a new Null object just above a layer, at the same position.
This is a convenience function calling DuAEComp.addNull.
Parameters:
Name Type Description
layer Layer The layer

View Source DuAEF_Duik_api.jsxinc, line 27641

the null
Layer

# 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

View Source DuAEF_Duik_api.jsxinc, line 27340

The effect or null if anything went wrong
PropertyGroup | null

# 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.

View Source DuAEF_Duik_api.jsxinc, line 27865

# 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.

View Source DuAEF_Duik_api.jsxinc, line 27848

# 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.

View Source DuAEF_Duik_api.jsxinc, line 27804

# 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.

View Source DuAEF_Duik_api.jsxinc, line 27781

# 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.

View Source DuAEF_Duik_api.jsxinc, line 27826

# 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

View Source DuAEF_Duik_api.jsxinc, line 27307

The effect corresponding to matchName or null if anything went wrong
PropertyGroup | null

# 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

View Source DuAEF_Duik_api.jsxinc, line 27975

# static bake(layer, modeopt, frameStepopt)

Bakes the expressions to keyframes and removes all non-renderable layers.
Parameters:
Name Type Attributes Default Description
layer Layer The layer to bake.
mode DuAEExpression.BakeAlgorithm <optional>
DuAEExpression.BakeAlgorithm.SMART The algorithm to use for baking the expressions.
frameStep float <optional>
1.0 By default, checks one value per keyframe. A lower value increases the precision and allows for sub-frame sampling. A higher value is faster but less precise.

View Source DuAEF_Duik_api.jsxinc, line 28460

# 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

View Source DuAEF_Duik_api.jsxinc, line 27661

The new layers
Array.<Layer>

# static createLocator(layerOrCompopt) → {ShapeLayer}

Creates a new locator linked to the layer
Parameters:
Name Type Attributes Description
layerOrComp Layer | CompItem <optional>
The layer or the containing comp

View Source DuAEF_Duik_api.jsxinc, line 28323

The locator
ShapeLayer

# 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.

View Source DuAEF_Duik_api.jsxinc, line 26847

Gets an expression linking to the layer
Parameters:
Name Type Attributes Default Description
layer Layer The layer
useThisComp Boolean <optional>
false Whether to begin the expression by 'thisComp' or 'comp("name")'

View Source DuAEF_Duik_api.jsxinc, line 28026

The expression link to the layer
str

# 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

View Source DuAEF_Duik_api.jsxinc, line 27405

The keyframe time or null if there are no keyframe
float | null

# static getActiveProperty(layer) → {DuAEProperty|null}

Gets the After Effects active property (the last selected one)
Parameters:
Name Type Description
layer Layer The layer

View Source DuAEF_Duik_api.jsxinc, line 26954

The selected property, or null if there isn't any.
DuAEProperty | null

# static getAnim(layer, selectedopt, timeRangeopt) → {DuAELayerAnimation}

Gets all animations on the layer in the whole timeline or in the time range
The first DuAEKeyframe._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.

View Source DuAEF_Duik_api.jsxinc, line 26969

The animation.

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

Gets all animations on the layers in the whole timeline or in the time range
The first DuAEKeyframe._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.

View Source DuAEF_Duik_api.jsxinc, line 27000

The animations.
Array.<DuAELayerAnimation>

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

Gets the children of a layer
Parameters:
Name Type Description
layer Layer The layer.

View Source DuAEF_Duik_api.jsxinc, line 27172

All the children of the layer
Array.<Layer>

# static getCreateLayerEffect(layer, targetLayer, effectNameopt) → {DuAEProperty|null}

Gets or create a layer control effect targetting the given target layer.
Parameters:
Name Type Attributes Description
layer Layer The layer to get the effect from
targetLayer Layer The targetted layer, which must be in the same comp than the layer.
effectName string <optional>
The name to use when creating the effect.

View Source DuAEF_Duik_api.jsxinc, line 28301

The effect or null if the two layers are not in the same comp.
DuAEProperty | null

# static getDistance(layer1opt, layer2opt) → {float}

Measures the distance between two layers
Parameters:
Name Type Attributes Description
layer1 Layer <optional>
The first layer. If omitted, will use the selected layers in the current comp
layer2 Layer <optional>
The second layer

View Source DuAEF_Duik_api.jsxinc, line 27238

The distance (in pixels). -1 if less than two layers are found
float

# static getMaxDistance(layers) → {float}

Gets the maximum distance between a bunch of layers
Parameters:
Name Type Description
layers Array.<Layer> | DuList.<Layer> | LayerCollection The layers

View Source DuAEF_Duik_api.jsxinc, line 27259

The distance (in pixels)
float

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

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

View Source DuAEF_Duik_api.jsxinc, line 27738

The properties
Array.<DuAEProperty>

# 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

View Source DuAEF_Duik_api.jsxinc, line 27208

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.
int | null

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

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, whether 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?

View Source DuAEF_Duik_api.jsxinc, line 26905

The selected properties, an empty Array if nothing active or selected
Array.<DuAEProperty>

# static getTransformMatrix(layer, timeopt) → {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 Attributes Description
layer Array.<Layer> the layer
time float <optional>
the time at which to get the coordinates. Current time by default.

View Source DuAEF_Duik_api.jsxinc, line 27896

The coordinates.
Matrix

# static getWorldPos(layer, pointopt, timeopt) → {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
time float <optional>
the time at which to get the coordinates. Current time by default.

View Source DuAEF_Duik_api.jsxinc, line 27279

The world coordinates of the layer
Array.<float>

# static hasChild(layer) → {Boolean}

Checks if a layer has at least one child.
Parameters:
Name Type Description
layer Layer The layer to test

View Source DuAEF_Duik_api.jsxinc, line 27189

true if the layer has at least one child.
Boolean

# static haveSelectedKeys(layers) → {boolean}

Checks if the layers have some selected keyframes
Parameters:
Name Type Description
layers Array.<Layer> | LayerCollection The layers

View Source DuAEF_Duik_api.jsxinc, line 27389

true if the layers have at least one selected keyframe
boolean

# static height(layer) → {Number}

Gets the actual height of a layer (including it's scale)
Parameters:
Name Type Description
layer AVLayer The layer

View Source DuAEF_Duik_api.jsxinc, line 28536

The height, in pixels.
Number

# static insideComp(layer, useBoundsopt) → {Boolean}

Checks if the layer is inside the bounds of the composition
Parameters:
Name Type Attributes Default Description
layer Layer the layer to check
useBounds Boolean <optional>
false (not implemented yet) Checks the layer bounds if true, just the anchor point if false.

View Source DuAEF_Duik_api.jsxinc, line 28077

true if the layer is inside the composition
Boolean

# static isComp(layer) → {Boolean}

Checks if the given layer is a precomposition.
Parameters:
Name Type Description
layer Layer The layer to test

View Source DuAEF_Duik_api.jsxinc, line 28061

true if it is a composition
Boolean

# static isRenderable() → {Bool}

Checks if a layer is renderable. A non-renderable layer can be:
  • A Null layer
  • A Guide layer
  • An empty shape layer
  • An empty text layer
  • A layer with the opacity at 0% for the whole composition

View Source DuAEF_Duik_api.jsxinc, line 28429

Bool

# static isSolid(layer) → {Boolean}

Checks if the given layer is a solid.
Parameters:
Name Type Description
layer Layer The layer to test

View Source DuAEF_Duik_api.jsxinc, line 28046

true if it is a solid
Boolean

# static isThreeD(layer) → {bool}

Checks if a layer is 3D (ie is a threeDLayer or a camera or a light)
Parameters:
Name Type Description
layer Layer The layer

View Source DuAEF_Duik_api.jsxinc, line 28013

true if the layer is a 3D layer
bool

# static lastEffect(layer, nameopt, skipopt) → {PropertyGroup|null}

Gets the last corresponding effect (instead of the first with the native layer.effect() method)
Parameters:
Name Type Attributes Default Description
layer Layer The layer
name string <optional>
The name or matchname to look for. If omitted, will return the last effect.
skip int <optional>
0 Number of effects to skip

View Source DuAEF_Duik_api.jsxinc, line 28108

The effect or null if not found.
PropertyGroup | null

# static lockScale(layer)

Locks the scale with an expression so its value cannot be changed
Parameters:
Name Type Description
layer Layer The layer

View Source DuAEF_Duik_api.jsxinc, line 27649

# static moveInsideComp(layer, useBoundsopt)

Moves a layer in the center of the comp if it is outside
Parameters:
Name Type Attributes Default Description
layer Layer the layer to check
useBounds Boolean <optional>
false (not implemented yet) Checks the layer bounds if true, just the anchor point if false.

View Source DuAEF_Duik_api.jsxinc, line 28092

# static moveLayerToProperty(layer, prop)

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

View Source DuAEF_Duik_api.jsxinc, line 27943

# 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

View Source DuAEF_Duik_api.jsxinc, line 26862

The unique name, with a new number at the end if needed.
string

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

Generates a new unique name for a marker for this layer
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

View Source DuAEF_Duik_api.jsxinc, line 26887

The unique name, with a new number at the end if needed.
string

# static parent(layers, parentopt, unparentedOnlyopt, insertopt)

Parents all (unparented) layers
Parameters:
Name Type Attributes Default Description
layers Layer | LayerCollection | Array.<Layer> | DuList.<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
insert boolean <optional>
false When true, the parent will be parented to the previous parent of the given layer (or first layer if the layers param is a list)

View Source DuAEF_Duik_api.jsxinc, line 27710

# static parentChain(layers)

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

View Source DuAEF_Duik_api.jsxinc, line 27496

# static repositionAnchorPoint(layer, value)

Changes the coordinates of the anchor point without moving the layer
Parameters:
Name Type Description
layer Layer The layer
value Array.<float> The new coordinates

View Source DuAEF_Duik_api.jsxinc, line 28127

# static reverseAnims(anims)

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

View Source DuAEF_Duik_api.jsxinc, line 27126

# static sequence(layersopt, expropt)

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

View Source DuAEF_Duik_api.jsxinc, line 27611

# 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 DuAELayer.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.<DuAELayerAnimation> 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.

View Source DuAEF_Duik_api.jsxinc, line 27067

# 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 DuAELayerAnimation 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)

View Source DuAEF_Duik_api.jsxinc, line 27024

true if the anim was actually set.
Boolean

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

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 DuAELayer.setAllAnims.
Parameters:
Name Type Attributes Default Description
layers Array.<Layer> | LayerCollection The layers.
anims Array.<DuAELayerAnimation> 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.

View Source DuAEF_Duik_api.jsxinc, line 27098

The animations which were not set (no corresponding layers)
Array.<DuAELayerAnimation>

# static setPosition(layer, position, worldopt)

Sets the new coordinates of the layer.
Parameters:
Name Type Attributes Default Description
layer Layer The layer to move
position Array.<float> The new coordinates
world boolean <optional>
false Set to true to use world coordinates.

View Source DuAEF_Duik_api.jsxinc, line 28587

# 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 | DuList.<Layer> The layers to sort

View Source DuAEF_Duik_api.jsxinc, line 27482

The sorted array
Array.<Layer>

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

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

View Source DuAEF_Duik_api.jsxinc, line 27427

The sorted array
Array.<Layer>

# static sourceRect(layer, timeopt, includeExtentsopt, includeMasksopt) → {Array.<float>}

Returns the bounds of the layer in local coordinates, like the sourceRectAtTime() function does in expressions, but can also include masks.
Parameters:
Name Type Attributes Default Description
layer Layer The layer
time float <optional>
The time at which to get the bounds, the current time by default
includeExtents Boolean <optional>
true Includes the extents (strokes, accents...)
includeMasks Boolean <optional>
true Includes the masks

View Source DuAEF_Duik_api.jsxinc, line 28244

The bounds [top, left, width, height]
Array.<float>

# static stack(layers)

Stacks the layers in the timeline according to their order in the given array/DuList
Parameters:
Name Type Description
layers LayerCollection | Array.<Layer> | DuList.<Layer> The layers to stack

View Source DuAEF_Duik_api.jsxinc, line 28554

# 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.

View Source DuAEF_Duik_api.jsxinc, line 27530

# static translate(layer, offset, worldopt)

Sets the new coordinates of the layer to translate it by offset.
Parameters:
Name Type Attributes Default Description
layer Layer The layer to move
offset Array.<float> The value of the translation. A two or three dimensionnal array.
world boolean <optional>
false Set to true to offset in world coordinates.

View Source DuAEF_Duik_api.jsxinc, line 28568

# static unparent(layers)

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

View Source DuAEF_Duik_api.jsxinc, line 27518

# static width(layer) → {Number}

Gets the actual width of a layer (including it's scale)
Parameters:
Name Type Description
layer AVLayer The layer

View Source DuAEF_Duik_api.jsxinc, line 28517

The width, in pixels.
Number