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

Noob Question: Move a layer in the opposite direction of a different animated layer

$
0
0

So say that I have an icon that I animate on the Y-axis +40px, but instead of trying to hand key the other layer each time, is there an expression I can write to have the other layer move in the opposite Y direction the same amount of units (ex: -40px)?

 

Thanks!


How can I load external file .txt in After Effects CC 2014.0 Release / Mavericks OS X 10.9.4 (13E28)?

$
0
0

ello everybody.

 

Someone can help me to load a external file .txt in After Effects CC 2014.0 Release / Mavericks OS X 10.9.4 (13E28)?

 

I tried the code bellow, but doesn't work.

 

try{

myPath = "~/Desktop/source.txt";

$.evalFile(myPath);

eval(thisComp.name)[0];

}catch(err){

"MISSING";

}

 

The source.txt file have the texts bellow:

 

var comp1 = ["Title”, “Subtitle”, “Description”];

var comp2 = ["Text 0", "Text 1", "Text 2"];

var comp3 = ["Text 0", "Text 1", "Text 2"];

 

Thanks.

Expressions in different compositions.

$
0
0

I am using pre_composed object in different compositions (A,B,C). Each compositions have their own camera in it (active camera). I am applying the expression bellow to rotate my object with the camera.

 

value+lookAt(comp("A").activeCamera.toWorld([0,0,0]),position)[0]

 

Everything works as I expected, but I can't use the same expression in the same object to work with comp B and C. Is there any way around this problem?

How to automatically "fit to comp" any imported file?

$
0
0

Hello everybody

 

i'm using a plugin to dynamically import video files into some comps i previously configured.

All these comps are 1280x720 and this plugin, when triggered, basically takes hundreds of video files i have in a specific folder on my PC and imports them in AE and puts each one of them in each comp.

For my job i sell hundreds of videos per year during sport events (all videos have the same structure). That's why i use this script, which automates my work and automatically edits each video.

 

THE PROBLEM

The video files are not the same resolution. Some are 1280x720, some others are 1920x1080.

The plugin simply imports them and puts them into the comp, which means the 1920x1080 files will not be properly scaled.

As you can imagine, i can't open each comp and right click on the video and click "fit to comp" because, having hundreds of comps each time, it would be a huge waste of time, and it would be useless to use a script.

 

THE SOLUTIONS I THOUGHT

1) Is it possible to tell AE to automatically fit to comp any video imported into a comp? (something like "default scale to frame size" of PPRO)

2) If 1 is not possible, i came up with a weird but possibly working solution. In each comp i put a null object with an expression that changes the scale of the imported video. Hence, when the video is imported, the expression on the NULL object takes care of resizing the imported video. The question is: how can i tell that expression to change the scale of a video not yet imported (i already have the code of the expression, found somewhere ont the web...i just need to tell the null object to apply the expression to a video file that is not yet imported)?

 

 

Thanks for support!

Is there a way to change expression values per keyframe?

$
0
0

I'm using an bounce/overshoot expression on the position property of an animated element.  On big moves, I want the bounce value to be higher - but on smaller movements I don't want it so dramatic.  It seems like the expression is independent of the keyframes - and if change a variable in the expression it changes it for the entire timeline - vs just certain keyframes.  Is this possible?

expression for popping on multiple layers

$
0
0

I need to have 40 eggs pop onto a field, each egg is on a separate layer.  Is there an expression I can use to do this or is this best done manually?  Thank you.

Expression: I am stuck

$
0
0

Hi, could someone please tell me whats going on here:

 

var i=1;

var Banana;

if (comp("Comp 1").layer("Calender_Pre").effect("STAY!")("Checkbox") == 0)

//i = 0

Banana = 20

 

else if (i == 0)

//i++

Banana = 25

 

else if (i >= 0)

Banana = 13;

(Banana);

 

This code seems to work fine until i uncomment either "i=0" on line 4, or "i++" on line 8. If i uncomment "i=0" i get "Error at line 7...illegal use of reserved keyword 'else'", when i uncomment "i++" i get the same Error at line 11.

 

Why am i allowed to assign a value to "Banana" inside the if statements, but not to "i"?

 

Thanks and kind regards,

Expression to change text in precomposed comp from main timeline

$
0
0

If I have a pre-composed animated comp for some lower thirds, is it possible to set it in a way that the text inside it can be changed from the main timeline?

 

I would like to be able to place the the lower thirds comp on the timeline, then change an expression on it for the string used for source text, without having to modify the precomp's contents.

 

Will need to use the precomp multiple times, so I would like to avoid having to duplicate it each time I need to change the text in it.


Limit value scale value using expression.

$
0
0

I'm using wiggle to scale a layer and I really only want it to wiggle  the scale in the positive direction (>100)
I looked into using an "if/else" statement, but AE always error-ed out.

 

This is what I'm using to wiggle the scale.

 

 

 

x=wiggle(effect("XTIME")("Slider"),effect("XDistance")("Slider"));

y=wiggle(effect("XTIME")("Slider"),effect("XDistance")("Slider"));

 

[x[0],y[0]]

 

I tried inserting this line of code, but it always error-ed

 

if (transform.scale[0] < 100) 100.2 else transform.scale[0]

 

Is it a syntax issue or am I just way off track. ANd I'm sure it's probably a really easy answer......

 

thanx in advance for your help

 

best,

 

Fred

How to use Expression to Mask Path vertices

$
0
0

Hi guys,

In Expression Language Reference(https://helpx.adobe.com/after-effects/using/expression-language-reference.html), I find an method called "points()";

 

and there is an example like:

  • Example 2

The example reads the coordinates of the first vertex of Mask 1 on Dark Gray Solid 1 and converts them to composition coordinates. Apply this to a 2D point control of an effect, such as Write-on or CC Particle Systems II, to make the effect trace or track the first point of an animated mask. Duplicate the effect and change the path points index value ([0]) to trace or track the other points of the mask.

myLayer = thisComp.layer(2);
myLayer.toComp(myLayer.mask("Mask 1").maskPath.points()[0]);

emm...

but when I try this, I get en error message saied:

points() method is undefined.....

So I confused about points() method,

 

always moving a null toward a point (simulating gravity)

$
0
0

Basically I want to move a null up and down, but I always want it to try and return to the home position between two keyframes.

 

I know I could just set key frames like this.

 

Home .... PosA ..... Home .... PosB .... Home

 

but I would have to determine the correct location to put the in between  "home" keyframes for every time I want this to happen.

 

it would be way easier to just make a keyframe of each location and have after effects always trying to put the object back where it came from.

 

I only need to work in 2D, fact I really only need to work with the Y axis.

 

Any help would be great,

 

Thanks,

Chris

Fade In/Out - Audio Expression

$
0
0

I have the expression below and wanted that the transition of audio between -192 and 0, and 0 to -192 be smooth during 2 seconds.

 

intro = comp("MASTER").layer("Control").effect("Intro")("Slider"); // example: results in 20
preview = comp("MASTER").layer("Control").effect("Preview")("Slider"); // example: results in 10

if(time < intro || time > preview) [-192,-192] else [0,0]; // the duration is 10 secs at 0 dB between 20 and 30 secs

 

How can I make a fade in, and also a fade out?

AE CC 2014 - Wiggle Expression not assigning similar values on scale

$
0
0

So I've just noticed that the wiggle expression no longer works how it used to. I found a released article explaining changes in the Noise Algorithm used for the wiggle expression what’s new and changed in the 2014 update to After Effects CC  |  After Effects region of interest and am referring to the "fixed bug in implementation of Perlin noise algorithm" section.

 

I'm not sure if this is what's causing the issue but let me explain.

 

I'm just adding a wiggle expression on to an object's scale.

wiggle(5,50);

 

This would normally scale the object's parameters with the same value. so it would be (100,100) to (125,125) and so on.

Now however with CC2014 the expression is assigning different values to each value so getting (125, 115) or something even if the 'constrain proportions' button is enabled.

 

So I tried to trick it:

 

temp=wiggle(5,50);

[temp[0],temp[1]];

 

Still got different values even though i'm telling it to insert the same variable?

 

temp=wiggle(5,50);

temp;

 

Still got different values... I don't get it can anyone help?

How to control only the WIDTH of a rectangle with slider control using expression

$
0
0

I have a simple rectangle shape layer that I want to control (only the width) with slider control using expression. How do I do that?

 

Thanks in advance.

eval expression trouble

$
0
0

Found this cool expression trick reading input from a .txt file.

try{

myPath = "c:/path/to/my/file/testfile.txt";

myTime = Math.round(timeToFrames(time));

$.evalFile(myPath);

eval(thisComp.name)[myTime];

}catch(err){

"MISSING";

}

I would like the expression: eval(thisComp.name)[myTime] to be incremented on each frame.

Works like a charm when i manually enter a array index, but i cannot seem to get timeToFrames(time) to work in this case.

I have tried alot of variations but i can't seem to get it right. Anyone have any tips?


Problem with sampleImage in After Effects CC 2015 (Extendscript / Expressions)

$
0
0

I'm having a weird problem with a script that adds and utilises an expression containing sampleImage.

 

The script is meant to add a 'Color Control' to the selected layer, sample a particular pixel RGBA value, and use that value.

 

I'm testing this with a pure red solid.

 

Here is the script in a basic form:

 

var myComp = app.project.activeItem;

var selectedLayer = myComp.selectedLayers[0];

 

var addColorControl = selectedLayer.Effects.addProperty("Color Control");

 

var expr = "sampleImage([0,0], [0.5,0.5], true, (time+0));";

addColorControl.property(1).expressionEnabled = true;

addColorControl.property(1).expression = expr;

 

var res = addColorControl(1).value;

$.writeln(addColorControl(1).value);

 

In After Effects 2014, this writes the following to the console:

 

1,0,0,1

 

Which is correct for the red solid.

 

But in After Effects 2015, the exact same script and circumstances (red solid), gives this response:

 

0,0,0,0

 

However, if after I have run the above script I then run this:

 

var myComp = app.project.activeItem;

var selectedLayer = myComp.selectedLayers[0];  

 

var getColorControl = selectedLayer.Effects.property(1);

 

$.writeln(getColorControl(1).value);

 

It prints the correct response to the console:

 

1,0,0,1

 

As I said, it works fine in the previous version of AE (2014), but not in the current version. This not working has just crippled a couple of large scripts I'm using, and it would nice to be able to use them in the latest version.

 

Anyone have any ideas about this?

Expression to randomly change position of layer on grid.

$
0
0

Hello,


I would like an expression to randomly affect the position of a layer on a grid, like the example on Dan Ebberts website (Mastering Expressions, Pushing The Limits: Random Motion). However, instead of moving along a path from point A to point B, I would like the layer to jump from point A to point B (with no path in between) over 1 frame. The layer would then hold on that grid space for 5-10 frames before jumping to another grid space, and so on.

 

Having the ability to control the number of layers on the grid by way of a slider would also be very useful.

 

Please help, very stressed!

Rotation Control and changing expression in a spesific time

$
0
0

Hello

i have a car composition and i included "time" expression into tires' rotation but in first minutes of my compositon tires should stop and take thier rotation value from a null object's position. How can i do that?

 

How can i cut "time" expression in a spesific time and how can change expression?

 

Should i use if-else statement?if you say yes, how can i specify the spesific time in if-else statement?

 

Here's my project i am still in the beginning https://drive.google.com/open?id=0B7SOvqNvET0XOU4xSy1YTjd0Yk0

Opacity expression question

$
0
0

Hello I`m looking for an expression that randomly (within parameters)  switches a layers opacity on or off, but crucially does so by fading up and down ( X seconds) rather than just on or off ( which I have an expression for). Can anyone help, thanks  John McGeoch

Help with write on text with curser using an expression

$
0
0

Hi There,

 

I have text writing on with a cursor using this TUT: AE Tut'z - How to Create a Type-Text Effect with a Blinking Cursor - YouTube

 

L = text.sourceText.length;
T = time*effect("Speed")("Slider") -effect("Start At")("Slider")* effect("Speed")("Slider");
F = Math.round(time % 1);

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

substr(0,T) + Fl

 

 

Questions:

 

1.

How would I double the speed of the cursor blink?

Have tried 0.5 under time and the if statement (and tried 2) but then the cursor doesn't show at all.

 

2.

How can I make the cursor start on, then blink?

Currently it starts off but it should be on to start. I tried swapping the cursor "▇"in the if/else statement but then the cursor doesn't show while the text types on (as expected).

 

 

Pretty green when it comes to this stuff so any help or pointers in the right direction would be juch appreciated.

 

Cheers

 

Ben

Viewing all 47983 articles
Browse latest View live


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