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

values to keyframes from a json

Explorer ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

Hello everyone,

I generally work with json dataset inside after effects and by using linear expressions I am generally able to create animation between two values. This time around though I am facing a new challenge:

I have a slider with a number of keyframes, what I want is for my keyframes to match the value of my json file. so for example, my first keyframe should be exactly the value of the year 2017, my second key should be exactly the value of the year 2018...and so on and so forth. As i said, i could've used alinear expression to map two marker keys with the values coming from a dataset...but this doesn't apply in this context.

How would you tackle this challenge?

 

Thanks for reading and caring.

TOPICS
Expressions

Views

223

Translate

Translate

Report

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
LEGEND ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

LATEST

Could be as trivial as a for() loop combing through your columns and then doing a break when it hits the correct value, assuming the values are in the same row on your file. Something along those lines perhaps:

 

mData=thisComp.layer("XYZ").sourceData();

for (i=0;i<mData[0].length;i++)
{
if (mData.dataValue[1][i] == key(i).value)
{
mYear=mData[0].dataValue[i]
break
}
else
{
mYear=1999;
}}

 

I'm making this up on the fly, so no guarantees, but I think you get the idea what is supposed to do. You basically just compare the columns and match the index if you find a value. Depending on what you need to do you may also need to figure out the current keyframe with that key.nearestKey() stuff as illustrated e.g. here:

 

http://www.motionscript.com/design-guide/marker-sync.html

 

Mylenium

Votes

Translate

Translate

Report

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