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

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


Offset in time and Inertial Bounce Expressions together

$
0
0

Hi.

 

I have a problem where I would like to control Offset in time and Inertial Bounce Expressions together on a layer which is connected to a null. Here is my expression so far:

 

// Expression below makes the Offset in time

 

offset = thisComp.layer("CONTROL LAYERS").effect("Slider Control")("Slider"); //The offset in time, negative half a second.

p = thisComp.layer("Null 12"); //The parent layer

T = time + offset; //The current time minus half a second

p.position.valueAtTime(T); //Value of the parent's position property at the current time minus half a second

 

// Expression below makes the Inertial Bounce

 

x = thisComp.layer("Null 12").transform.position;

n = 0;

if (x.numKeys > 0){

  n = x.nearestKey(time).index;

  if (x.key(n).time > time) n--;

}

if (n == 0){

  t = 0;

}else{

  t = time - x.key(n).time;

}

 

if (n > 0){

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

  amp = .02;

  freq = 2.0;

  decay = 4;

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

}else{

  x.value;

}

 

 

Any Idea how to make these two expressions work sametime together?

 

-Matti

Expression to duplicate whole layer several times.

$
0
0

Hi everyone,

 

I am pretty new with AE, I want to ask if there is an expression, which would let me duplicate selected layer?

I want to use expression, because I have to use like, 30 layers of same object, only with some position and rotation offsets.

 

THank you.

Slider Control expression position

$
0
0

Hello everybody,

 

Hopefully somebody can help me out with this:
There are two text layers in my composition and I have a rectangle that is linked to the size of the text of these layers. This worked quite wel so far, but

if my first text layer has more than one line of text, I need to reposition my second text layer. Therefore I made a slider which controls the vertical position of my second text layer. Now I would like to link the size of the rectangle to the y-position of the second text layer. So that if I lower the second text layer, the rectangle grows with a certain amount. Hopefully I could explain the problem clear enough.

This is my code. Please tell me what I am doing wrong. Thank you so much in advance.

 

 

heightTextLayer1 = thisComp.layer("Text Layer 1").sourceRectAtTime().height+300;

 

positionTextLayer2 = thisComp.layer("SLIDER CONTROL Positie").effect("Slider Position Text Layer 2")("Slider").value;

 

if (positionTextLayer2 >= 0) {

heightTextLayer2 =  thisComp.layer("Text Layer 2").sourceRectAtTime().height+300;}

 

 

else if (positionTextLayer2 >= 800) {

heightTextLayer2 =  thisComp.layer("Text Layer 2").sourceRectAtTime().height+700;}

 

 

else if (positionTextLayer2 >= 900) {

heightTextLayer2 = thisComp.layer("Text Layer 2").sourceRectAtTime().height+800;}

 

 

else {positionTextLayer2 = thisComp.layer("Text Layer 2").sourceRectAtTime().height+1000;}

 

x = 1920

if (heightTextLayer1 > heightTextLayer2) {y = heightTextLayer1} else {y = heightTextLayer2} 

[x, y]

Help Combining two expressions

$
0
0

Hi everyone.  I have two expressions which im trying to combine to work on the scale property of a shape layer. The first one is a bounce expression and the second is an expression to use a slider to control the scale of a layer (on the second keyframe). It might help to check out the original thread (Controlling the scale of a shape layer using slider control and expressions. ) where I was given the second expression to get an better idea. If anyone can help that would be greatly appreciated.

 

 

Bounce expression

 

amp = .1;

freq = 2.0;

decay = 4.0;

 

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);

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

}else{value}

 

 

Expression to control scale of the layer

 

x2 = thisComp.layer("Null 1").effect("Slider Control")("Slider");

x = ease(time,key(1).time,key(2).time,key(1).value[0],x2);

[x,x]

time code and expressions HELP

$
0
0

Hello,

My name is Dalal and I need help in my project, in my project there is a hologram control panel and in that panel is a clock from sec to hours, I followed a tutorial on youtube of how to animate and code sec and mins but not hours I need help in coding hours the time starts from 7:30 AM to 5 PM.

 

Here is what I coded:

 

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

sec = slider%60;

min = Math.floor(slider/60);

 

function addZero(n){

if(n<10) return"0"+n else return n;

}

if(slider>0) {

addZero(min)+":"+ addZero(sec)

}else{

"00:00"

}

Shape following right-justified text

$
0
0

Hi everyone!

 

I have this expression which works great. It's made for a shape (in this example a dot) to follow the end of a text.

My problem now is, that i dont know how to make it work, when the text is right-justified instead. Because right now it only works on left-justified text.

 

In this picture you can see how it works right now. It follows the end of the text:

pictureforweb.png

This is the expression used:

x=thisComp.layer("SText").sourceRectAtTime(time,true).width + thisComp.layer("SText").transform.position[0] + effect("x Offset")("Slider");

 

Now i want to right-justify the text and make the dot follow the other end of the text, so it ends up looking like this everytime i type a new text:

pictureforweb2.png

 

Hope someone can help!
Thanks in advance :-)

 

Best regards,

Niklas

Layer not respecting opacity setting

$
0
0

I have a list of about 100 layers in a composition. I use this script to create random fading for those layers.

segMin = .3; //minimum segment duration

segMax = .7; //maximum segment duration

minVal = 0;

maxVal = 100;

 

 

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);

ease(time,segStart,segStart + segDur, startVal, endVal);

It used to work but I was away from the project for a while and opened the file to make changes for a client. Now they all the layers pulse in unison even though if I expand the layers opacity setting and scroll through the time-line, the values do fluctuate in the opacity field as I would expect. Just the actual render shows the flashing in sync.

This expression statement worked in november of last year and now it doesn't. Did something change? I know AE updated the javascript engine but it was supposed to be compatible with the old engine. Also, I the opacity numbers do what I expect just the render/preview does not.


timer expression

$
0
0

Hi, this is the 1st time i post here & i'm newbie in using expressions i was trying to set out an expression that make my timer follow my progress bar like this

MbbX5Xl.png

sp = thisComp.layer("timer");

ep = thisComp.layer("timer"));

t = comp("Music").marker.key("Music End").time;

val = linear(time, 0, t, sp[0], ep[0]);

[val, sp[1]];

 

but i keep getting

unknown.png

AeRender does not recognize expressions in .txt files. How to solve this issue?

$
0
0

Hello. We're experiencing some problems with AE render engine. I searched this across the web but found no solution.

 

We're a large video publishing company and we publish same videos with changed texts on each one. To speed up process we created external .txt file so we can change the texts of AE project using expressions/codes in each text layer.

 

We add this expression into each text layer

 

try{

myPath = "text.txt";

$.evalFile(myPath);

eval(thisComp.name)[0];

}catch(err){

"text error";

}

 

and we add this text into the text file, which is located with AE project

 

VAR compname "text",

VAR compname "text".

 

Everything works great when we render our videos with After Effects, but when we try to render using AERENDER (which is much faster and easier for large number of videos), all expressions are getting disabled and we get videos with wrong text.

 

I wonder if there is a solution to render using AErender but make the expressions to work normally? We use After effects CS6 (this expressions does not work with CC at all)

 

Thanks a lot for your help    

Using Markers and Expressions to animate slider value

$
0
0

Hello,

 

I have a pie chart set up in my animation, pie chard value comes from a dynamic source. I have everything working, but I want to replace the keyframe with layer markers instead. I've applied the below expression to the slider that's controlling "Pie Segment 1". After Effects is recognising the value change at each marker, but only when I remove any 4 of the 5 ease(time... lines below.

 

So, my question is, how can I combine multiple ease(time expressions within the same layer?

 

I hope this makes sense.

Thanks in advance for any help.

 

 

startMarker = thisComp.layer("Pie Segment 1").marker.key(1).time;

midMarker = thisComp.layer("Pie Segment 1").marker.key(2).time;

hold1Marker = thisComp.layer("Pie Segment 1").marker.key(3).time;

dynamicMarker = thisComp.layer("Pie Segment 1").marker.key(4).time;

hold2Marker = thisComp.layer("Pie Segment 1").marker.key(5).time;

endMarker = thisComp.layer("Pie Segment 1").marker.key(6).time;

 

startValue = 0;

midValue = 25;

dynamicValue = thisComp.layer("Display_Ctrl").effect("Slider Control")("Slider");

endValue = 0;

 

 

ease(time, startMarker, midMarker, startValue, midValue);

ease(time, midMarker, hold1Marker, midValue, midValue);

ease(time, hold1Marker, dynamicMarker, midValue, dynamicValue);

ease(time, dynamicMarker, hold2Marker, dynamicValue, dynamicValue);

ease(time, hold2Marker, endMarker, dynamicValue, endValue);

link a keyframe to a slider control

$
0
0

Hey all,

 

Got 2 keyframes on the Trim Paths 1 (End) of a Shape layer 1

The first keyframe has a value of 0

 

Now I want to be able to control the second keyframe with a slider control on Null. So when the slider value is 50, the keyframe value is 50.

 

Thanks in advance.

Random Number per comp

$
0
0

Hi,

 

I have a comp with a random number being generated,

 

This is what I have on the rotation keyframe:

 

seedRandom(index,true);

myValue = random(50) ;

time*myValue;

 

When i duplicate this comp, they all produce the same results.

 

Is it possible for each comp to generate it's own random number?

 

Thanks

Advanced expression (position) question

$
0
0

I'm usually pretty good with expressions, but I'm really stumped on this one:

 

For the sake of keeping it simple, let's say I have:

1. A layer

2. A null object with a slider

 

I want my layer to slide in (x position only) from Point A, to Point B, pause on Point B for a few seconds, then slide back to Point A.

 

Here's the challenge: I want Point B to be controlled by the slider, but I always want Point A to be the same exact starting/ending point. (say 0, for the sake of simplicity). So the animation should go:

 

0 to X, then X back to 0, where X is the value driven by the slider.

 

Hope this makes sense. Thank you in advance to anyone who might be able to help.

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


Time Remap with expression slider not frame accurate

$
0
0

Hi all, first of, I hope this hasn't been posted before - I couldn't find anything on this specific issue.

 

I have a simple mockup character rig with 3 compositions.

01_Character is where all the controls would be.

02_Head is the head subcomp.

03_Eyes is for the different eye states. It's only 3 frames long and on each frame is a layer containing a different eye.

 

In 01_Character is a null object with a slider control. This will be used to switch between different eye states. 02_Head has been added to 01_Character as a layer.

03_Eyes has been added to 02_Head as a layer. This 02_Head layer has Time Remap activated. There is an expression on the time remap:

 

control = comp("01_Character").layer("Control").effect("Numbers")(1);
framesToTime (control -1)

 

Now when I animate the slider in 01_Character comp the eye states (in my mockup numbers) appear and disappear as planned. However this only seems to work while the values increase. As soon as I animate decreasing values the number-states always switch one frame too soon.

That's only when I animate the switches with hold keyframes. When I animate with linear keyframes, the highest value - which should appear for one frame - doesn't appear at all, even though the animation curve shows the correct values.

 

In this screenshot the curve shows value "3", however eye #2 is rendered.

 

Here the animation curve shows the value "3" but #2 is rendered instead.

 

Any ideas on why that's happening? I have played around with different Math.floor and Math.round functions, but I can't seem to resolve this.

Or do you have any alternative ideas for switching asset states? I could put expressions on each layers' opacity, but that has an impact on the rig's performance if I have e.g. 5 x 2 eyes. 5x2 eyebrows, 20 mouths, 20x2 hands, etc. each with their own opacity expression.

 

Cheers, Michael

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.

keyframes control with layer markers

$
0
0

Hello,

 

I have an animation of a line that has two sets of keyframes of two different properties in CS4.

Basically a line gets generated in the first phase then it gets cleared out in the second phase.

This is done using two slider controls that act on the horizontal size of two rectangles and using merge paths (using the second rectangle as a matte for the first to clear it out)

 

I've put two layer markers on my layer hoping to link the keyframes to each of them.

 

Then I have found this script on the web and I put it on the first property :

 

L= thisComp.layer("ShapeLayer");

n = 0;

if (L.marker.numKeys > 0){

n = L.marker.nearestKey(time).index;

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

n--;

}

}if (n == 0){

valueAtTime(0);

}else{

t = time - L.marker.key(n).time;

valueAtTime(t)

}

 

This indeed lets me move the whole animation with the layermarker (which is very good) but I can't find a way to link the second set of keyframes to do the output.

I will add a link with the project file: WeTransfer

 

Please help!

Thanks

Expressions depending on program language? WTF??

$
0
0

How insanely stupid is this? I am working on After Effects in English. Now i got an AEP from a collegue who uses AE in german. The particular project uses a lot of expressions connecting to "Controls for Expressions". An when i open that project in my AE, i get dozens of error messages because all the controls and properties are beeing translated into english while the handlers of the expressions aren't.

 

Is there any possibility for me to fix this without changing almost 50 expressions in 15 comps and without changing my AE to german (because this would mean to reinstall the complete Creative Suite -- another fact that makes no sense)

 

thany you very much

u

clamp a wiggle expression

$
0
0

How do I go about clamping a wiggle expression?

 

I am using the mosaic effect with a wiggle expression on it. The only thing is that I never want the number to become 1, only 2 or higher as with 1 the mosaic effect make vertical lines that I don't want.

 

Cheers

Viewing all 47983 articles
Browse latest View live


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