Expression Tips
This page introduces practical expressions for Nexanim, organized by use case.
For Progress Controls
Change the referenced effect and layer names to match your project.
Offset Start Timing with a Single Key
Keep the easing unchanged and shift only the timing, using the first key as the start point.
sourceP = effect("P:位置-トランスフ-1Position-Trans-1_1")(1); offset = sourceP.key(1).time - key(1).time;sourceP.valueAtTime(time + offset);Stretch or Compress Animation with Two Keys
Keep the easing unchanged and use two keys to define the start and end points, then stretch or compress the entire animation.
sourceP = effect("P:位置-トランスフ-1Position-Trans-1_1")(1); mappedTime = linear(time, key(1).time, key(2).time, sourceP.key(1).time, sourceP.key(sourceP.numKeys).time);sourceP.valueAtTime(mappedTime);Stretch or Compress Animation to Layer Duration
Keep the easing unchanged and stretch or compress the entire animation to match the layer duration.
sourceP = thisComp.layer("ctrl").effect("P:位置-トランスフ-1Position-Trans-1_1")(1); mappedTime = linear(time, thisLayer.inPoint, thisLayer.outPoint, sourceP.key(1).time, sourceP.key(sourceP.numKeys).time);sourceP.valueAtTime(mappedTime);Automatically Reference by Trailing Number
Automatically references a specific Progress Control P that has the same trailing number.
sourceP = effect("P:位置-トランスフ-1Position-Trans-1_1")(1); sourcePControlId = sourceP.propertyGroup(1).name.replace(/^P:/, "").replace(/_\d+$/, "");indexNum = thisProperty.propertyGroup(1).name.match(/_(\d+)$/)[1];sourceP = effect("P:" + sourcePControlId + "_" + indexNum)(1);sourceP;For Value Controls
Link Y and Z to X
This expression is mainly useful for Scale and applies the X value to Y and Z as well.
[value[0], value[0], value[0]];Last updated on