Page 1 of 1

Set Marker Duration

Posted: November 8th, 2016, 7:30 pm
by jordanwade33
Is it possible to set the duration of a marker via a script? It appears so via the scripting guide, but I can't actually get it to work. Does anyone have experience with this?

A basic example. A comp, with one layer, with one marker. The alert returns the correct value of the marker, but if you look at the marker on the timeline or double click it, the duration doesn't actually change.

Code: Select all

var myComp = app.project.activeItem;
var marker = myComp.layer(1).Marker.keyValue(1);
marker.duration = 20;
alert(marker.duration);

Re: Set Marker Duration

Posted: November 9th, 2016, 6:02 am
by zlovatt
Note that this feature was only added in AE 14.0 -- there's an example code block here that shows how you can do it.

Re: Set Marker Duration

Posted: November 9th, 2016, 1:45 pm
by jordanwade33
Thanks for the quick response! That example code block was able to solve my problem, though not only restricted to AE 14.0. Access to comp markers is new to AE 14.0 but not to layer markers as I was looking for.

The solution to my problem is that I should set the duration of the marker before the script adds the marker to the layer. A simple answer that I never thought of.

A revision to my basic example that sets duration properly:

Code: Select all

var myComp = app.project.activeItem;
var marker = new MarkerValue("Test Marker");
marker.duration = 20;
myComp.layer(1).Marker.setValueAtTime(2, marker)

Re: Set Marker Duration

Posted: November 9th, 2016, 1:53 pm
by conigs
Yeah, the weird thing about markers is you can make any changes to the marker value object you want… but it doesn’t take effect until it’s set back on the layer.

If you’re dealing with a pre-existing marker, you can make due with your original code, but then adding 

Code: Select all

myComp.layer(1).Marker.setValueAtKey(1,marker);