Create Counter that Increments By Marker

Moderators: Disciple, zlovatt

Post Reply
Posts: 2
Joined: November 4th, 2019, 10:56 am

November 4th, 2019, 7:46 pm

In AE I have a text layer with a starting value of "0" and an adjustment layer I've brought over from PPro that has the markers that I need to reference. I'm trying to create a counter by writing an expression that will increase by 1 the text layer value for each marker in the adjustment layer.

I've written several expressions for the text layer's Source Text property...

Code: Select all

...but none of them seem to work. I've tried:

Code: Select all

var marks = thisComp.marker;
for (var i; i <= marks.numKeys; i++){
	text.sourceText.valueAtTime(marks.key(i).time, (text.sourceText.value +1));
and another based on

Code: Select all

 while (x < thisComp.duration) {code to adjust text at each marker}
I'm new to AE scripting and expressions, but have dabbled in JavaScript and powershell and I have the docs for AE expressions and scripting available so this seems like it should be fairly simple yet I can't seem to figure this out. I'm not looking for a complete solution, just help on where I'm going wrong.

EDIT: To make things more frustrating, I can achieve the effect manually.
User avatar
Posts: 10
Joined: April 13th, 2019, 2:19 pm

November 9th, 2019, 6:13 pm

You're trying to make the text layer show the most recent marker index, so that whenever the time indicator passes a marker the text layer increments by one?

Code: Select all

let myMarkers = thisComp.layer("name of your marker layer").marker;
let n = myMarkers.nearestKey(time).index; // get index of the closest key in time
if (time < myMarkers.key(n).time) { n--; } // make sure n == most recent key index only
Posts: 2
Joined: November 4th, 2019, 10:56 am

November 10th, 2019, 4:04 pm

Apologies for taking so long to reply...I've been playing around with several options trying to figure out a solution. Unfortunately I don't think an expression will achieve what I'm looking for.

Given a PPro project with video footage and an audio track. The audio track contains a certain number of either a) audio clip 1 (AC1) or b) audio clip 2 (AC2). Both AC1 and AC2 have markers that indicate where a number should go up or down.

The end goal is a counter graphic...something that can be used in PPro...that increments/decrements depending on whether AC1 or AC2 is played. Also, the graphic must be able to be re-used in a new project with a different number of AC1 and AC2 clips.
  • I've written an AE script that will do this (increment/decrement) based on the PPro linked adjustment layer, and...
  • ...given an AE comp with a text layer and two AV layers with the two different audio clips... I can (almost) write an expression that will increment/decrement based on either one of the audio clips.
I don't know how to use either to create the end goal...or if it's even possible. Ideally it would be a mogrt that has properties for AC1 name and AC2 name that tell the counter when to increment and decrement.
Post Reply