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

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!


set scale in pixels in After Effects using Expressions

$
0
0

Hey everyone!

 

I often set the scale in pixels, using right click on a scale, hitting Edit, and then enter scale in Pixels. How can set the scale using expressions? And generally, how do you set the units using expressions?

 

returning ["200px","200px"] results in error

 

Thanks for help!

attach positional data to 4 corners of a shape with rotation

$
0
0

So here is my dilemma. I need to attach positional data to 4 corners of a box that I can then animate and rotate.

 

I've tried pre-comping, parenting null objects with offset, using corner pin, and CC Power Pin. All to no avail. Currently this is the expression I am using:

 

L = thisComp.layer("Rectangle");

offset = [50,50];

r = L.sourceRectAtTime(time,false)

L.toComp([r.left,r.top]) + offset

 

The main problem is the rotation. I have this expression on all 4 of the different positions, with slightly different offsets to put them on the 4 corners. But when I rotate the box, the points stay in the same place. Because their offset is based of the rectangle source anchor which doesn't translate rotation.

 

The goal is to create ripples under the wheels of a car in a top down view. I'm using wave world to create the ripples and each ripple source has a position data point that I need to tie to each car wheel corner, or in this case, a box that I can animate and "drive" around.

 

Thank you for any assistance you may provide.

 

- Ryan

Expression disabled error !!

$
0
0

//The below script creates jiggle for keyframes in any property but sometimes

//results in attached error

//Can someone please help me with this

 

Thanks

 

n = 0;

if (numKeys > 0){

  n = nearestKey(time).index;

  if (key(n).time > time){

  n--;

  }

}

if (n == 0){

t = 0;

}else{

t = time - key(n).time;

}

if (n > 0){

v = velocityAtTime(key(n).time - thisComp.frameDuration/10);

amp = .05;

freq = 2.0;

decay = 5.0;

value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);

}else{

value;

}

 

Thanks in advance !!

erro.PNG

Height of layer depending its scale

$
0
0

Hello everybody,

 

I'm working on a UI on After Effects and I want to automate it with expressions.

 

I'm kinda stuck right now. Here's my issue :

 

I have a shape layer (SL 1) whose scale is animated. Above it, i have an other shape layer (SL 2). I want the SL 2 to never cross the SL 1, I want it to slide along when the SL 1 is growing up (as in Apple OS Desktop interface toolbar).

 

For that, I want to get the height/width of my SL 1. I used sourceRectAtTime() but unfortunately, this expression doesn't considered the evolution of my scale.

 

Is there a way to get the height/width of a layer evolving as my scale is changing ?

 

Is there a "toComp" expression but for scale's values ?

 

Tell me if I'm not clear on my demand.

 

Thank you very much !

After Effects Font Expression

$
0
0

Dear AE expressionators,

 

Concrete: I am making a template whereas the user can change the text font and that it will automatically update this to the hole template.

 

For example, see the picture.

So everything I change in the above text layer the under text layer transforms with it. But if I change the font it doesn't.

Does after effects use a different expression for automatically changing a font?

 

I would really appreciate your help!!!

 

I'm using after effects CS6

How do text layer expression selectors operate on character value?

$
0
0

I'm banging my head against my desk here.  Every other attribute I try to animate using expressions selectors works by multiplying the value returned by the selector by the value of the property in question.  But I can't make heads or tails of what an expression selector does to either Character Value or Character Offset properties.

 

Has anyone had any luck with these?

 

I'm just trying to transcribe the characters from one text layer into another using the expression:

 

 

MT = thisComp.layer("Master Text").text.sourceText;
if(textIndex < MT.length) MT.charCodeAt(textIndex) else 32

 

 

I set my character value to 1, and left the Amount property set to [100,100,100] thinking the value coming out of my expression would be multiplied by 1.  Instead, the results I get are nonsensical.  Is there something obvious that I'm missing?

Creating a number counter that counts in increments of .05 in After Effects.

$
0
0

I need to create a number counter that counts in increments of .05 in After Effects.  Any advice on how to do this?

 

Many thanks!


time offset path driven by nulls

$
0
0

Hi! I would like to make different shapes to be driven by the same nulls using the ".valueAtTime(time-x)" expression.

Where should i use the time offset value in the path expression?

I used it in anchorPoint.value but i get no delay. The shape look the same like the one without it.

Let's say i have this expression on a path driven by 10 nulls:

 

var nullLayerNames = ["Shape Layer 1: Path 1 [1.1.0]","Shape Layer 1: Path 1 [1.1.1]","Shape Layer 1: Path 1 [1.1.2]","Shape Layer 1: Path 1 [1.1.3]","Shape Layer 1: Path 1 [1.1.4]","Shape Layer 1: Path 1 [1.1.5]","Shape Layer 1: Path 1 [1.1.6]","Shape Layer 1: Path 1 [1.1.7]","Shape Layer 1: Path 1 [1.1.8]","Shape Layer 1: Path 1 [1.1.9]","Shape Layer 1: Path 1 [1.1.10]"];

var origPath = thisProperty;

var origPoints = origPath.points();

var origInTang = origPath.inTangents();

var origOutTang = origPath.outTangents();

var getNullLayers = [];

for (var i = 0; i < nullLayerNames.length; i++){

    try{ 

        getNullLayers.push(effect(nullLayerNames[i])("ADBE Layer Control-0001"));

    } catch(err) {

        getNullLayers.push(null);

    }}

for (var i = 0; i < getNullLayers.length; i++){

    if (getNullLayers[i] != null && getNullLayers[i].index != thisLayer.index){

        origPoints[i] = fromCompToSurface(getNullLayers[i].toComp(getNullLayers[i].anchorPoint.valueAtTime(time-. 16))); 

    }}

createPath(origPoints,origInTang,origOutTang,origPath.isClosed());

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,

 

change color according to value

$
0
0

Hey.

 

I want to make an expression for a randomly changing number, (so far so good), but each time it will change a value, I want it to change color relatively to the previous value it had. MEANING... if it will goes up, then it will change to blue and if down then to orange (for example).

 

one more thing. I want it to change value every few seconds and do it with a "hold interpolation" so it will jump to the next value instead of working it's way toward it...

 

 

now.. so far I got this: (for the first part anyway)

------------------------------------------------------------------------------------------ -----------------------------------

 

upColor = thisComp.layer("Ctrl").effect("Up Color")("Color");

downColor = thisComp.layer("Ctrl").effect("Down Color")("Color");

value = thisComp.layer("Ctrl").effect("Slider Control")("Slider");

prevframe = thisComp.layer("Ctrl").effect("Slider Control")("Slider").valueAtTime(time - thisComp.frameDuration);

 

if(prevframe.valueAtTime < ((time * 25) % 2 == 0).valueAtTime))downColor else upColor;

 

value;

 

------------------------------------------------------------------------------------------ -----------------------------------

Capture.JPG

any ideas?

 

thanks!

Ido.

Master Expression for Multiple Layers

$
0
0

Working on a project that may have many hundreds of layers, and while many will have the same animations with time offsets etc I need to build it as an adjustable template.

 

Effectively I'm looking for a way to have many layers using the same expression from a single control layer so that if I want to make modifications to the expression I don't have to go through 100+ layers and re-paste the expression.

 

Ideal scenario would be to have an "Master Expressions" layer which has many properties with the applied expressions and then on all my other layers have them pull the expression code from the appropriate "Master Expressions" property. This way when I update the code in the "Master Expressions" it is applied globally across all linked layers.

 

I've attempted to use a Text Layer and input my expression in the "Source Text" parameter, but I have not found a way to pull the full text as applied expression for another layer.

 

Any ideas?

Change text colour with an existing slider control

$
0
0

Hi guys, I am making a 9:16 (vertical) graphics template themed with the logo and colours of the 20 teams of the English Premier League.  My expressions knowledge only goes so far as wiggle and a bit of pick whipping!

 

I am trying to make an essential graphics template so that the editors can use the slider to pick the team that they want to have as their on screen graphic in Premiere (rather than having to go into AE).

 

So far I have in my essential graphics tab the four lines of text, the slider, and a comment which tells the user which team is which number. The slider goes from 1 to 23 (20 teams plus three others).

 

 

Here is what that looks like:

Screen Shot 2018-02-05 at 10.27.04 PM.jpg

I have so far been able to use the slider to change the logo (by making all other logos 0% opacity), to change the name of the team (by making all other team names 0% opacity) and to change the background colours of the boxes.

This is the expression I used to do all of this. It is in the opacity setting for each object:

 

 

slider = thisComp.layer("Team Slider").effect("Slider Control")("Slider");

 

 

if (slider == 6) 100 else 0;

 

 

My problem is that I also want to be able to change the colour of the text when the slider is changed. Does anybody have any idea of how I can do this?

 

 

Below is the project file:

 

https://www.dropbox.com/sh/0yrknu66b8fjvcg/AADNJFMAoNLRlT7INQ1yh9rla?dl=0

 

Thank you!

 

David.

Random scale with equal values for xScale and yScale

$
0
0

Hi there,

 

professional scripters might not think of this to be a problem, but I cannot solve it on my own after hours of trying.

 

I found a random script on www.motionscript.com (thank you so much Dan, for this great resource, you're awesome!).

 

The sample for "random motion - more chaotic" is exactly what I need, but for the scale property with same random values for xScale and yScale (so that the random scaling is proportionally). I cannot figure out how to do this. I know I need another variable, but I don't know where.

 

Actually, I want to have a matrix of dots, each scaling up and down again randomly and independently in size and timing...

 

This is what I got so far:

 

segMin = .3;
segMax = .7;

minValX = 100;
maxValX = 200;
minValY = minValX;
maxValY = maxValX;

minVal = [minValX, minValY];
maxVal = [maxValX, maxValY];

seedRandom (index, true);
segDur = random (segMin, segMax);
seed = Math.floor (time / segDur);
segStart = seed * segDur;
seedRandom (seed, true);
startVal = random (minVal, maxVal);
seedRandom (seed+1, true);
endVal = random (minVal, maxVal);
easeOut (time, segStart, segStart + segDur, startVal, endVal);

 

I'd appreciate someone's help without being to demanding :-)

 

Thanks a lot for reading this.

 

Chris

Using Create Nulls From Paths without Nulls (self contained)

$
0
0

Is it possible to use the new "Create nulls from paths" and relink the expression to its own layer rather than the null object.

I have a very basic object - a flower

It has a stem which is one single path.

Using Create Nulls from paths makes one at the stop of the stem and the bottom as you would expect

I then link the top of the stem null to the flower petals position.
This way I can move the flower and the stem bends and follows nicely

 

However I am wondering if I can alter the expression to bypass the null and link it directly to the position of the petals object group.

 

The direct code created out of create nulls from paths script.

 

I have been able to link the stem up using the Expression controls automatically created to select the shape instead of the null

however the null which then does nothing, breaks the code if deleted and it no longer works.

So I can bypass the null but its effectiveness is still dependent on the existence of the null which  makes the attempt pointless.

 

var nullLayerNames = ["Shape Layer 2: Path 1 [5.1.0]","Shape Layer 2: Path 1 [5.1.1]"];
var origPath = thisProperty;
var origPoints = origPath.points();
var origInTang = origPath.inTangents();
var origOutTang = origPath.outTangents();
var getNullLayers = [];
for (var i = 0; i < nullLayerNames.length; i++){    try{         getNullLayers.push(effect(nullLayerNames[i])("ADBE Layer Control-0001"));    } catch(err) {        getNullLayers.push(null);    }}
for (var i = 0; i < getNullLayers.length; i++){    if (getNullLayers[i] != null && getNullLayers[i].index != thisLayer.index){        origPoints[i] = fromCompToSurface(getNullLayers[i].toComp(getNullLayers[i].anchorPoint));     }}
createPath(origPoints,origInTang,origOutTang,origPath.isClosed());

 

I can do without obviously but I was hoping to make the flower self-contained if possible. And then if it were possible to bypass the null I could learn by extrapolation and apply the bypass to other projects


Camera Zoom Expression

$
0
0

Hi All, I've been recently using a workflow I quite like to create hundreds or thousands of instances of a 3D object in AE, and I'd like to take some of the guesswork out of it with an expression for the camera.

 

Let me give you an example of the kind of shot I'm working on. 

 

Imagine you're pushing in towards the window of an office building when it opens and out of it starts pouring hundreds of paper airplanes.  My workflow is to do the following once I've got the office building and the airplanes built in AE.  Design the camera move, with one airplane which follows a typical path.  Then use the perspective changes on that airplane to create a 2D "card" which can be fed to a particle system which replicates the move hundreds of times with minor variations.

 

What I'm trying to make:  a set of expressions to use with the camera for the purposes of creating the 2D card.   What it needs to do is point the camera at the object and control zoom.  Ultimately it needs to keep the object's  orientation and apparent size constant through the shot, so that the only change in the object that you see is the change in perspective.

 

I've been eyeballing this in the past and it works relatively well, but I think if I nailed it down I could have a really useful system for creating apparently 3D particles.   Thanks in advance for any help!

"slider wiggle"=? in french ??

$
0
0

Hello, i'm novice.

 

I'm working on a project, but there is not the same AE version. I'm french.
I have a error message, because  AE can't found the 'slider' effect. It's a language problem.

I understand that i have to replace any "slider control" by "paramètre glissière; "slider" by "curseur".
But what have i to replace for "slider wiggle" ?

 

thx

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

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.

Stop wiggle at certain time and keep value

$
0
0

I'm trying to create an animation whose length can be user-controlled via a slider.

It is about a layer which rotates in 3D space and it works just fine for the rotation and length controls.

But I want to give that layer also some random movement in the form of a wiggle on the position property. I figured out how to stop the wiggle at a certain point in time, but after that point it just jumps back to its initial value. But I want it to keep it the value it has on the last frame the wiggle is active.

Is there a way to do this?

Viewing all 47983 articles
Browse latest View live


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