Skip to main content
Known Participant
May 22, 2023
Question

Change a comp duration from an expression or script

  • May 22, 2023
  • 3 replies
  • 2852 views

Hi,

 

I would like to change the duration of a comp through an expresion (ideally) or a script. The duration would come from a text field within a comp within the AE project. 

 

I have been looking around but can't find a solution. Is it possible?

 

Or is there another way to achieve this? Like the comp duration could adjust to be the same length as a targeted piece of footage?

 

Many thanks,

 

Nick

This topic has been closed for replies.

3 replies

Nick5FF2Author
Known Participant
May 25, 2023

Thanks for the feedback. This script seems to be what I am looking for. I am just wondering if:

1. you can target a layer by name?

2. You can set the comp duration instead of the workAreaDuration?

 

Many thanks.

 

Nick

Nick5FF2Author
Known Participant
May 25, 2023

{

var theComp = app.project.activeItem;

var theLayer = theComp.selectedLayers[0];

theComp.workAreaStart = theLayer.inPoint;

theComp.workAreaDuration = theLayer.outPoint - theLayer.inPoint;

}

Adam24585301qycn
Inspiring
May 23, 2023

there is an expression that would keep the opening animation and the ending animation consistent and everything inbetweeen would be frozen, so it would not work if you had continual movement the whole duration of the precomp.

Dan Ebberts
Community Expert
Community Expert
May 22, 2023

You can't do it with an expression--expressions can only change the value of the property to which the expression has been applied. Basically, if you can't keyframe it, you can't change it with an expression.

You could change comp duration with a script, but it wouldn't be automatic--you'd have to run the script after you change the text field (or replace the footage).

Nick5FF2Author
Known Participant
May 22, 2023

It would be ok if it is after the text field is changed or the footage is updated. thanks !

 

Dan Ebberts
Community Expert
Community Expert
May 22, 2023

The script would very much depend on the specific details of your project, so it would be difficult to come up with something generic without knowing those details.