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

I have to fix some expressions in After Effects.

$
0
0

스크린샷 2016-01-11 오후 1.23.34.png

When I turn on some file at first, it suddenly appear that comment, which said 'In this project, it has expression error 1/1 error'

 

Actually, I'm a learner of After Effect so I do not know fluently what's what.

 

Here is the expression having error.

 

 

transComplete = effect("Slide Master Control")("Transition Completion");

if (effect("Slide Master Control")("reverse direction") == true)

    {xPos = linear(transComplete, 0, 100, thisLayer.width, 0)}

else

    {xPos = linear(transComplete, 0, 100, -thisLayer.width, 0)};

[xPos, 0]



Thank you.

 

If you want to email me, please send me into 'triumphalboy@gmail.com'.

 

I can send you this aep file for you in order to fix the problem.


RGB to HEX #ffaadd value to Text Layer

$
0
0

Hi, I am trying to write an expression that will spit out #HEX value to a text layer source.  The RGBA color will come from a fill color on a solid layer.

 

I cannot find anything to convert RGB to a HEX value only rgb to hsl.

 

Is this even possible through expression or extendscript?

 

This is what I have so far, which will spit out RGBA values from converting rgbtohsl and then back to hsltorgb*255

 

in_rgb = thisComp.layer("controller").effect("color_04")("Color");

in_hsl = rgbToHsl(in_rgb);

new_hue = (in_hsl[0] + 0) % 1;

new_sat = in_hsl[1] * ((thisComp.layer("color_04_tint").effect("saturation")("Slider")/100)+1);

new_lightness = in_hsl[2] * ((thisComp.layer("color_04_tint").effect("brightness")("Slider")/100)+1);

mod_hsl = [new_hue, new_sat, new_lightness, in_hsl[3]];

 

 

src = hslToRgb(mod_hsl) * 255;

 

 

Any help is appreciated.  Please feel free to email me, jchung@guidespark.com.

 

Joe

Expression Evaluation Issue in CC 2015

$
0
0

Hi,

 

I have a script that applies the sampleImage expression to a layer in order to find its boundaries. In all previous versions of After Effects, this script could evaluate a layer in less then a second. In AE CC 2015, the script was failing completely. I found the problem was that the value of the applied script was not being updated fast enough.

 

In order to get things working i have to add a half second delay each time the expression is changed, so a function that used to take half a second now takes almost 2 minutes.

 

Has anyone came accross any similar issues or have any ideas for fixing the problem without hurting the performance so much?

 

Thanks,

Jesse

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?

seedRandom( index, true) generates each frame a new number. Why?

$
0
0

Hi, I would like to understand why this code here:

 

j = 0;

accum = 0;

seedRandom(index,true);

 

while ( j < time ) {

accum += random(10);

j += thisComp.frameDuration;

}

 

random(100)

 

generates a different number each frame. But this one:

 

seedRandom(index,true);

random(100)

 

doesn't. Can anybody explain me this please?

Possible to set Source Text from another comp?

$
0
0

Let's say there is a Comp1 with a pretty complicated animation that involves a text layer. CompMain is the main comp with 10 instances of Comp1. Each instance has different text, position and timing. Can I set the Comp1 text layer Source Text from an expression in CompMain? If this is not possible, is there any workaround? Otherwise, the alternative would be to have 10 versions of Comp1 with different text and that would be too messy.

divide by 0?

$
0
0

Hi, one of my expressions got disabled due to an "invalid numeric result (divide by 0?)" , but as far as i can see, i am not dividing by 0.

 

my code:

 

var f=timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false);

var c= thisComp.height;

var h=(c-1)/2;

var a= f-z*c;

var z=(f/c)-(1/10000000);

var s=4/(c-1);

var x=(-(h+1)+a)*s;

var y=(h-z)*s;

 

[x,y]

 

The super weird thing is, that when i change the "z" in var a to "3", the expression works, but when i replace the whole value of var z to "3", i get the same error. Shouldn't the two give the exact same result??

 

Thanks and kind regards,

keyframe overshoot at the start of animation

$
0
0

I am using a keyframe overshoot expression. Starts normally and wiggles at the end. This is the code for it:

 

freq = 3;

decay = 5;

 

n = 0;

if (numKeys > 0){

  n = nearestKey(time).index;

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

}

if (n > 0){

  t = time - key(n).time;

  amp = velocityAtTime(key(n).time - .001);

  w = freq*Math.PI*2;

  value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);

}else

  value

 

How can I reverse this expression, so that the wiggle is at the start of the animation (instead of at the end), creating sort of an expectation. Would look really cool I think. Thanks for help. I think that this already has a solution posted somewhere, but I am unsure of what to google. Thanks for help.


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

After Effects Combine x2 Expressions - Bounce & loopOut

$
0
0

I'm after help combining x2 expressions. A bounce expression like below...

 

n = 0;

if (numKeys > 0){

n = nearestKey(time).index;

loopOut("cycle");

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 = 4.0;

decay = 2.0;

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

}else{

value;

}

 

...with the standard loopOut("cycle") expression. I have a few key frames to lift an object slowly then to drop it quickly (hopefully with a bounce) and I need to repeat this indefinitely. Can any one help?

how to read data from serial port

$
0
0

Hi,
I want to read data from serial port by using expressions (or script, does not matter) for attaching them to a null or somthing else in realtime.

is any solution for this?

thanks

Expression on checkbox to control opacity of other layers

$
0
0

I'm making a template with multiple color schemes, and I'd like to work backwards a little:

 

Typically when I make a template, I'll have a pre-comp with multiple background layers in it and I'll use a Null in my main comp with an appropriate amount of Expression Control checkboxes to control the respective BG layers' opacities – pretty normal stuff.

 

The downside is that if I want to reuse this background layer in different comps I have to duplicate it and change the expression to match the location of the null each time it moves.

 

I'd like to work backwards (if possible) and instead apply an expression to the checkbox itself that references a single BG precomp. This way I can copy the null to my 20 different template comps, while the expressions always reference a single pre-comp, thus enabling me to simply copy the null from one comp to another without ever having to change the expressions.

 

Is that possible?

Floating Expression

$
0
0

Greetings community,

 

i found an expression that makes a floating animation with consistant oscillations.

 

xAmp = 3; //height of undulations (pixels)

xFreq = .3; //undulations per second

xSpeed = 150; //speed of wave (pixels per second)

 

wl = xSpeed/xFreq; //wavelength (pixels)

phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;

y = xAmp*Math.sin(2*Math.PI*xFreq*time + phaseOffset);

value + [0,y]

 

This expression does the oscillations only on the Y axes.

 

My question:

Is there a way to make the expression do the oscillation not just on Y, but also on the X axes at the same time?

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.

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


Is it possible to confine expressions to specific keyframes?

$
0
0

I am definitely a beginner when it comes to expressions.

I am currently using a "bounce" expression on the position parameter of some objects as they come on screen. However, the next time they change positions, I don't want them to bounce. Every time a motion tween ends in a static position, the position expression gets applied and the stuff is moving around.

I'd like to be able to keyframe the expression so that it worked only when on the keyframes that it makes sense to affect.

 

amp = .05;

freq = 1;

decay = 7;


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

}

 

I got this script from somewhere online. The only thing I know how to manipulate are the initial values of amp, freq, and decay.

Expressions Optimization

$
0
0

I use a lot of expressions - to a point where I sometimes get stack overrun errors in renders, and other glitches.

 

I am wondering if anyone has advice for optimizing expressions and reducing the amount of redundant calculations.

 

At the moment, the only way I can think of to make a 'comp-level variable', is to create a text layer, calculate something in the 'Source Text' property, and have other expressions refer to that.  For numerical values, I might use a Slider or Point control for the same purpose, depending on the value type.  Does anyone know if this actually helps to optimize expression evaluation?

 

Thanks,

Bryan

Using a relative path to .txt in expressions

$
0
0

Hi there,

 

I am using an AE Expressions script to read in text from an external .txt-file. The script is working great, except for the fact that I need the path to the external .txt file to be relative to After Effects project folder in stead of absolute. The path can't be absolute since I will be using this project 'blindly' on different computers with different file structures/configurations. This is the script I'm using:

 

myPath = "absolute_path/vars/vars.txt";

try

{

$.evalFile (myPath);

eval(thisLayer.name);

}

catch (err){ "" }

 

I have already tried putting in a relative path in the variable myPath e.g. "myPath = "./vars/vars.txt". Unfortunately this does not work. I'm wondering if using a relative path in AE Expressions is possible at all and if not, what would be another solution to this problem? (Maybe there are some plugins out there that might solve this?) Any advice or help would be greatly appreciated as I am in kind of a pinch to figure this one out.

 

Greetings,

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.

Changing a value over time, based on previous frame

$
0
0

I have a layer that I need to move based on a number that gets calculated each frame. That number is added or removed from the position, but if you do something like this:


[value[0]+10, value[1]]


... you end up with 10 added to the original position, not the position that resulted from previous expressions. Is there a simple way to retain the calculated position? I've always worked using time to get a procedurally generated position, but that's not going to work in this case.

Viewing all 47983 articles
Browse latest View live


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