Set Marker Duration

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
jordanwade33
Posts: 16
Joined: December 8th, 2014, 11:11 pm

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);
User avatar
zlovatt
Posts: 47
Joined: October 31st, 2016, 5:00 pm
Location: Portland
Contact:

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.
jordanwade33
Posts: 16
Joined: December 8th, 2014, 11:11 pm

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)
User avatar
conigs
Posts: 3
Joined: November 4th, 2016, 11:01 am
Contact:

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);
Post Reply