2 Replies Latest reply on Dec 18, 2014 4:43 AM by Lewiz

    Script converting expressions on every comp in a project

    Lewiz

      Hi there everyone,

       

      I have a project full of comps that are very similar. Three layers in each comp (always the same layers, same index) have an expression on position, that I want to convert to keyframes.

      To automate this, I wrote a script that selects the postion parameter of each of these certain layers and nicely converts the expression to keyframes for each one.

       

      The problem is that the script will only work right on an a comp that is actually opened in the timeline window. So I have to open and close each of the 400 comps manually now, and manually run the script in between. Of course, there are better ways to spend my time :-)

       

      I noticed that when I don't open any comp, but highlight one in the project window and then execute the script, AE gets as far as selecting the targeted layers and their position parameters (which appear highlighted when I open the comp), but it simply doesn't perform the Convert Expressions To Keyframes-action. How can this be? Is the CETK command only executable in the timeline window? I'd be pleased to know.

        • 1. Re: Script converting expressions on every comp in a project
          Mylenium Most Valuable Participant

          Keyframe Assistants require the property to be converted selected and that only works with open comps, naturally. Generally you would not use this feature, anyway, but rather use valueAtTime() in your script to get the actual value and bake it into a keyframe. Pretty much how most scripts of that ilk work in the first place.

           

          Mylenium

          • 2. Re: Script converting expressions on every comp in a project
            Lewiz Level 1

            Thanks for your reaction, Mylenium. The strange thing is that the properties ARE selected by the script even when the comps aren't open, but indeed the Keyframe assistant cannot complete its task.

             

            So let's take a look at your suggestion, using valueAtTime. That would give me the expression-generated value of a layer? Or rather the original value? If the first is true, okay, good idea, but how do I bake this value into let's say a position keyframe? And how do I eliminate the expression? Because that is the main target: the expressions I use generate a position based on a sampleImage() of another layer. This sampling is very time consuming, though the position is just one static value, because AE keeps sampling for the entire comp's duration. So what I want to do is to determine this sampleImage value just once and bake that value in the position parameter of another layer.

             

            Now I noticed that sampleImage() unfortunately is not a script command, just for expressions apparently. If however, I could use valueAtTime to get the sampleImage value generated by the expression on let's say time zero, I can enter that value into the position parameter of another layer through scripting, but then I would also need a command that disables or destroys the expressions.

             

            Now I don't know if that is possible.