Activity › Forums › Adobe After Effects Expressions › Connecting Two Keyframes To Start And End Point of Workspace
-
Connecting Two Keyframes To Start And End Point of Workspace
Posted by Kamiar Babaei on February 6, 2022 at 4:58 pmIs it possible by any chance?
Kamiar Babaei replied 4 years, 7 months ago 2 Members · 4 Replies -
4 Replies
-
Dan Ebberts
February 6, 2022 at 6:48 pmDo you mean the work area? Expressions don’t have access to the work area start and end times. Scripting does, so you could do it with a script, but it wouldn’t adjust automatically when you change the work area.
-
Kamiar Babaei
February 6, 2022 at 7:00 pmYes, work area,
Than maybe the script can have a refresh button for when I want to update it to the new work area length?
-
Dan Ebberts
February 6, 2022 at 7:54 pmIt could, but that would require a UI for the script, which is a bit of work. Here’s how the basic functionality might look though:
function setKF(){
var myComp = app.project.activeItem;
if (! (myComp && (myComp instanceof CompItem))){
alert("No comp active.");
return;
}
var myProps = myComp.selectedProperties;
if (myProps.length == 0){
alert("No property selected.");
return;
}
var myProp = null;
for (var i = 0; i < myProps.length; i++){
if (myProps[i].numKeys >= 2){
myProp = myProps[i];
break;
}
}
if (myProp == null){
alert ("No property with 2 or more keyframes selected.");
return;
}
var tStart = myComp.workAreaStart;
var tEnd = tStart + myComp.workAreaDuration;
var myExpr = "t = linear(time," + tStart + "," + tEnd + ",key(1).time,key(numKeys).time);\rvalueAtTime(t)";
myProp.expression = myExpr;
}
setKF();
Reply to this Discussion! Login or Sign Up