Quantcast
Channel: Adobe Community : Popular Discussions - After Effects Expressions
Viewing all 47983 articles
Browse latest View live

Syntax Error on Mac

$
0
0

I am trying to use the following expression:

 

Math.sin(time * effect(“Speed”)(“Slider”)) * 45

I got the expression from this tutorial:  AFTER EFFECTS TUTORIAL - Animate Butterfly / Bird - YouTube

I've not worked with expressions before... but some Googling showed several folks running into the issue of this not working on a Mac.


Can anyone offer any advice?  Thanks!


Baking Parented Motion into Keyframes

$
0
0

Hey guys!  I'm trying to stabilize a piece of extremely tricky footage.   The stabilization needs to be reversible.  Ordinarily this is easy... you just apply the tracking and rotation data inverted to a layer, and then you precomp the stabilized comp, and apply the non-inverted data to the precomp.  Voila!

 

However in this case, due to the trickiness of the stabilization, I've ended up with a chain of parented nulls, each with a combination of position, anchor point, and rotation data (some added manually, some imported from Mocha).  The result works, but reversing it in the traditional way is no longer possible.

 

I've thought of a dumb solution to this problem (more on that below), but what I'm wondering is whether anyone has a smarter solution.  Is there a way of using an expression to read the footage layer's objective position and rotation (taking into account the whole chain of parents)?   If so, then I could simply convert that expression to keyframes, and invert the resulting keyframes to get my "unstabilize" data out of my big mess.

 

I think this is what the toWorld expression is for in a 3D context, but using it is a little beyond me.    Does anyone have a good idea for how to fix this?

 

For the record, here's my dumb solution.  I'm hoping to avoid this:

Replace the footage layer with a grid. 

Render.

Import the rendered file into mocha.

Track the grid.

Sat Nav//GPS style animation trouble - linking properties on multiple layers to control null

$
0
0

Hey,

 

I've got a car (.ai file - could be png or whatever) and a shape layer producing a dotted line along a path. This same path has been copied into the position data of the car and both move over the map seamlessly with the dotted line following where the car has just been.

 

My problem comes from trying to sync this journey with VO - currently ive pre composed the the animation and used time-remapping to to ramp up and down the speed of the animation so that it syncs with the VO of the journey. This is no good as its taking too long too turn around each route and the interpolation between the ramps isnt the most aesthetically pleasing.

 

So what i want is to have a Null with a slider control - id want the trim path of the shape layers dotted line and the position data of the car to both be controlled by the slider (so at 0 on the slider we are at the beginning of the route and 100 the end)

 

Ive been playing around with -

 

ctrl = thisComp.layer("ControlNull");

slider = ctrl.effect("Slider Control")("Slider");

n = Math.max(1,Math.min(slider,numKeys));

valueAtTime(key(Math.floor(n)).time)

 

This is close - at 2 on the slider the dotted line jumps from 0-100. The car gradually completes the run between around 0 - 18 (out of 100) i would like to be able to use the slider to make both properties complete the route at the same time & speed

 

Relatively new to expressions so excuse any blatant ignorance - im using the most recent version of AE CC15

 

Thank you in advance

 

T

Parsing number text string to numeric value

$
0
0

If I have the number "5" as a text layer, how can I get another text layer to read that number, and then add another number to it?

 

This gives me "56". I want "11".

 

temp = thisComp.layer("5").text.sourceText.value;

(temp + 6)

Rotation offset time

$
0
0

I have this code for Position offset time, but, how to turn it for rotation offset time? I have tried to change the "p" for "r" and "position" to "rotation" but still not working...

 

offset = -.5;

p = thisComp.layer("My Animated Layer");

t = time + offset;

p.position.valueAtTime(t);

 

Thanks

Offsetting time and position of several layers relative to preceding layer

$
0
0

Hello -

 

Pardon the newbie questions, but I've keyframed 'Black Solid' moving along the x axis and basically would like to duplicate the layer (perhaps with a new color) several times so that each 'new layer' follows the previous layer and offsets itself a certain amount of pixels...say 20px for example.

 

I found a simple expression that I applied to the first dup'd layer and it works fine but I can't figure out where to tell it to offset 20px to the left of the main layer.

 

thisComp.layer("Black Solid 1").transform.position.valueAtTime(time -.1);

 

I suppose I'm trying for a cascading effect + offset.

 

Thanks!

gj

stroke width with expression

$
0
0

Hi, iam trying to set stroke width based on shape scale, (to maintain fixed stroke size) so ive used "(1/transform.scale[0])*500;" for stroke width expression, but this only works for either stroke width, or stroke height. What am i doing wrong? Or how can i apply ths to both stroke width and stroke height at the same time?

Blinking Cursor

$
0
0

I have been using an expression for blinking cursor text but wanted to see if it can be enhanced.  Here is the expression that I used

 

Apply to the Text Source of a text layer

add a slider controls to the text

 

L = text.sourceText.length; 

PT = time - thisLayer.inPoint;

T = PT*effect("Speed")("Slider") - effect("Start At")("Slider")*effect("Speed")("Slider")*effect("Opacity")("Slider");

F = Math.round(PT % 1);

 

if(F == 1 | (T<L & T>0) ){Fl = "|";}else{Fl = "";}

 

 

substr(0,T) + Fl

 

 

I would like to be able to have the blinking cursor blink faster and also change it's opacity from 0 to 100 as it blinks as it draws on the text.  I am including a link to my after effects file as well as an example video of how I would like it look.

 

http://www.mediafire.com/?ggu3339l5a8o317,jv13o0b8e082fll

 

 

Any suggestions would be most appreciated.

 

Ira


GPS data in Position Expressions?

$
0
0

I have GPS tracks of ocean drifters that I would like to animate with georegistered satellite images at specific time intervals. The objective is to show people how NOAA combines satellite observations and data collected in the ocean using drifters.

 

I can easily convert lon, lat, and time data into image coordinates and frame numbers, but I would like to know how to use these values to set position and frame number properties. I see how to set  position properties using expressions, but I don't see how to tie those properties to specific key frames or frame numbers.

 

This would be my first time implementing a project using expressions, so I would appreciate as thorough of a response as possible.

 

Thank you

wiggle expression with stepped (not smooth) interpolation?

$
0
0

hi

 

not sure if it's even a wiggle expression I'm after,

 

but I'm wondering how to go about getting a series of random values that an object or parameter will jump to (rather than smoothly transition to, as in the basic wiggle expression).

 

thanks

 

ML

Expression Get Project Path or Name

$
0
0

Hi,

 

I am new to After Effects as in I have just seen it for the first time today!

 

What I'd like to know is, is it possible to write an expression to return either the current project name or file path?

 

I'm assuming no as I cannot find any reference to this in the language reference. How would I go about integrating a script with the project to return the project name?

 

I have tried something basic like:

 

Expression code:

 

var currpath = $.evalFile(filepath);

 

filepath is the path to my script file, the script is like the below:

 

GetPath()

 

function GetPath() {

 

return app.project.name;

}

 

With this I get an error similar to method name 'Global' not found - not at my work computer so can't remember the exact message.

 

Any help would be appreciated.

 

Thanks,

 

Mark

Expressions from AE CS6 not working in AE CC

$
0
0

We have used some expressions in an AE CS6 project to fill text from an external file. Here's an example:

 

try{

/* "mypath" must be absolute to data file */

myPath = "file:////nynfile1/Production/Egg/Marque/data.txt";

$.evalFile(myPath);

/* Use [0,1,2] for array offset value(Name, Date, Time)*/

eval(thisComp.name)[0];

}catch(err){

/* Display if data error found*/

"text not found";

}

 

 

It works fine in CS6. When we open the file in AE CC, the expressions can't find the data.txt file to pull text from. All we get is the "text not found" error. We stepped through debug and the data.txt file doesn't open/isn't found.

 

What up with that?

global array variables? , transfer data from one layer expression to another

$
0
0

hi i have arrays in expression, but i have a problem, every time when i move effect point control(i need move it for my task)  array update and erasing, but i need to save data from previous array state

 

 

i add this expression to text layer on Source text

//create array

var arrayX = [];

var arrayY = [];

//add data to array

arrayX.push(12);

arrayX.push(232);

arrayX.push(2424);

arrayY.push(0);

arrayY.push(322);

arrayY.push(122);

text_cur_layer = text.sourceText;

//final result

text_cur_layer ="Array_X= "+arrayX.join( ', ' )+"\r"+"      Array_Y= "+arrayY.join( ', ' );

 

 

expression return 

in array x must be (12 232 2424)

in arrayY  must be (0 322 122)

 

 

so every time when i change state on effect "point control"(slider control and etc) this expression updates and give me always same numbers, from this commands^

arrayX.push(12);

arrayX.push(232);

arrayX.push(2424);

arrayY.push(0);

arrayY.push(322);

arrayY.push(122);

 

 

it happened because i create array every time with

var arrayX = [];

var arrayY = [];

i think this commands erasing all data from array and create new clean array, so i need some how save previous data...., in AE script i can do that with creation array

globally for all functions, but don't know how  do this in expression

 

 

 

 

also i think it can be done with transfer data from array to string and save this string in another layer and then get this data after array creation, but i don't know how i can save array string data and export this string back?

 

 

example

 

 

var arrayX = [];

var arrayY = [];

//try import previous data back(i don't know how do that, just using standard java code..)

//and now i need get data from strX strY from save place and chekc it later

if(strX!=null && strY!=null)

{

arrayX=strX.split(',');

arrayX=strX.split(',');

}

//add data to array

arrayX.push(12);

arrayX.push(232);

arrayX.push(2424);

arrayY.push(0);

arrayY.push(322);

arrayY.push(122);

text_cur_layer = text.sourceText;

//final result

text_cur_layer ="Array_X= "+arrayX.join( ', ' )+"\r"+"      Array_Y= "+arrayY.join( ', ' );

//get data to save

var strX = arrayX.join(',')

var strY = arrayY.join(', ');

 

 

and then i need some how save this strX and  strY  to save place

 

 

 

 

Sorry for bad English

Number Counting Expression with $ - Understanding how to set stop points

$
0
0

Hello, I'm using an expression I found on: Dan Ebberts's Expressioneering Design Guide which has saved me quiet a bit of frustration since I needed to have a comma and a custom character at the end of my counting numbers. But I have a simple question that I can't quite get out of the page's instructions and I'm hoping someone here could direct me.


Issue: The numbers are counting for the first 4 seconds - or whatever I change it too, but I don't understand how to set my number stop points. ie, I want to go from 0 to 1,800 pause at a specific point for several seconds and then count up to 6,500 pause again and count up and so on. So the part I'm not understanding is, how to start the count and stop on a number and then start the count again. I've set key frames for where I want those numbers to be on the timeline in the 'Source Text' which Dan's page references but this isn't working. Thoughts? Direction??? Expression is below and I've attached a reference image of my timeline. Many thanks for any direction you can provide!


Expression:

numDecimals = 0;

commas = true;

dollarSign = true;

beginCount = 0;

endCount = 17000;

dur = 4;

 

 

t = time - inPoint;

s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);

 

prefix = "";

if (s[0] == "-"){

  prefix = "-";

  s = s.substr(1);

}

if(dollarSign) prefix += "±";

 

if (commas){

  decimals = "";

  if (numDecimals > 0){

    decimals = s.substr(-(numDecimals + 1));

    s = s.substr(0,s.length - (numDecimals + 1));

  }

  outStr = s.substr(-s.length, (s.length-1)%3 +1);

  for (i = Math.floor((s.length-1)/3); i > 0; i--){

    outStr += "," + s.substr(-i*3,3);

  }

  outStr + decimals + prefix;

}else{

  prefix + s;

}

ref.jpg

How Can I get pre text Characters position?

$
0
0

I create text like "test".

and I want to know each letters( "t" "e" "s" "t") position

How to do this with expression or script? 


Text layer bounds expression problem

$
0
0

I was working on something with this, and funky stuff seems to happen when there's any lower case letter with a decender (qypj) the box acts kinda funny.

In this image[2] you can see I'm using it to center the anchor point, but the words on the left with the decenders think the text box is way bigger than it is or something and puts the anchor point up a bunch, also screwing up a beautiful set of expressions I had keeping those words in the boxes and doing all sorts of other exciting stuff.after effects.PNG

The expression: myTextLayer.sourceRectAtTime().height/2; 

(I'm only centering the y axis so pay no attention to the anchor point not being in the middle of the x axis)

This is the first time we've had this feature so maybe I'm missing something or it's a lil funky still? Any help would be appreciated!

Need Help w/ Expression (Sound Keys Plugin is Used)

$
0
0

I have a question, it is with java code in after effects.

so my code for my bars right now is

 

X = 90
Y = thisComp.layer("Sound Keys 33").effect("Sound Keys")("Output 1") + 1;
[X, Y]

This is bar 37

I want Y to only go up to a maximum of 105% of bar 38, which for that bar my expression is

 

X = 90
Y = thisComp.layer("Sound Keys 19").effect("Sound Keys")("Output 2") + 1;
[X, Y]

 

I could easily do this, but the problem is, the bars are not static, they are reacting to a song using keyframes making Y go higher and lower.

A screenshot of the bars I'm working with

Screenshot_5.pngThe arrow is pointing at bar 37, the one right to that one is bar 38.

I would greatly appreciate any help at all, but would also like a quick response, since I want to get this done ASAP! Thanks!

Difficulty w/ Expression speed and frequency control: Unable to create a smooth value oscillator when changing frequency over time

$
0
0

Hi there. I have a somewhat advanced question about speed and frequency control expressions, and I'm hoping some expression gurus out there may be able to help.

 

I'm trying to create an expression to animate an oscillating diameter of a circle that smoothly responds to changes in frequency value over time. Using slider controls, I've assigned the values of the initial circle diameter, its oscillation amplitude, and oscillation frequency. I can keyframe changing frequency values over time, but when I do this, an uneven animation results. Please refer to my attached screenshot for reference:

AESS_1.jpg

 

The green graph represents the circle diameter size (to be completely specific, this is the 'Starting Thickness' value of the 'Beam' effect made to look like a circular glowing eye). The pink graph represents the slider value of the frequency value control. It starts at .5 and increases to 1.4 over about a second, but as you can see from the graph output when this occurs the frequency of the diameter size oscillation abruptly jumps to a rate faster than the intended target rate before arriving at the target frequency - not gradual at all. I realize I could convert my expression to keyframes and smooth things out this way, but I'd prefer to find a solution w/ the expression itself. Can someone please advise me how to create an expression that will result in a smooth, gradual change in frequency?

 

Below is my current expression. I use sliders to define the maximum sphere diameter size and it oscillates to a smaller diameter size and back again depending on the value of "amp" and "freq". I also have it designed to only begin the animation after a specific keyframe is reached in the composition to ensure a smooth animation (w/ out this :

 

initEyeSize = effect("Sldr-EyeDiameter")("Slider");

freq = effect("Sldr-EyeSizeFreq")("Slider");

amp = effect("Sldr-EyeSizeAmp")("Slider");

FXstartFrame = effect("Sldr-FXStartFrame")("Slider");

currentTime = timeToFrames();

t = currentTime - FXstartFrame;

 

if (t >= 0)

  {thisProcTime = currentTime - FXstartFrame;

  finalEyeSize = initEyeSize - Math.abs(amp*Math.sin(freq*framesToTime(thisProcTime)*2*Math.PI));}

else {initEyeSize;}

 

I am familiar with Dan Ebberts' expertise in the area of motion scripting and have consulted this article extensively, which is about achieving smooth frequency transitions over time w/ his linear keyframe integration technique. Specifically, I think this expression holds the key to my solution, but I'm having a hard time wrapping my head around how to integrate it w/ my current expression:

 

freq = effect("Slider Control")("Slider");

amp = 100;

n = freq.numKeys;

if (n > 0 && freq.key(1).time < time){

  accum = freq.key(1).value*(freq.key(1).time - inPoint);

  for (i = 2; i <= n; i++){

  if (freq.key(i).time > time) break;

  k1 = freq.key(i-1);

  k2 = freq.key(i);

  accum += (k1.value + k2.value)*(k2.time - k1.time)/2;

  }

  accum += (freq.value + freq.key(i-1).value)*(time - freq.key(i-1).time)/2;

}else{

  accum = freq.value*(time - inPoint);

}

value + amp*Math.sin(accum*Math.PI*2)

 

My current expression allows me to generate sine wave oscillations starting from a specific keyframe of my choosing vs. the start of the composition as I understand is standard expression behavior -resulting in a smoother animation of my oscillating sphere diameter. I'd like to preserve the functionality of my current expression while integrating Dan's expression, but my previous attempts have been unsuccessful b/c Dan's expression seems to work off of the inPoint time of a layer, whereas mine is working off of time in frames as measured from a specific keyframe starting point ('FXstartFrame') not at the start of a layer. Plus I'm having a difficult time comprehending the inner workings of Dan's expression.

 

Are there any expression wizards out there who know how I can integrate Dan's expression into mine so that the value oscillation begins after a specific keyframe is reached AND the oscillation frequency gradually changes when the frequency value changes over time?

 

To help clarify all this, I'm attaching a video clip of what I'm working that reflects the animation going on indicated in my screen shot above. It features the animated circle (a glowing eye) static before the target keyframe is reached, then oscillating at the initial frequency, then oscillating wildly during the transition from frequency one to two, then oscillating at the final target frequency.

 

 

 

Please let me know if you need further clarifications, I realize this is somewhat of a complicated series of questions.  Thanks in advance for any help you can provide!

Effect > Expression Controls > Layer Control

$
0
0

Possible ways to create a control Panel with Layer Control?

I need a control to create a template with secure and unique choices for peoples.

 

  1. Way - "Layer Control" control another "Layer Control"?
  2. Way - "Layer Control" hide unwanted layers, showing only specific layers?
  3. Way - "Layer Control" show as choice external layers, of another Comp? ("Comp B" the comp with layers that need to be accessed). Instead of layers of the same Comp ( "Comp A" where the effect "Layer Control" is)

 

  • Why have two "Layer Control" (twice "Layer Control" for "3. Way") that need to choose separate layers, now I want to join the two "Layer Control" into one layer externally with more a "Layer Control" (totaling 3 Effects), to control the two Effects previous, working like a panel.
  • The "Way 2." would not be necessary two "Layer Control" in layers separated, only a mode of hide layers for each Layer Control Effect who are in the same layer (Or until put in another layer, if necessary to achieve the result.) in Main Comp "Comp A".
  • And in "Way 1." Also need to three "Layer Control", but it would be necessary an expression that links the choices of layers of Comp where are the Layer control effects external, with the Layer Control of Main Comp ("Comp A"), which will be the panel.

 

Or otherwise.

 

Thanks.

Repeat news ticker seamlessly

$
0
0

Hello,

 

I am making a news ticker and I am happy with the design result so far. The only thing what's left is repeating the ticker.

 

This is my current setup:

 

  • Main comp
    • Main news-ticker comp
      • News content composition
        This comp has a time remap expression:
        loopOut("cycle", 0)
        And 2 keyframes. One at the beginning and one at the end. **

        • Inside this composition is a text layer. This is one line of multiple news items. It scrolls with the following expression on the position:
          offset = 8.34; // Value in pixels per frame
          x = timeToFrames() * offset;
          value - [x, 0]


** I am looking for a solution to let it loop seamlessly. So the first news items should connect to the last news item and so on..

Do I need a separate expression for this? Or is there any other trick to accomplish this?

Viewing all 47983 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>