Animation
DEVELOPPER GUIDE
libDuik 15 reference - Nicolas Dufresne
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license,
visit http://creativecommons.org/licenses/by-nc-sa/4.0/
INTRODUCTION
libDuik is a complete library of objects, attributes and methods
from Duik Duduf IK & Animation Tools for After Effects. It
allows you to easily include Duik functions into other scripts.
PSEUDO EFFECTS
LIST
libDuik uses pseudo effects instead of expression controls. Example: app.project.activeItem.layer(1).effect.
Those effects must be added to presetEffects.xml addProperty(PSEUDO/DUIK_One_Layer_IK);
(see Introduction, Installing libDuik for more details).
But, using libDuik, you should instead use
The XML code used to create those effects is Duik_ Duik.utils.addEffect(layer,effectMatchName);
presetEffects.xml Example:
Duik.utils.addEffect(layer,DUIK_One_Layer_IK);
Here is a list of the effects available.
Those effects can be added on any layer with: This way, libDuik checks if the pseudo effect has been
layer.effect.addProperty(PSEUDO/ + matchName) installed, and if not, it tries to use a corresponding preset
(.ffx file)
OBJECTS
libDuik creates new javascript instantiable javascript objects, which can be very
helpful when working with After Effects, and are needed by Duik.
Name Description
KeySpatialProperties.inTangent KeySpatialProperties.autoBezier
KeySpatialProperties.outTangent KeySpatialProperties.roving
KeySpatialProperties.continuous
KeyFrame.time KeyFrame.spatialProperties
KeyFrame.value KeyFrame.inEase
KeyFrame.inInterpolationType KeyFrame.outEase
KeyFrame.outInterpolationType KeyFrame.continuous
KeyFrame.spatial KeyFrame.autoBezier
inEase Array of AFX KeyframeEase objects Incoming temporal ease of the keyframe
outEase Array of AFX KeyframeEase objects Outgoing temporal ease of the keyframe
PropertyAnim.name
PropertyAnim.keys
PropertyAnim.startValue
keys Array of KeyFrames Keyframes of the animation, see KeyFrame object attributes
effectsAnims Array of EffectAnim Animations of the effects, see EffectAnim object attributes
masksAnims Array of MaskAnim Animations of the masks, see MaskAnim object attributes
layer1 AVLayer First layer of the IK (the root, the top parent)
layer2 AVLayer or null The second layer of the IK, if type is 2 or 3, or null if type is 1.
layer3 AVLayer or null The third layer of the IK, if type is 3, or null if type is 1 or 2.
clockWise boolean true if the IK bends clockwise. Used with type 2 and 3 only.
create() Creates the rig in the comp AVLayer, the zero created (if any) or null
16 Objects
IKRig.create()
Creates the IK Rig in the comp. Sets the created attribute to true if sucessful.
returns
AVLayer, the zero created (if any) or null.
PropertyDescription.isEffect PropertyDescription.parentName
PropertyDescription.index PropertyDescription.dimensions
PropertyDescription.depth PropertyDescription.canSetExpression
dimensions integer 1, 2 or 3
Array of floats
color The color of the controller
[R,V,B,A]
update() Updates the shape of the controller, if its properties have changed void
Precomposes all layers of the comp, and animates the resulting layer
precompose(comp) void
with the animation of the camera
applyToLayer(camLayer, links) Applies the animation of the camera to the given layer void
x float X position
y float Y position
TVPProfileprofPoint.u TVPProfileprofPoint.v
DUIK
Duik.sizes.SMALL integer 0
Duik.sizes.MEDIUM integer 1
Duik.sizes.BIG integer 2
Duik.layerTypes.VECTOR integer 2
Duik.layerTypes.NULL integer 1
Duik.layerTypes.SOLID integer 0
Duik.getLayers.INDEX integer 0
Duik.getLayers.NAME integer 1
Duik.getLayers.SELECTION_INDEX integer 2
Duik.placement.TOP integer 0
Duik.placement.BOTTOM integer 1
Duik.placement.OVER_LAYER integer 2
Duik.placement.UNDER_LAYER integer 3
Duik Attributes
Duik Objects
Name Description
Duik Methods
Low-level methods are listed below (greyed) but they are not documented.
If you do not understand what low-level methods do by reading them in libDuik.jsxinc, you shouldnt need them.
true if successful,
autoIK(layers,clockWise,
AddsIK onthe layers false if anything
frontFacing)
went wrong
true if successful,
Adds a goal effect to the layer, which
goal(layer, controller) false if anything
may be controlled by a controller
went wrong
addController(layer,
Createsa null object (controller)
color, autoLock, rotation,
at layer position and named by layer. Controller object
xPosition, yPosition, scale,
name
arc)
true if successful,
wiggle(layer, property,
Adds a wiggle effect to given property false if anything
separateDimensions)
went wrong
true if successful,
Adds exposure controls to the
fixedExposure(layer, prop) false if anything
animation of the property.
went wrong
Array of AVLayer;
addBones(layers) Adds bones to the layers
bones
Array of AVLayer;
addZeros(layers) Adds zeros to the layers
zeros
true if successful,
Creates a rotation morph on the given
rotationMorph(layer, prop) false if anything
property
went wrong
true if successful,
swing(layer,prop) Creates a swing on the given property false if anything
went wrong
true if successful,
Automates the rotation of the given
wheel(layer, radius, curved) false if anything
layer using its position
went wrong
true if successful,
lensFlare(layers) Rigs the layers to move like a lens flare. false if anything
went wrong
true if successful,
distanceLink(layer, property, Linksthe property to the distance of
false if anything
parentLayer) parentLayer
went wrong
true if successful,
spring(property, layer,
Adds a spring effect on the properties false if anything
simulated)
went wrong
copyAnim(layers,
selectedKeysOnly, Copies the animation of the layers Array of LayerAnim
startTime, endTime)
true if successful,
blink(layer, prop) Adds a blink effect to the property. false if anything
went wrong
randomizeProperties
(props, fromCurrentVal, Randomizes the values
void
xMin, xMax, yMin, of the properties.
yMax, zMin, zMax)
randomizeStartTimes
Randomizes start times
(layers, fromCurrentVal, void
of the given layers.
min, max)
DUIK 25
randomizeInPoints
Randomizes in points
(layers, fromCurrentVal, void
of the given layers.
min, max)
randomizeOutPoints
Randomizes out points
(layers, fromCurrentVal, Void
of the given layers.
min, max)
randomizeSelectedKeys(props,
Randomizes the values of the selected
fromCurrentVal, xMin, xMax, void
keyframes of the properties.
yMin, yMax, zMin, zMax)
Duik.autoIK Duik.addControllers
(layers, clockWise, frontFacing) (layers, color, autoLock, rotation, xPosition,
Adds IK on the layers. Duik will attempt to autodetect yPosition, scale, arc)
each layer role, using Duik.utils.prepIK(). If it cant (wrong This is a convenience method, which runs Duik.addController()
parenting, wrong placement...) it will use the order on each layer of the given array of layers.
of the layers in the Array or LayerCollection: first the
layers, from end to root (from child to parent), last the parameters
controller. layers | Array of AVLayer or LayerCollection
color | Array of 4 floats : [R,V,B,A], default [1,1,1,1]
parameters: autoLock | boolean, default false
layers | Array of AVLayers or LayerCollection rotation | boolean, default true
clockWise | boolean, used only with two-layer and xPosition | boolean, default true
three-layer IK, default: false yPosition | boolean, default true
frontFacing | boolean, default: false scale | boolean, default false
arc | boolean, default false
returns
IKRig object created returns
Array of Controller objects
Duik.goal
(layer, controller) Duik.wiggle
Adds a goal effect to the layer, which may be controlled (layer, property, separateDimensions)
by a controller Adds a wiggle effect to given property.
parameters: parameters
layer| AVLayer layer | AVLayer of the property
controller | AVLayer or undefined property | Property
separateDimensions | boolean, false to apply the same
returns wiggle to all dimensions, default: false
true if successful, false if anything went wrong
returns
true if successful, false if anything went wrong
Duik.addController
(layer, color, autoLock, rotation, xPosition,
yPosition, scale, arc) Duik.fixedExposure
Creates a null object (controller) at layer position and (layer,prop)
named by layer.name Adds exposure controls to the animation of the property.
If Duik.settings.controllerType is Duik.layerTypes.VECTOR,
the parameters are used to draw a nice icon instead of parameters
using a null object. layer | AVLayer
If autoLock is true, the transformations which should prop | Property
not be changed are locked with a simple expression.
See Controller object. returns
true if successful, false if anything went wrong
parameters
layer | AVLayer
color | Array of 4 floats : [R,V,B,A], default [1,1,1,1]
autoLock | boolean, default false
rotation | boolean, default true
xPosition | boolean, default true
yPosition | boolean, default true
scale | boolean, default false
arc | boolean, default false
returns
Controller object
DUIK 27
Duik.adaptativeExposure Duik.rotationMorph
(layers,precision, (layer,prop)
minExp,maxExp,sync,layerSync) Creates a rotation morph on the given property.
Adds exposure controls to the animation of the property.
The exposure adapts automatically to the speed, according Parameters
to the given precision, of the properties between a layer | AVLayer
minimum and a maximum exposure (in frames). prop | Property
parameters returns
layers | Array of AVLayer or LayerCollection true if successful, false if anything went wrong
precision | integer, default: 100
minExp | integer, default: 1
maxExp | integer, default: 4 Duik.swing
sync | boolean, wether to sync all properties, default: (layer,prop)
true Creates a swing on the given property
layerSync | boolean, wether to sync all layers, if sync
== true, default: false parameters
layer | AVLayer
returns prop | Property
true if successful, false if anything went wrong
returns
true if successful, false if anything went wrong
Duik.addBones
(layers)
Adds bones to the layers, only on selected pins if any, Duik.wheel
or else on all puppet pins found on those layers. (layer, radius, curved)
Automates the rotation of the given layer using its
parameters position.
layers | Array of AVLayers If curved, works even if the trajectory is not horizontal,
but is heavier to compute.
returns
Array of AVLayers, the bones created parameters
layer | AVLayer
radius | float, default 100.0
Duik.addZero curved | boolean, default false
(layer)
Adds a null object for the layer, at the same place returns
and orientation, and then parents the layer to it, true if successful, false if anything went wrong
parenting the null object (the zero) to the former
parent of the layer.
Duik.morpher
parameters (layers)
layers | Array of AVLayers Adds a morpher, a slider to easily control interpolations
of selected properties of the given layers.
returns
Array of AVLayers, the zeros created parameters
layers | Array of AVLayer
Duik.addZeros returns
(layers) true if successful, false if anything went wrong
This is a convenience method, which runs Duik.addZero() on each
layer of the given array of layers.
parameters
layers | Array of AVLayers or LayerCollection
returns
Array of AVLayers, the zeros created
28 DUIK
Duik.lensFlare Duik.pasteAnim
(layers) (layers, layerAnims, startTime,
Rigs the layers to move like a lens flare. The first layer getLayerMethod)
in the selection is the controller, with sliders for intensity Pastes all the animations in the Array of LayerAnim on
and size; the other layers have a distance property to layers, using layer names or layer indexes, beginning at
adjust their position along the lens flare. startTime
See LayerAnim object
parameters
layers | Array of AVLayer parameters
layers | Layers where to paste the animation
returns layerAnims | Array of LayerAnim, default: Duik.
true if successful, false if anything went wrong copiedAnim
startTime | float, default: comp.time
getLayerMethod | one of Duik.getLayers.NAME, Duik.
Duik.distanceLink getLayers.INDEX, Duik.getLayers.SELECTION_
(layer,property,parent Layer); INDEX, default: Duik.settings.getLayerMethod
Links the property to the distance of parentLayer
returns
parameters integer, number of layers on which animations were
layer | AVLayer containing the property pasted
property | Property to rig
parentLayer | AVLayer which distance from layer is used
to rig Duik.rigPaint
(layers)
returns Rigs the paint effects to be able to animate all strokes as if
true if successful, false if anything went wrong there was only one.
parameters
Duik.spring layers | Array of AVLayers or LayerCollection
(property, layer, simulated)
Adds a spring effect on the property returns
void
parameters
property | Property
layer | AVLayer containing the property Duik.blink
simulated | if true, applies the simulated version of the (layer, prop)
spring, default: false Adds a blink effect to the property.
returns parameters
true if successful, false if anything went wrong layer | AVLayer
prop | Property
Duik.copyAnim returns
(layers, selectedKeysOnly, startTime, endTime) true if successful, false if anything went wrong
Copies all the animations as LayerAnim objects (except expressions)
on selected layers, and store them in the Array Duik.copiedAnim.
If selectedKeysOnly is true, copies only the selected keyframes, Duik.lockProperty
otherwise all the masks, effcts, and transformation properties (layer, prop)
will be copied, even if they are not animated (in this case, the Locks the property with a simple expression.
value will be stored in the PropertyAnim.startValue). If you do
not want to keep the properties without animation, you will parameters
have to loop through the arrays of PropertyAnim and check if layer | AVLayer
PropertyAnim.keys.length > 0 to remove empty animations prop | Property
from the Arrays. See LayerAnim object
returns
parameters void
layers | Array or Collection of AVLayers
selectedKeysOnly | boolean, true to copy only selected
keys, default: false
startTime | float, default: start of the comp
endTime | float, default: end of the comp
returns
Array of LayerAnim
DUIK 29
Duik.scaleZLink Duik.importRigInComp
(layers) (comp, rigComp, rigName, progressBar,
Links the distance of the layer from the camera to its scale progressText, containingWindow)
so its apparent size wont change. If multiple cameras, Imports a rig in the comp, transferring and linking the
include the camera used in the array. controllers in the new comp, while keeping the rig
precomposed.
parameters The rig comp is duplicated, including precomps,
layers | Array of Layer or LayerCollection renamed, and expressions are updated, so that one can
import the same rig several times.
returns A Master Controller is created to move, scale and flip the
void imported rig.
All controllers created by Duik, and any layer which name
begins with C_ is considered a controller. The controllers
Duik.timeRemap should not be parented to any of the other layers, but they
(layers) can be parented to other controllers and have zeros.
Activates the time remapping of the layers, extending Any controller without zero will have one automatically
them to the length of the comp and adjusting the last added, this is needed to link them from the composition
keyframe. with the rig to the one where its imported.
parameters parameters
layers | Array of Layer or LayerCollection comp | CompItem, the comp where to import the rig
loopType | String, in or out or none, default: rigComp | CompItem, the comp containing the rig
none rigName | the name of this instance of the rig, must be
unique in the project
returns
void returns
void
Duik.onionSkin
(layers) Duik.randomizeProperties
Activates or deactivates an onion skin on paint effects on (props, fromCurrentVal, xMin, xMax, yMin,
the layer. yMax, zMin, zMax)
Randomizes the values of the properties.
parameters Min and max values for each axis can be undefined: in this
layer | AVLayer case, the axis wont be randomized.
activate | boolean, default: true
duration | integer, onion skin duration in frames, parameters
default: 5 props | Array of PropertyBase
fromCurrentVal | boolean, if true, min and max values
returns are added to current property value
void
returns
void
Duik.randomizeStartTimes
(layers, fromCurrentVal, min, max)
Randomizes start times of the given layers.
Min and Max in seconds (comp time).
parameters
layers | Array of Layers or LayerCollection
fromCurrentVal | boolean, if true, min and max values
are added to current start time value
returns
void
Duik.randomizeInPoints Duik.groupPaint
(layers, fromCurrentVal, min, max) (props)
Randomizes in points of the given layers. Rigs the paint effects to be able to animate all brushes as if
Min and Max in seconds (comp time). there was only one.
parameters parameters
layers | Array of Layers or LayerCollection props | Array of Properties (the brushes to rig)
Lo fromCurrentVal | boolean, if true, min and max values
are added to current in point value returns
void
returns
void
Duik.randomizeSelectedKeys
(layers, fromCurrentVal, xMin, xMax, yMin,
Duik.randomizeOutPoints yMax, zMin, zMax)
(layers, fromCurrentVal, min, max) Randomizes the values of the selected keyframes of the
Randomizes out points of the given layers. properties.
Min and Max in seconds (comp time). Min and max values for each axis can be undefined: in this
case, the axis wont be randomized.
parameters
layers | Array of Layers or LayerCollection parameters
fromCurrentVal | boolean, if true, min and max values layers | Array or Collection of Layers
are added to current out point value fromCurrentVal | boolean, if true, min and max values
are added to current property value
returns
void returns
void
Duik.pathFollow
(layer) Duik.randomizeSelectedKeyTimes
Automates the rotation of the layer so it follows its path. (layers, fromCurrentVal, min, max)
Randomizes the times of the selected keyframes of the
parameters properties.
layer | AVLayer
parameters
returns ayers | Array or Collection of Layers
void fromCurrentVal | boolean, if true, min and max values
are added to current property value
Duik.multiplane returns
(numLayers) void
Creates null objects rigged to easily animate a 2D
multiplane camera.
parameters
numLayers | integer, number of layers to create, default:
3
returns
void
Duik.moveAway
(numLayer)
Rigs the position of the layer to be able to move it away
from its parent with a simple slider.
parameters
layer | AVLayer
returns
void
DUIK 31
DUIK.SETUP
Methods and attributes to correctly install libDuik & pseudo effects.
Duik.setup Attributes
Duik.setup.presetEffects
The XML (as string object) to insert just before </effects>in After Effects presetEffects.xml
to correctly install libDuik pseudo effects.
presetEffects string
This includesthe version of of libDuik as an XMLcomment, which can be checked by
Duik.setup.checkPresetEffectsVersion to ensure libDuik has been correcly installed.
Duik.setup Methods
Duik.setup.installPseudoEffects() Duik.setup.checkPresetEffectsVersion()
Duik.setup.installPseudoEffects Duik.setup.checkPresetEffectsVersion
() ()
Tries to Automatically install pseudo effects in After Effects presetEffects.xml. Checks the version of installed libDuik pseudo effects,
The installation can be checked with Duik.checkPresetEffectsVersion(), en stored in Duik.presetEffectsInstalledVersion.
then comparing Duik.presetEffectsInstalledVersion with Duik.versionNumber. See Duik.setup.installPseudoEffects() for an example.
Example:
//install parameters:
Duik.installPseudoEffects(); none
//check returns
Duik.checkPresetEffectsVersion(); void
if (Duik.presetEffectsInstalledVersion != Duik.versionNumber) {
//do something
} else {
//continue loading your script
}
parameters:
none
returns
void
DUIK.UI 33
DUIK.UI OBJECTS
Contains attributes and methods to manipulate some user interface objects
(progress bar, alerts) displayed by libDuik
Duik.ui.progressPanel
Duik.ui.progressGroup
Duik.ui.progressBar
Duik.ui.progressStatus
progressPanel Window Window containing the progress bar and status of libDuik
Duik.ui Methods
Duik.ui.updateProgressPanel (val,status)
Duik.ui.showProgressPanel (maxVal,status)
Duik.ui.hideProgressPanel ()
showProgressPanel (maxVal, status) Initializes and displays the progress panel. Void
returns
void
Duik.ui. showProgressPanel
(maxVal,status)
First, initializes the progress panel, settting the max value
of the progress bar and the text to display behind it, then
displays it.
parameters:
maxVal | integer, the max value of the progress bar
status | string, the text to display behind the progress bar
returns
void
DUIK.UISTRINGS 35
DUIK.UISTRINGS
Contains all string names used by effects created by Duik.
You can set these strings to translate libDuik at runtime.
Default values are English names.
Duik.uistrings attributes
ik string "IK"
PSEUDO
DUIK.SETTINGS
EFFECTS
LIST
Access to settings used by Duik.
Duik.settings Attributes
These attributes define some settings and preferences needed by Duik.
If you set them, they can be saved to be reloaded even if After Effects is shutdown, using Duik.settings.save(). If this method
is not called, the settings will be set back to previous values if After Effects is shut down.
Saved settings must be loaded at runtime calling Duik.settings.load().
Default values can be restored using Duik.settings.restoreDefaults().
Duik.settings Methods
Duik.settings.save Duik.settings.restoreDefaults
() ()
Saves Duik settings attributes into After Effects Restore default values to Duik settings. These values will
preferences (using app.settings.saveSetting()) not be saved until Duik.settings.save() is called.
Those settings can be loaded when the script runs using
Duik.settings.load(). This allows to easily restore the settings parameters:
set by the user even if After Effects is shut down. none
parameters: returns
none void
returns
void
Duik.settings.load
()
Loads Duik settings attributes from After Effects
preferences (using app.settings.getSetting())
This allows to easily restore the settings set by the user
even if After Effects is shut down.
If this method is not called at runtime, default values
will be loaded at first run.
parameters:
none
returns
void
DUIK.BRIDGE 39
DUIK.BRIDGE
OBJECTS
Tools for importing/exporting to/from After Effects.
Duik.bridge.tvPaint
Tools to import and export assets from/to TvPaint
Duik.bridge.tvPaint Methods
Duik.bridge.tvPaint.parseCam(camString) Duik.bridge.tvPaint.loadCamFile(camFile)
Duik.bridge.tvPaint.parseCam Duik.bridge.tvPaint.loadCamFile
(camString) (camFile)
Parses a string representing a camera exported from Loads and parses a file representing a camera exported
TVPaint, with its animation. from TVPaint, with its animation.
parameters: parameters:
camString | the string to parse camFile | javascript File object to load
returns returns
TVPCamera, see TVPCamera Object TVPCamera, see TVPCamera Object
TI
DUIK.JS
Lo
General javascript related tools.
Duik.js Methods
General javascript related tools.
Duik.js.escapeRegExp(string) Duik.js.arrayHasDuplicates(array)
Duik.js.replaceAll(string, find, replace, caseSensitive) Duik.js.arrayGetDuplicates(array)
Duik.js.random(min, max) Duik.js.arrayRemoveDuplcates(array)
Duik.js.arrayIndexOf(array, value)
Duik.js.escapeRegExp Duik.js.replaceAll
(string) (string, find, replace, caseSensitive)
Escapes all regular expressions special characters Replaces all occurences of find by replace in the given
in the given string. string.
parameters: parameters:
string | string string | string to modify
find | string to search
returns replace | string, replacement
string, the modified string. caseSensitive | boolean, wether to perform a
caseSensitive search
returns
string, the modified string.
DUIK.JS 41
Duik.js.random Duik.js.arrayGetDuplicates
(min, max) (array)
Random number between min and max Get the duplicated items of the array
parameters: parameters:
min | float or integer, the minimum value array | Array, the array
max | float or integer, the maximum value
returns
returns Array, the duplicates found. Empty array if none found.
float, the random number.
Duik.js.arrayRemoveDuplicates
Duik.js.arrayIndexOf (array)
(array, value) Removes the duplicates from the array, and returns them
Gets the index of the value in the array, -1 if the value is
not found. parameters:
The values must be able to be compared using =. array | Array, the array
parameters: returns
array | Array, the array Array, the duplicates found. Empty array if none found.
value | Object, the value to search
returns
integer, the index of the value, -1 if not found
Duik.js.arrayHasDuplicates
(array)
Checks if the array contains duplicates
parameters:
array | Array, the array
returns
boolean
PSEUDO
DUIK.UTILS
EFFECTS
LIST
Lo
Some useful methods.
Duik.utils Methods
Duik.utils.prepareProperty(property,isFX,index,depth,parentName) Duik.utils.prepIK(layers)
Duik.utils.getPropertyDimensions(property) Duik.utils.getControllers(layers)
Duik.utils.getLength(value1,value2) Duik.utils.getAverageSpeeds(layers)
Duik.utils.getAverageSpeed(layer,property) Duik.utils.replaceInExpressions(prop,oldString,newString)
Duik.utils.addPseudoEffect(layer,pseudoEffectName) Duik.utils.replaceInLayersExpressions(layers, oldString, newString)
Duik.utils.getPuppetPins(effects) Duik.utils.renameLayer(layer, newName, updateExpressions,currentCompOnly)
Duik.utils.getDistance(layer1,layer2) Duik.utils.renameItem(item, newName, updateExpressions)
Duik.utils.rigProperty(layer,prop,pseudoEffect) Duik.utils.layersHaveSelectedKeys(layers)
Duik.utils.deselectLayers() Duik.utils.renameEffect(effect,name)
Duik.utils.checkNames(comp) Duik.utils.getFootageExposure(layer, accuracy, tolerance, r, g, b, a)
Duik.utils.getItem(items, itemIndex) Duik.utils.addEffect(layer,effectMatchName)
Duik.utils.getKey(prop, keyIndex) Duik.utils.getLayerByName(layers, name)
Duik.utils.getPropertyAnims(prop, selectedKeysOnly, startTime, endTime) Duik.utils.getLayerByNames(layers, names)
Duik.utils.getPropertyAnim(prop, selectedKeysOnly, startTime, endTime) Duik.utils.getLayersByName(layers, name)
Duik.utils.setPropertyAnim(prop, propAnim, startTime) Duik.utils.getLayersByNames(layers, names)
Duik.utils.addKey(prop,key, startTime) Duik.utils.sortByDistance(layers, from)
Duik.utils.getFirstKeyTime(prop) Duik.utils.getWorldPos(layer)
Duik.utils.hasSelectedKeys(prop) Duik.utils.sortLayersByIndex(layers)
Duik.utils.convertCollectionToArray(collection)
Gets the length between the values, whichever float, length between
getLength(value1, value2)
dimensions they are the values
Gets the average speed of the animated property, float, average speed of
getAverageSpeed(layer, property)
between its first and last keyframe only the property
integer, distance
getDistance(layer1,layer2) Measure distance between two layers
between layers, in pixels
rigProperty(layer, prop, Performs some checks on the property and adds Property, the effect
pseudoEffect) a pseudo effect on the layer added
Checks for duplicate names among the layers true if any layer was
checkNames(comp)
of the comp, renaming them if found. renamed
getKey(prop, keyIndex) Gets the keyframe at keyIndex on the property KeyFrame object
getPropertyAnim(prop,
selectedKeysOnly, startTime, Gets the keyframe animation of the Property PropertyAnim object
endTime)
renameLayer(layer, newName,
Renames the layer, updating expressions
updateExpressions, void
in all the compositions of the project
currentCompOnly)
Renames the effect, making sure there are not two effects
renameEffect(effect,name) void
that share the same name on the layer
getFootageExposure(layer, accuracy,
Gets the animation exposure of the footage Array of float
tolerance, r, g, b, a)
addEffect(layer, effectMatchName) Adds a pseudo effect from Duik on the layer Property
getLayerByName(layers, name) Gets the first layer which name contains the given name Layer
Gets the first layer which name contains one of the given
getLayerByNames(layrs, names) Layer
names
Gets all the layer which names contain one of the given
getLayersByName(layers, name) Array of Layer
names
Gets all the layers which names contain one of the given
getLayersByNames(layrs, names) Array of Layer
names
Duik.utils.prepareProperty Duik.utils.addPseudoEffect
(property,isFX,index,depth,parentName) (layer, pseudoEffectFileName)
Prepare the given property to be rigged. Adds a Duik predefined pseudo effect to the layer. The
isFX, index, depth, parentName will be filled by the AFX preset file of the pseudo effect must be located in
method with the values corresponding to this property. the same folder as libDuik.jsxinc and called Duik_ +
pseudoEffectName + .ffx.
parameters: In the preset, the effect must be called
property | Property pseudoEffectName.
isFX | boolean
index | integer parameters:
depth | integer layer | AVLayer
parentName | string pseudoEffectFileName | string, name of the file of the
pseudo effect
returns
true if property can set expression, false otherwise returns
Property, the effect added
Duik.utils.getPropertyDimensions
(property) Duik.utils.getDistance
Gets the dimensions of the property (1, 2 or 3), taking (layer1,layer2)
care of 2D layer positions (reported as 3D by AFX, but to Measures distance between two layers, in pixels.
be considdered as 2D)
parameters:
parameters: layer1 | AVLayer
property | Property layer2 | AVLayer
returns returns
integer, number of dimensions integer, distance in pixels
Duik.utils.getLength Duik.utils.getPuppetPins
(value1, value2) (effects)
Gets the length between the values, whichever dimensions Recursive method to find all puppet pins on a given layer,
they are even if there is more than one puppet effect.You must
provide the effects PropertyGroup of the layer.
parameters: Example: var pins = Duik.utils.getPuppetPins(app.
value1 | float or Array of float, first coordinates project.activeItem.layer(1)(Effects);
value1 | float or Array of float, second coordinates
parameters:
returns effects | PropertyGroup, the effects group of a layer
float, length between the values
returns
Array of Property, the puppet pins
Duik.utils.getAverageSpeed
(layer, property)
Gets the average speed of the animated property, between Duik.utils.rigProperty
its first and last keyframe only. (layer, prop, pseudoEffect)
Performs some checks on the property and adds a pseudo
parameters: effect on the layer.
layer | AVLayer of the property The AE preset file of the pseudo effect must be located in
property | Property the same folder as libDuik.jsxinc and called Duik_ +
pseudoEffectName + .ffx.
returns In the preset, the effect must be called pseudoEffectName.
float, average speed of the property
parameters:
layer | AVLayer
prop | Property
pseudoEffect | file name of the pseudo effect
returns
PropertyGroup, the effect added
DUIK.UTILS 47
Duik.utils.deselectLayers Duik.utils.getItem
() (items, itemIndex)
Deselects all layers After effects sometimes uses its own Collection class,
which is very similar to Arrays, but the first element of a
returns Collection is at index 1 instead of 0 as in an Array.
void This can make it difficult to write functions which will
work both on Array or Collections.
Duik.utils.checkNames Example:
(comp)
Checks for duplicate names among the layers function doSomethingOnLayers(layers) {
of the comp, renaming them if found. This method is for (i = 0 ; i < layers.length ; i++) {
called everytime libDuik creates an effect which involves var layer = layers[i];
expressions and more than one layer, to avoid any bug //do something
with expressions linking to wrong layers. }
}
parameters:
comp | CompItem where are the layers which //will work correctly, as selectedLayers is an Array
must be checked. Default: app.project.activeItem beginning at index 0
doSomethingOnLayers(app.project.activeItem.
returns selectedLayers);
true if any layer was renamed, false otherwise.
//will not work, as layers is a LayerCollection
beginning at index 1
doSomethingOnLayers(app.project.activeItem.layers);
function doSomethingOnLayers(layers) {
for (i = 0 ; i < layers.length ; i++) {
var layer = Duik.utils.
getItem(layers,i);
//do something
}
}
parameters:
items | Array or Collection
itemIndex | int, index where the item must be found
returns
Object, the item at itemIndex in items.
Duik.utils.getKey Duik.utils.addKey
(prop, keyIndex) (prop,key, startTime)
Gets the keyframe at keyIndex on the property Adds a keyframe on the property.You can offset the time
see KeyFrame object by setting startTime
see KeyFrame object
parameters:
prop | Property parameters:
keyIndex | int prop | PropertyBase
key | KeyFrame object
returns startTime | float, default: 0
KeyFrame object
returns
void
Duik.utils.getPropertyAnims
(prop, selectedKeysOnly, startTime, endTime)
Gets the keyframe animations on the child properties Duik.utils.getFirstKeyTime
of the prop, if its a PropertyGroup (recursive), or the (prop)
animation of the prop if its a Property, beginning at Gets the time of the first key on the property.
startTime and ending at endTime.
This is a recursive method. parameters:
see PropertyAnim object prop | Property
parameters: returns
prop | PropertyBase float
selectedKeysOnly | boolean
startTime | float
endTime | float Duik.utils.hasSelectedKeys
(prop)
returns Checks if the properties has keyframes which are selected.
Array of PropertyAnim objects
parameters:
prop | Property
Duik.utils.getPropertyAnim
(prop, selectedKeysOnly, startTime, endTime) returns
Gets the keyframe animation of the Property boolean
This is not a recursive method (it wont check child
properties); see Duik.utils.getPropertyAnims() for the
recursive method. Duik.utils.convertCollectionToArray
see PropertyAnim object (collection)
Converts the given Collection to an array. If the
parameters: parameter is already an Array, returns a copy of it.
prop | Property
selectedKeysOnly | boolean parameters:
startTime | float collection | Collection or Array
endTime | float
returns
returns Array
PropertyAnim object
Duik.utils.setPropertyAnim
(prop, propAnim, startTime)
Sets the animation on the property, beginning at
startTime
see PropertyAnim object
parameters:
prop | PropertyBase
propAnim | PropertyAnim object
startTime | float
returns
boolean, true if succeeded.
DUIK.UTILS 49
Duik.utils.prepIK Duik.utils.renameLayer
(layers) (layer, newName, updateExpressions,
Creates an IKRig object, automatically detecting each layer currentCompOnly)
usage. Renames the layer, updating expressions in all the
The detection checks the hierarchy of the layers to find compositions of the project.
each layer usage.
If the detection fails, the IKRig object is created using the parameters
order of the layers in the Array or LayerCollection: the layer | Layer
first are the layers, beginning by the last child, the last one newName | string
is the controller. updateExpressions | boolean, default: true
Goal layers are detected by measuring the distance currentCompOnly | boolean, default: false
between the last child of the chain and the controller: goal
layers and controllers should be at the same place. returns
See IKRig object. void
parameters:
layers | Array of AVLayers or LayerCollection Duik.utils.renameItem
(item, newName, updateExpressions)
returns Renames the item, updating expressions in all the
IKRig object compositions of the project if the item is a CompItem
parameters
item | Item
Duik.utils.getControllers newName | string
(layers) updateExpressions | boolean, default: true
Gets the controllers created by Duik found in the Array or
LayerCollection. If the Array or the LayerCollection are returns
empty, or if not provided, gets the controllers found in void
the active comp.
See Controller object.
Duik.utils.layersHaveSelectedKeys
parameters: (layers)
layers | Array of AVLayers or LayerCollection Checks if there are selected animation keyframes on the
layers.
returns
Array of Controller objects parameters
layers | Array of Layers or LayerCollection
Duik.utils.getAverageSpeed returns
(layer, property) boolean
Gets the average speed of the animated property, between
its first and last keyframe only.
Duik.utils.renameEffect
parameters: (effect,name)
layer | AVLayer of the property Renames the effect, making sure there are not two
property | Property effects that share the same name on the layer.
returns parameters
float, average speed of the property effect | PropertyGroup
name | String
Duik.utils.replaceInLayersExpressions returns
(layers, oldString, newString) void
Replaces all occurences of oldString by newString in all
the expressions of all the layers.
parameters
layers | Array of AVLayers or LayerCollection
oldString | string
newString | string
returns
void
parameters parameters
layer | AVLayer layers | Array of Layer or LayerCollection
accuracy | float from 0.0 to 100.0, default: 50 name | string
tolerance | float from 0.0 to 100.0, default: 10
r | boolean, default: true returns
g | boolean, default: true Array of Layer
b | boolean, default: true
a | boolean, default: false
Duik.utils. getLayersByNames
returns (layrs, names)
Array of float, the times when the animation changes Gets all the layers which names contain one of the given
names
Duik.utils.stepSelectedProperties parameters
(layers) layers | Array of Layer or LayerCollection
Changes the keyframes of the selected properties to names | Array of string
hold.
returns
parameters Array of Layer
layers | Array of Layers or LayerCollection
returns Duik.utils.sortByDistance
void (layers, from)
Sorts and returns the Array of layers depending on their
distance from a given layer
Duik.utils.addEffect
(layer, effectMatchName) parameters
Adds a pseudo effect from Duik on the layer layers | Array of Layer or LayerCollection
from | Layer
parameters
layer | AVLayer returns
effectMatchName | string Array of Layer
returns
Property, the effect added Duik.utils.getWorldPos
(layer)
Gets the world position of the layer
Duik.utils.getLayerByName
(layers, name) parameters
Gets the first layer which name contains the given name layer | Layer
parameters returns
layers | Array of Layer or LayerCollection Arary of float, [X,Y,Z]
name | string
returns Duik.utils.sortLayersByIndex
Layer (layers)
Sorts the layers in the Array or Collection according to
their index.
Duik.utils.getLayerByNames
(layrs, names) parameters
Gets the first layer which name contains one of the given layers | Array of Layer or LayerCollection
names
returns
parameters Arary of Layer
layers | Array of Layer or LayerCollection
names | Array of string
returns
Layer
DUIK.UTILS 51
Duik.utils.hexColorToRVB
(hexColor, isString)
Converts hexadecimal color to RVB Array.
parameters
hexColor | string or hex
isString | true if hexColor is a string, false of it is hex
number
returns
Array of float [R,V,B]
Duik.utils.rvbColorToHex
(rvbColor)
Converts RVB array to hex string, without a leading #
parameters
rvbColor | Array of float [R,V,B]
returns
string
DUIK.AUTORIG
This is the object used to automatically rig a lot of different animals.
All methods are available in their corresponding objects, but there are aliases to make them easier to use.
Example:
Duik.autorig.vertebrate.digitigrade
is equivalent to:
Duik.autorig.digitigrade
All methods are used the same way: you only have to provide the needed and optionnal layers (the anchor points
must be correctly placed); the methods return the Controller objects created.
In this documentation, needed layers are shown bold, other layers are optionnal and can be undefined or null.
Duik.autorig.vertebrate
Spine and neck are Arrays of Layers. The order must be: tail is an Array of Layers. The order must be: from the
from the head to the hips. end to the hips.
Duik.autorig.vertebrate.plantigrade
Alias: Duik.autorig.plantigrade
Duik.autorig.vertebrate.digitigrade
Alias: Duik.autorig.digitigrade
Duik.autorig.vertebrate.ungulate
Alias: Duik.autorig.ungulate