ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Opacity control from data in .json

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Gary Sweeney
Opacity control from data in .json
on Mar 11, 2019 at 11:40:04 am

I'm looking for a way to have an image at 100% opacity if the data in the .json says the name of the image so something like this...


input = footage("datafile.json").sourceData[46].NAMES;

if (input=thisLayer.name){value = 100}
else {0};


So the " [46].NAMES " part looks for the name of the person in the .json and that works fine.
(I can get it to say the name in a text layer)

I just don't know how to get the opacity of the image to be 100 if it says the name and 0 if it doesn't.
I'm sure this is probably basic put any help is greatly appreciated.


Return to posts index

Dan Ebberts
Re: Opacity control from data in .json
on Mar 11, 2019 at 2:11:35 pm

I haven't tested this, but give it a try:

input = footage("datafile.json").sourceData[46].NAMES;
(input == name) ? 100 : 0


Dan



Return to posts index

Gary Sweeney
Re: Opacity control from data in .json
on Mar 12, 2019 at 12:26:17 pm

Hi Dan,

Yes that works perfectly, really appreciate the help! I have another question if you have the time.

I want to position the same image layer in a specific position depending on the data.
I've put the code in below and it's not having it when I had the 'else if' lines in but will work with just the if line & the else line at the end.


input = footage("datafile.json").sourceData[46].CITY;

if (input == “London”){[625.5,100.75]}
else if (input == “Dublin”){[625.5,200.75]}
else if (input == “Glasgow”){[625.5,300.75]}
else if (input == “Cardiff”){[625.5,400.75]}
else if (input == “Belfast”){[625.5,500.75]}
else {[0,0]};


Thanks
Gary

PS - Also what do you recommend is the best way forward in terms of learning all there is to know about this?

input = footage("datafile.json").sourceData[46].CITY;

if (input == “London”){[625.5,100.75]}
else if (input == “Dublin”){[625.5,200.75]}
else if (input == “Glasgow”){[625.5,300.75]}
else if (input == “Cardiff”){[625.5,400.75]}
else if (input == “Belfast”){[625.5,500.75]}
else {[0,0]};


Return to posts index


Dan Ebberts
Re: Opacity control from data in .json
on Mar 12, 2019 at 12:59:06 pm

You're using curly quotes around your city names, use straight quotes instead.

Dan



Return to posts index

Gary Sweeney
Re: Opacity control from data in .json
on Mar 12, 2019 at 2:00:42 pm

Thanks again Dan, I'm an idiot.

The next issue I have is I've ended up with 2 or more images overlapping each other.
You don't know of a way the images can be offset if they happen to be in the same location?


Return to posts index

Dan Ebberts
Re: Opacity control from data in .json
on Mar 12, 2019 at 4:56:41 pm

It might be a little tricky, and depends a lot on how you have things set up, but rather than have the expression for each image's position have to keep track of all the other images, you might want to move all that logic to an invisible text layer that, based on the json data, calculates where everybody should be and then publishes a list. Then each image has a position expression that gets its position from the list. Something like that.


Dan



Return to posts index


Gary Sweeney
Re: Opacity control from data in .json
on Mar 13, 2019 at 10:32:43 am

That sounds exactly what I need Dan.




(The error message is only down to not having the json loaded on this screenshot, it does work)

My set up is shown in the images above, I have a main project showing a map and then 3 projects overlaying within it.
In the project folders are the person's heads which will move to the locations depending on the data.
So there are times where different people will be in the same location but in different projects.
The text layer at the top of the project is an invisible text layer that references the row in my json file required.

What would be the way to put everything in an invisible text layer, calculate where everybody should be and then publish a list?
I also assume this way would speed up the preview speed as it is very very slow at the minute.

Gary


Return to posts index

Scott McGee
Re: Opacity control from data in .json
on Mar 11, 2019 at 2:11:36 pm

Try below if the input is working. Looks like you're missing an =. should be ==

input = footage("datafile.json").sourceData[46].NAMES;

if (input == thisLayer.name){value = 100}
else {0};


Return to posts index

Gary Sweeney
Re: Opacity control from data in .json
on Mar 12, 2019 at 12:29:00 pm

Thanks Scott, this also works perfectly too.

If you also have time for the other question I asked Dan above it would be appreciated.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]