任何人都可以帮助我吗? 我正在尝试使用Extendscript为后效CC编写脚本。 我希望通过javascript更改合成中图层的持续时间。 我在这里写了这段代码
app.project.item(1).layer(1).length = 12;
或
app.project.item(1).layer(1).duration = 12;
但它不起作用。 我该怎么做? 感谢。
答案 0 :(得分:2)
事情并不那么容易。像Solids这样的图层没有您可以设置的持续时间。但您可以设置inPoint
和outPoint
。像comp这样的其他层需要在源头进行更改。请参阅下面的代码,了解如何执行此操作。
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();