在extendscript中移动关键帧时间

我想将图层上某些关键帧的时间更改为x秒/帧。在Extendsript文档中,有一个function用于设置关键帧的值,但是找不到用于设置关键帧时间的

我不想修改图层的入/出点,这将仅需要对选定的键进行操作,因此仅移动图层并不能完全解决此问题。

ccc_crazy_2000 回答:在extendscript中移动关键帧时间

After Effects API中没有实际的关键帧对象。只有属性,还有许多方法来获取有关这些属性的关键帧的信息。对于所有与关键帧有关的程序,这似乎……就像Adobe 将要所做的那样。

因此,您要做的是复制要移动的关键点的所有属性,例如时间缓和度,空间切线等,然后使用这些属性创建一个新关键点,然后删除原始关键点(可以也是一个陷阱,因为如果您在旧密钥之前插入了新密钥,则其索引将发生更改。我编写了一个函数来执行此操作,您可以找到here,可以随意进行分叉和改进。

我想我是否会更好地使用JS,我会设置为关键帧对象。

,

我最终做了这件事,因为我想了解如何使用键盘热键将所有选定的关键帧移到播放头。 我找不到如何模拟鼠标单击和拖动的方式(如果有人知道,因为这可能更琐碎...),但是我最终制作了一个脚本,该脚本首先记录所有关键帧,然后删除所有关键帧,然后替换它们以移位的值。

是的,确实需要制作一个“关键帧”对象并将其存储到数组中。 shiftKeyFrames的顺序将假定您以左右顺序将关键帧记录到数组中。

var records = arrayOfkeyFrameObjects;

function shiftKeyFrames(records,dif){//shifts keyFrames by dif     

    for(i= records.length - 1; i >= 0 ; i--){ //Remove original keyframes.
        records[i].property.removeKey(records[i].index);
    }

    for(i=0; i < records.length;i++){ 
        records[i].replacementIndex = records[i].property.addKey(roundFrame(records[i].time+dif)); //Adds a keyframe with the time difference,rounded to the nearest frame,and stores the replacement index.
        records[i].property.setValueAtKey(records[i].replacementIndex,records[i].value); //Sets the value of the new keyFrame
    }

    for(i=0; i < records.length;i++){
        records[i].property.setSelectedAtKey(records[i].replacementIndex,true); //Re-selects all the created keyframes.
    }
}

function roundFrame(time){
    return Math.round(comp.frameRate*time)/comp.frameRate;
}

function keyFrame(property,index){
    this.property = property;
    this.index = index;
    this.time = property.keyTime(index);
    this.value = property.keyValue(index);
    this.replacementIndex;
}
}());
本文链接:https://www.f2er.com/2424540.html

大家都在问