Activity › Forums › Adobe After Effects Expressions › Index/Time of a marker according to comment
-
Index/Time of a marker according to comment
Posted by Benoit Kergosien on July 1, 2014 at 10:28 pmHi folks,
I need a boost!I’m trying to animate a text layer with the source.text. I have markers on it and I want to access to their comments and mainly to their times.
The marker’s order isn’t final so I can’t use a simple marker’s index.
The idea would be to search the marker which comment is “Tokyo” and then retrieve its index to calculate its time.
Any help would be appreciate.
Benoit
Dan Ebberts replied 11 years, 10 months ago 2 Members · 14 Replies -
14 Replies
-
Dan Ebberts
July 1, 2014 at 10:58 pmI think it’s easier than you’re picturing it to be:
thisComp.layer(“Text Layer”).marker.key(“Tokyo”).time
Dan
-
Benoit Kergosien
July 2, 2014 at 9:32 pmWow… It was so obvious, I can’t believe that I didn’t try it!
Thank you Dan.In addition, I’ve got some trouble to give value to my markers referencing them with comments.
For example I want that my marker wich comment is “TOKYO” returns a value of 10, the value needs to be hold from the marker’s time until the next marker minus a delay. Then 10 goes linearly to the value returned by the next marker at the next marker’s time, and so on…
Do I need to put all the values associated to the comments in a array or such thing like that? For the changes between values I try some Conditionnal statements without success (only the first works).
Thanks for your help!
Benoit
-
Dan Ebberts
July 2, 2014 at 10:28 pmIf you know the value at the time you create the marker, you could put it in one of the marker’s parameters. For example, you could name the parameter “value” (without the quotes) and set the value to 10. You could then access the value like this:
parseFloat(marker.key(“Tokyo”).parameters[“value”])
Dan
Edit: fixed typo in description
-
Benoit Kergosien
July 2, 2014 at 11:27 pmHi Dan,
Thanks for your trick about parameters but I thought give the value on a slider control to be more flexible.
Furthermore
parseFloat(marker.key("Tokyo").parameters["value"])
returns a ” no property or method called ‘value’ ”
What’s wrong?Did you have a clue about the linear changes between values?
Thanks again.
Benoit
-
Dan Ebberts
July 2, 2014 at 11:51 pmYou may have missed my edit where I changed the name of the parameter from level to value.
Linear changes are pretty easy. In this case, you could set v1 to be the value of the first marker, t2 would be the time of the second marker and v2 would be its value, and r would be the ramp time.
you’d finish the expression with something like this:
linear(time,t2-r,t2,v1,v2)
Dan
-
Benoit Kergosien
July 3, 2014 at 12:50 amI didn’t miss your edit but it appears it isn’t working.
For linear changes I did the following:
v1=10;
TOKYO=thisComp.marker.key("TOKYO")
t1=TOKYO.time;
nextMarkerTOKYO=TOKYO.index+1;
v2=50;
t2=thisComp.marker.key(nextMarkerTOKYO).time;
delay=1;
linear(time,t1+delay,t2,v1,v2)it does the job for one linear change but to apply this to all my markers I need an expression which increment marker’s index and retreive value linked to comment (in an array?).
ex: marker TOKYO=10 , marker PARIS=50, marker LONDON = 25, etc…Tell me if you didn’t understand my process, it’s a bit tricky because markers’s order isn’t final.
Benoit
-
Dan Ebberts
July 3, 2014 at 2:38 amI think your expression needs to figure out which markers the current time is between. To do that, I’d first get the nearest marker using marker.nearestKey(time). If the time of that marker is less than the current time, then get the time of the next marker, otherwise get the previous marker (you do need to watch out for cases where there is no previous marker or no next marker). Then I guess, based on the the indexes of the two markers you could get their corresponding values out of an array. A bit of work to set up, but definitely do-able.
Dan
-
Benoit Kergosien
July 3, 2014 at 8:36 pmHi Dan,
I exploded my brains out and tried to follow your advices… unsuccessfully!
Here is the best I can do right now.
Please correct my mistakes!
Benoit
layerMarker=thisLayer.marker;
nextMarker="";
maxMarker=layerMarker.numKeys;
nearMarker= layerMarker.nearestKey(time).index;
nearMarkerTime=layerMarker.key(nearMarker).time;if (layerMarker.key(nearMarker)<=1 || time>= layerMarker.key(maxMarker));{
// I tried something to limit the search of markers who doesn't exist but I'm stuck as you can see.
}
else
{
if ( nearMarkerTime<time){
nextMarker=layerMarker.key(nearMarker+1);
}
else
{
nextMarker=layerMarker.key(nearMarker-1);
}
} -
Dan Ebberts
July 3, 2014 at 9:33 pmThis is something of an untested shell (there’s still a bunch of stuff you need to add). When you’re between two markers prev has the index of the previous marker and next has the index of the next marker:
m = marker;
prev = 0;
next = 0;if (m.numKeys > 1){
nearest = m.nearestKey(time);
if (nearest.time <= time){
prev = nearest.index;
if (prev < m.numKeys) next = prev+1;
}else{
next = nearest.index;
if (next > 1) prev = next-1;
}
if (prev != 0 && next != 0){
// in between two markers -- do whatever you need to do here
}else{
// only have 1 marker -- add some code to deal with that
}
}else{ // no markers
value;
}
Dan
-
Benoit Kergosien
July 4, 2014 at 7:30 pmThank you so much for your patience Dan.
I will try to complete the code during the weekend.
Wish me good luck!Benoit
Reply to this Discussion! Login or Sign Up