Expressions/Scripts/Presets

Moderator: Paul Tuersley

 
jordanwade33
Topic Author
Posts: 13
Joined: Mon Dec 08, 2014 11:11 pm

Set Marker Duration

Tue Nov 08, 2016 7:30 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.

var myComp = app.project.activeItem;
var marker = myComp.layer(1).Marker.keyValue(1);
marker.duration = 20;
alert(marker.duration);
 
User avatar
zlovatt
Posts: 15
Joined: Mon Oct 31, 2016 5:00 pm
Location: Los Angeles
Contact:

Re: Set Marker Duration

Wed Nov 09, 2016 6:02 am

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
Topic Author
Posts: 13
Joined: Mon Dec 08, 2014 11:11 pm

Re: Set Marker Duration

Wed Nov 09, 2016 1:45 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:
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: Fri Nov 04, 2016 11:01 am
Contact:

Re: Set Marker Duration

Wed Nov 09, 2016 1:53 pm

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 
myComp.layer(1).Marker.setValueAtKey(1,marker);

Who is online

Users browsing this forum: No registered users and 3 guests