Skip to main content
Inspiring
March 29, 2024
Answered

How to Modify the startTime of Precompose Using Script

  • March 29, 2024
  • 1 reply
  • 503 views

Because the script command precompose() does not have a corresponding syntax to manually precomp the option checkbox called ‘Adjust composition duration to the time span of the selected layers’, I manually specified the start and end times. However, I found that

var start = 30;
var end  = 60 ;
var preComp = app.project.activeItem.layers.precompose([layer.index], layer.name,true);
preComp.startTime = start;
preComp.duration = end - start;

These lines have been executed successfully, but the start time of the precomp is still at time 0 on the timeline. What’s going on?

 

This topic has been closed for replies.
Correct answer Airweb_AE

try this:

var proj = app.project;
var thisComp = proj.activeItem;

var layer = thisComp.layer(1);
var idx = layer.index;

var start = 30;
var end = 60;
var preComp = thisComp.layers.precompose([idx], layer.name, true);
thisComp.layer(idx).startTime = start;
preComp.duration = end - start;

1 reply

Airweb_AECorrect answer
Legend
March 29, 2024

try this:

var proj = app.project;
var thisComp = proj.activeItem;

var layer = thisComp.layer(1);
var idx = layer.index;

var start = 30;
var end = 60;
var preComp = thisComp.layers.precompose([idx], layer.name, true);
thisComp.layer(idx).startTime = start;
preComp.duration = end - start;
Inspiring
March 29, 2024

it work ! but why ? 🤔 🤔

Legend
March 29, 2024

idk, maybe because:

app.project.item(index).layers.precompose(layerIndicies, name[, moveAllAttributes])

returns a compItem object and it's not really a layer object