After Effects Expressions 405 - External Code & JSON

Поділитися
Вставка
  • Опубліковано 23 лис 2024

КОМЕНТАРІ • 88

  • @anywheredesign3710
    @anywheredesign3710 3 роки тому +7

    Hello there! The evalFile method as you present it seems not to work anymore (since Ae 2019 version I think) 🤔
    The best alternative I found so far is to create a .jsx file, write down your code, import your document into Ae and write "eval(footage("yourFileName.jsx").sourceText)" as an expression to have it working.
    I hope it will help someone in distress like I used to be 😉

    • @Animoplex
      @Animoplex  3 роки тому +1

      Just pinned this, thanks for the heads up and code example!

    • @polovnikvozmezdiya
      @polovnikvozmezdiya 2 роки тому +1

      No, it still works if you change Expressions Engine in File → Project Settings → Expressions to Legacy ExtendScript.
      But better to do like you said, yea

    • @anywheredesign3710
      @anywheredesign3710 2 роки тому

      ​@@polovnikvozmezdiya Yes, I'm working with the newest language :)
      Still, thanks for your help, I hope people shall benefit from it ^^

    • @levidewitt1823
      @levidewitt1823 2 роки тому

      ​@@polovnikvozmezdiya This works and you are amazing! However, I noticed that while changing the Expressions Engine fixes this expression, unfortunately, it can break other expressions in your project. The old system apparently uses a different syntax for various things; ex. in [value[0],value[1]] the "[0]" and the "[1]" are no longer valid syntax

    • @marinelouward843
      @marinelouward843 Рік тому

      None of your solutions is working for me... I use the 2023's version of AE. Can someone help ? Thanks

  • @juncando
    @juncando 3 місяці тому +1

    I learnt so much. Came here from Domestika.

  • @benjaminreynolds3659
    @benjaminreynolds3659 3 роки тому +3

    This is exactly what I was looking for. Bravo good sir!

    • @Animoplex
      @Animoplex  3 роки тому +1

      Glad to hear it! Thank you.

  • @nathitappan
    @nathitappan 7 місяців тому

    This whole series is so amazing! Thank you for taking the time to put this together.
    Quick question... how would you go about searching a match inside a json file, and outputting another value from that object as a result?
    Say, we have objects from 1 to 10, each has a player name and their current world ranking.
    If I wanted to find, amongst all data records, a matching player name and output its ranking to either a text layer or a slider control. Any idea? I assume we would use a for loop? But can't figure out how to iterate and reference other pairings inside the object's group.
    I hope that makes sense, lol.

  • @riccardofissore7996
    @riccardofissore7996 Рік тому +1

    Nice, all the tutorials and documentation I watched though stops when it comes to link a live date from the web and how to trigger and export in after effects when that data changes

    • @Animoplex
      @Animoplex  Рік тому

      That's a tough one. It can be done locally via external scripts that modify a local file, but you have to be careful since the value/file could change during a render. Scripting (not expressions) could access a live date from the web, but it would be a bit more work to set up.

  • @YahiaDesigner
    @YahiaDesigner 6 років тому +1

    I can't believe that this is free. This stuff is great, I will definitely consider purchasing your course.

    • @Animoplex
      @Animoplex  6 років тому +2

      This course is a gift to the motion design community. Can't tell you how many free tutorials and plugins have helped over the years. There's absolutely no obligation to purchase the extra content. All the proceeds from that will fund a possible new course in the future.

    • @YahiaDesigner
      @YahiaDesigner 6 років тому +1

      I truly appreciate what you're doing here. Clearly you are putting so much time and effort into making these tutorials as easy-to-follow as possible even for folks like me who are not even familiar with JSON for instance (Just learned how to work with it thanks to you :) ). You are a great gift to the community. Notification bell is on :D

    • @Animoplex
      @Animoplex  6 років тому +1

      Thank you for noticing the amount of work put in. Top priorities when creating this were clarity, ease of access, and making the content fun and relevant. Some things worked really well, other examples were less-strong but still hit the mark. Definitely learned a lot and plan to incorporate all the feedback and improvements on the next one. Reach out if you have any questions in the future.

  • @brownbichon1597
    @brownbichon1597 6 років тому +1

    Your tuts are pleasing, ths for the great work.

    • @Animoplex
      @Animoplex  6 років тому

      You're most welcome. More on the way!

  • @TutorielsdeHugo
    @TutorielsdeHugo 6 років тому +2

    really, REALLY WELL made tut
    gg man seriously

    • @Animoplex
      @Animoplex  6 років тому +1

      Thanks Hugo, appreciate the compliments! More on the way in the next few days, stay tuned. Post what you liked about the video, feedback helps to improve.

    • @TutorielsdeHugo
      @TutorielsdeHugo 6 років тому +2

      Clear, organised explanation, can be easily followed by the newbies and complex enough for the more veteran users. The video UI / animations / simple look is really delighting to watch :)
      You know the way to teach man ;)

    • @Animoplex
      @Animoplex  6 років тому +1

      So glad you're finding these valuable. Top priority is clarity and quality. Sometimes there are areas to improve on. It's all a learning process and feedback is always applied to the next video. More videos are coming in the next few days. Curious to hear what you'd like to see next after this course is finished.

  • @BobKirksey
    @BobKirksey 6 років тому +1

    Thanks You So Very Much. I have needed this tutorial. How can I control only one dimension on the "scale" property - like on only the 'Y'-Axis, but leaving the 'X' axis at it's current setting?
    Thanks again!

    • @Animoplex
      @Animoplex  6 років тому

      You're welcome! You can find more info on separating values here:
      ua-cam.com/video/w1yWv8w-WG8/v-deo.html
      You'll want an expression kinda like this:
      y = effect("Slider Control")("Slider");
      [value[0], y]
      Hope this helps!

  • @akthammusa3336
    @akthammusa3336 6 років тому +1

    Thanks . that is what i'm looking for

    • @Animoplex
      @Animoplex  6 років тому

      Awesome! Glad you found it.

  • @CaptainSnackbar
    @CaptainSnackbar 5 років тому +1

    Thanks Animoplex extremely helpful, i'll be checking out your paid content

    • @Animoplex
      @Animoplex  5 років тому

      You're welcome, thanks for reaching out! Reach out if you have questions about the course, happy to help.

    • @CaptainSnackbar
      @CaptainSnackbar 5 років тому +1

      @@Animoplex thanks for sharing and yes my question is can you do tutorials for jsx scripts as well or your channel is expressions only?

    • @Animoplex
      @Animoplex  5 років тому

      At the moment, there is no plan to create scripting tutorials. However, some additional content is being planned, so stay tuned!

  • @martinlofqvist9405
    @martinlofqvist9405 6 років тому +2

    Really really really good stuff. Thank you for this!

    • @Animoplex
      @Animoplex  6 років тому

      You're very welcome. Reach out if you have any questions!

    • @martinlofqvist9405
      @martinlofqvist9405 6 років тому +1

      Trying to figure out how to properly access the json data structure. The json is accessed properly but when I try to print the data it keeps giving me error messages.
      I just bought the projects files from gumroad so I'll have a look!

    • @Animoplex
      @Animoplex  6 років тому +1

      How are you printing the data? If you're using a text layer to display JSON data, you may need to use the ".value" attribute at the end of the JSON object reference. It's hard to tell without seeing your specific setup, but try this out and see if it works.

    • @martinlofqvist9405
      @martinlofqvist9405 6 років тому +1

      puh! I solved it! It was a question of data structure: in what order to call the array number versus the object.

    • @Animoplex
      @Animoplex  6 років тому +1

      Glad you solved it! So you’re using something like myData[1] to reference it? Curious to see what syntax you landed on.

  • @jonmicsa2297
    @jonmicsa2297 5 років тому +1

    These tutorials are really good! You explain things very well and the visuals go perfect with what you are teaching.
    I am stuck on trying something with JSON. I am trying to get a shape to animate changing colors based on the data from JSON.
    For instance:
    data point1 = blue
    data point 2 = red
    data point 3 = green.
    I can get the shape to read one color and display, but not sure how to animate it so the shape displays data point 1 (displays color blue) for 3 seconds, then changes to data point 2 (displays red) for the next 3 seconds, then finally changes to data point 3 (green) for final 3 seconds. Any help or advice to accomplish would be greatly appreciated.
    Thank you very much for making this tutorial series!

    • @Animoplex
      @Animoplex  5 років тому +1

      Thanks for the compliments and feedback! Here's a quick reply: If it's only three colors in sequence, an If, Else If, Else statement might work nicely. Use variables for the three colors like you have, then use conditional statements to say something like this:
      if (time < 3) { color1 }
      else if ((time >= 3) && (time

    • @jonmicsa2297
      @jonmicsa2297 5 років тому +1

      That worked perfect man, thank you!

    • @jonmicsa2297
      @jonmicsa2297 5 років тому +1

      Ok, now I'm looking to get fancy with it lol.
      Do you think it's possible to add a smooth transition (like a tween or something of the sort) between the data points?
      Regardless, this is hands down the best ae scripting tutorial series out there. Have u considered making a Udemy course of this compilation and make some $ off of it? It is that badass...truly.

    • @Animoplex
      @Animoplex  5 років тому +1

      You could combine ease() methods with conditional statements to create something like this. Try this and see if it works, might needs some tweaks:
      if (time < 3) {
      color1
      } else if ((time >= 3) && (time 6) {
      ease(time, 6, 7, color2, color3)
      }
      Thanks for the compliments! The course materials are sold on Gumroad for people who want the project files and videos. That's great extra revenue, and allows the course to be put out there for everyone to benefit from. If you're curious, check it out here: gumroad.com/l/animoplex-expressions

    • @jonmicsa2297
      @jonmicsa2297 5 років тому +1

      That worked like a charm, thanks again!
      Your course is great, very professional and well organized.
      Excellent work!
      Cheers

  • @marlinknecht
    @marlinknecht 4 роки тому +1

    Great Tutorial! Is there a way to do this by dynamically pulling it from a server having a page deliver the JSON string? Does AE have a call function where it can call a page on a server and retrieve the data at the time of rendering? Thank you for the video!!

    • @Animoplex
      @Animoplex  4 роки тому +1

      Not sure if there is a dynamic solution native to After Effects without a third party solution. There may be some solutions out there via plugins/scripts. You could look at pulling a file down to a local drive and restarting/relaunching AE via a command line script?

    • @marlinknecht
      @marlinknecht 4 роки тому +1

      @@Animoplex Thank You, for your reply!

  • @mattshoesmith5201
    @mattshoesmith5201 4 роки тому +1

    As an alternative to evaluating a text field or an external file, is it possible to evaluate a different layer's expression code?

    • @Animoplex
      @Animoplex  4 роки тому +1

      No, but you can create a project-wide library in the most recent versions of AE:
      ua-cam.com/video/sMxQawzvPXI/v-deo.html

  • @MakeTestBattle
    @MakeTestBattle 4 роки тому +1

    Can you use smooth() to smooth the incoming data or do you have type up your own moving average with
    (valueAtTime(time - 1) + valve + (valueAtTime(time + 1) /3;
    To my understanding in say a 25fps timeline that would be like
    smooth(0.04,3)
    Thanks for the video series Parker, I have been using AE for years but never used the expressions. It satisfying when it work and realise I don't have to hand animate the keys.

    • @Animoplex
      @Animoplex  4 роки тому

      Great question! You can use smooth() for this. And if I understand your situation correctly, you should be able to use smooth(1,3) for this. The first argument (sample time width) is measured in seconds, not frames.
      You are very welcome, thanks for the feedback. Expressions are so useful when converting values, it opens up a whole new world of possibilities. Post back if you have more questions!

  • @alexeimolchan1322
    @alexeimolchan1322 4 роки тому +1

    12:55
    Hi there, I spent a bunch of time and still can't find the answer. May be you know:
    I want to use JSX property by index, not by name. What syntax should I use?
    x=footage("example.jsx").sourceData;
    // y=x[1].Name - I want to use index instiad of name
    y=x[1].property(1) // for example. But its not working

    • @Animoplex
      @Animoplex  4 роки тому +1

      Since the sourceData JSON is made of unordered objects, it does not have a specific index order and must be referenced by name. To achieve an indexed approach, you could add a single object and then use an array to hold your indexed data, something like this:
      JSON:
      {
      "myValues": [
      100,
      200,
      300,
      400
      ]
      }
      EXPRESSION:
      src = footage("example.jsx").sourceData.myValues;
      val1 = src[0]; // equals 100
      val2 = src[3]; // equals 400

    • @rabbityRogue
      @rabbityRogue 3 роки тому

      hey so i had basically the same problem and turns out you can (in after effects at least). if you add the json to the composition youll see the tree and if you go to the property, youll see the expression is something like this "footage("example.json").dataValue([0,0,1]" , if you follow carefully the data tree and see which node you need to change, you can put a variable in there. it works ... at least as a source text, but i can't make it work elsewhere for some reason.

  • @nicolasguionnet6867
    @nicolasguionnet6867 5 років тому +1

    Great tuto !
    I tried to use it to put my favorite wanabe-Global functions in a text layer. But the line breaks are not tolerated by our deer AE, so it seems ...
    These global functions ... why is it not simply implemented in AE ? It is so necessary ...

    • @Animoplex
      @Animoplex  5 років тому

      If you're on CC19, you can try this method:
      ua-cam.com/video/sMxQawzvPXI/v-deo.html

    • @nicolasguionnet6867
      @nicolasguionnet6867 5 років тому +1

      @@Animoplex Great !
      I heard that using an extern file at every frame was slowing down AE. But here, as it is imported, this problem does not occur ...
      I will try this method asap !
      THANKS !

    • @Animoplex
      @Animoplex  5 років тому

      Give it a try and see if it works!

  • @andreiacalhau4149
    @andreiacalhau4149 6 років тому +1

    Great tutorial! I have one question: How can I change the color of a shape, using a color value (HEX or RGB, I don't know what's easier) from the json file? Thank you!

    • @Animoplex
      @Animoplex  6 років тому +1

      Thanks, great question! Let's say you had a JSON file that was formatted like this:
      {
      "color": [255,255,255,255]
      }
      You could use the following expression to access the color data:
      myData = footage("File.json").sourceData;
      myData.color / 255
      The array in the JSON file is formatted with 0 to 255 values, so be sure to divide the array by 255 since colors in expressions use values from 0 to 1. Hope this helps!

    • @andreiacalhau4149
      @andreiacalhau4149 6 років тому +1

      Awesome! It works great! Thank you so much for the quick answer!

    • @Animoplex
      @Animoplex  6 років тому +1

      By the way, the four-dimensional array in the JSON example represents RGBA. Glad to be of help.

    • @Animoplex
      @Animoplex  6 років тому +1

      You can calculate the width of the entire text layer, regardless of width, using the sourceRectAtTime method. This can be found here: ua-cam.com/video/BOPfs49VfLE/v-deo.html

    • @andreiacalhau4149
      @andreiacalhau4149 6 років тому +1

      Wow that's nice! Thank you! I can see how I can make it work with that method but I'm having a hard time just trying to follow your tutorial. I can see that my problem is related to the anchor points, again. Where should they be placed? My background layer never stays aligned with the text layer (in the x axis) when I link my text to the JSON file. I guess I'm making some dumb error that is making everything go wrong 😫

  • @DayDreamArtistry
    @DayDreamArtistry 5 років тому +1

    It seems like that the evalFile Method does not work in AE CC 2019. I followed your tutorial and always got an error message "linear is not defined". I get the same error message with different functions, only when I insert plane numbers in the .txt file it works. I couldn't find a solution so I tried exactly the same code in AE CC 2018 and it immediately worked fine. Do you have any experiences with CC2019? Thanks for your tutorials anyway!

    • @Animoplex
      @Animoplex  5 років тому +1

      This is a great point that you bring up, something that will need to eventually be addressed. In CC19, there are new ways to import data into a composition and the evalFile method has been removed from the new JavaScript engine. You can see more information here: helpx.adobe.com/after-effects/using/legacy-and-extend-script-engine.html
      In the meantime, either; 1) Switching back to the Legacy engine (File > Project Settings > Expressions) and using that for what you need, or 2) Look at embedding the expression into a JSX file and importing the JSX directly into the project. You can then use the footage("File.jsx").sourceData method from this video to read that data. It's a slightly different setup but essentially works the same.
      Reach out if you have further questions. Thanks for chiming in!

    • @DayDreamArtistry
      @DayDreamArtistry 5 років тому +1

      ​@@Animoplex Awesome, that helps a lot! Thanks for your reply. I didn't know that you can change the expression engine in CC 2019. There is also a lot of valuable information in the link that you posted, so I'm gonna read that as well.
      Thanks again, for all your help and keep making great tutorials like this.

    • @Animoplex
      @Animoplex  5 років тому

      You're welcome, post back if you find any additional information, it's still pretty new territory. Thanks for the update!

    • @slackdave
      @slackdave 4 роки тому

      all I can do for now is curse. The bastards

  • @voodoomotion5855
    @voodoomotion5855 6 років тому +1

    Is it possible for an expression to change a JSON value and then another expression uses the new value?

    • @Animoplex
      @Animoplex  6 років тому

      This is not possible with vanilla After Effects. There may be a way to use a script or a plugin for this. Depending on your scenario, you could link the two expressions together rather than edit an external JSON file. Hope this helps!

    • @voodoomotion5855
      @voodoomotion5855 6 років тому +1

      That's a pity, it's still a great way to share a lot of read only data. Apparently in older versions of AE, plugins could calculate and output multiple data for expressions to pickwhip but this was disabled due to stability. I've added a feature request on the Adobe website for this to be made possible again but doubt they will. Unfortunately for advanced rigging I find expressions needlessly slow :)

    • @Animoplex
      @Animoplex  6 років тому

      Very interesting, had no idea you could do that in older versions. It would definitely be a cool feature. This may be possible with scripts, maybe frame.io/ uses this type of tech. Reach out if you find any more info on this!

  • @bengregoire
    @bengregoire 5 років тому +1

    this is the one 👌

    • @Animoplex
      @Animoplex  5 років тому +1

      Thanks Ben! Hope it helped solve some of the JSON questions you had.

  • @RigelEli
    @RigelEli 4 роки тому +1

    how can i change colors through json?

    • @Animoplex
      @Animoplex  4 роки тому

      You'll need to specify the color data (using an RGB channel array) in the JSON file then link it to the desired property.

  • @IllusionSector
    @IllusionSector 2 роки тому

    Incredibly useful *when it works*. Unfortunately, sometimes, perfectly valid code that evaluates fine otherwise, would mysterious refuse to evaluate when loaded externally via _$.evalFile()._
    ● Same expression typed directly into the attribute : WORKS
    ● Same expression drawn from the _sourceText_ value of a different text layer via _eval()_ : WORKS
    ● Same expression loaded from an external file via _$.evalFile()_ : DOESN'T WORK.