Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Time Remap script for markers not working on certain comps

Community Beginner ,
Feb 03, 2025 Feb 03, 2025

Hi there.

I have this script saved as an animation preset. This one works perfectly on certain compositions, but not all.

What I did was selected the time remap add a keyframe, paste the script. Save the preset.

As mentioned on most compositions it works, on others it doesnt.
When it doesn't i have to manually enable time remap and paste the exact same script. Then it works.
Feels odd, and I do not know what I am doing wrong here.

var numMarkers = thisComp.marker.numKeys;
var finalValue = value; // Default value if no markers are found

if (numMarkers >= 2) {
    var markerInTime = null;
    var markerOutTime = null;

    // Find the first "IN" and "OUT" markers
    for (var i = 1; i <= numMarkers; i++) {
        var markerComment = thisComp.marker.key(i).comment;
        var markerTime = thisComp.marker.key(i).time;

        if (markerComment == "IN" && markerInTime == null) {
            markerInTime = markerTime;
        } else if (markerComment == "OUT" && markerOutTime == null) {
            markerOutTime = markerTime;
        }

        if (markerInTime != null && markerOutTime != null) {
            break; // Stop once both are found
        }
    }

    // Ensure both markers exist
    if (markerInTime != null && markerOutTime != null) {
        var animationDuration = markerOutTime - markerInTime;
        var relativeTime = time - markerInTime;

        // Apply time-based transformation within the marker range
        if (time >= markerInTime && time <= markerOutTime) {
            finalValue = thisProperty.valueAtTime(markerInTime + relativeTime);
        } else if (time > markerOutTime) {
            finalValue = thisProperty.valueAtTime(markerOutTime); // Hold at OUT value
        }
    }
}

finalValue;

 

TOPICS
Expressions
317
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2025 Feb 03, 2025

When it doesn't work, does it do anything at all? Do you always have a just single precojmp layer selected when you try to apply the preset?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 03, 2025 Feb 03, 2025

Hi Dan, Thanks for willing to help.

Yes I make sure to only have one layer selected when assigning the preset.
When it doesnt work, it does nothing "actively" However: it does enable the time remap and adds the script as I did in the preset upon saving. it does nothing.

I have tested this with serveral small comps, complex animations, simple animations.
Sometimes it works, most often it doesnt.

As a workaround:
So as I mention, i copy the exact script found in the expression which was placed via the preset.
Remove all the keyframes and time remap.
Create a new time remap →  paste the code i just copied.
It works...

So for now I have a mac textexander shortcut "atr" and I manually set the time remap via cmd shift t , alt click the stopwatch and type atr which expands my expressions. Everything works then.

Pretty weird.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2025 Feb 04, 2025
LATEST

So it applies the expression, but the expression does nothing? There is a path through the code that does nothing, if either the "IN" or "OUT" marker is missing (or the comments are not spelled exactly that way). But if something like that were happening, it wouldn't be fixed by applying the expression by hand. I'm stumped.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines