通过在后的效果的JavaScript改变组合物层的持续时间

问题描述 投票:0回答:1

有谁能够帮助我?我想写使用后效果Extendscript CC的脚本。我想由JavaScript改变层的持续时间的组合物。我在这里写了这个代码

app.project.item(1).layer(1)。长度= 12;

要么

app.project.item(1).layer(1).duration = 12;

但它没有工作。我该怎么做?谢谢。

javascript scripting extendscript after-effects
1个回答
2
投票

事情并不那么容易。像固体层不必你可以设置一个时间。但是你可以设置自己inPointoutPoint。像其他的补偿层需要从源头改变。请参阅下面如何做到这一点的代码。

function main(){
// do some checking if we have a comp and a layer selected
var curComp = app.project.activeItem;
  if (!curComp || !(curComp instanceof CompItem)) {
    // alert and end the script
    alert("please select a composition and at least a layer");
    return;
  }
var durationValue = 1; // the desired value in seconds
var selectedLayer = curComp.selectedLayers[0]; 

// if the layer has source layers it is a comp
// so we change its source duration
// else 
// we have layers like solids or lights. They have no source and no layers in them
// so we change their outPoint 

if (selectedLayer.source.numLayers != null){
    $.writeln('we have a comp');
    selectedLayer.source.duration = durationValue;
  } else {
    $.writeln('we have a layer');
    selectedLayer.outPoint =   selectedLayer.inPoint + durationValue;
  }
}
main();
© www.soinside.com 2019 - 2024. All rights reserved.