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

How to get the footage's current frame number in expression?

$
0
0

There are 2 layers.One is text layer,one is sequence layer.

Footage has begun from the 20th frame.

Therefore, the number of composition's current frame number and footage's frame number has shifted.

 

I want to show footage's frame number in text layer . not composition's frame number.

How to get the footage's current frame number in expression?

 

 

Tatsuya


inertial bounce expression

$
0
0

hello everyone i have after effects cc and windows 8.

 

when i was on ae cs6 i used this expression and it worked perfectly

 

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

freq = 1.0;

decay = 5.0;

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

}else{

value;

}

 

now on ae cc it works for 1 minute and then this error pops up:    (in this case i applied the expression on the position of a null object with linear velocity)

 

 

After Effects warning: an expression was disabled as a result of an error.

 

Error at line 19 'Position' of layer 2 ('Null 7') in comp 'Comp 4'.

invalid numeric result (divide by zero?)

 

 

how can i fix this error? that expression was very very helpful!

 

thx!

Make clone-stamp relative to tracker

$
0
0

Hello!

 

I am not sure that the answer for my question isn't already out there, but I was not able to find the exact solution to my problem. Most tutorials and help-topics focus on copying something from a still frame.

 

I have a scene where camera-equipment is in the background and definitely has to be replaced.because it is quite obvious. The area around the object is not moving, and since the camera was on a tripod and the object was far away the changing of the perspective can be ignored. Unfortunately, there are light changes in the scene, so clone-stamping from a single frame does not work for this shot. So I want to do the following:

 

1. Track the position of the object with the AE tracker.

2. Clone-stamp the object away in a single frame.

3. Make the clone-stamp apply for all frames, with all positions (clone-source, clone-path) relative to the tracker (which I applied to a null-object). The clone-source-frame should always be the same as the clone-target-frame so that the light conditions match.

 

I currently have no clue on how to do the third step. Pickwhipping does not really work, since it has no direct capabilities for relativ positioning. Writing all of this with expressions would be very time-consuming, since I have around 10 clone-stamps. Does any of you can help me with a workflow for this? Is there built-in functionallity for this?

 

Thanks in advance! Greetings,

Jonathan

Font Size Expression

$
0
0

I need an expression that would automatically change the font size based on how many characters are typed in.

 

The goal is to fit multi-line text into a bounding box as it's read from the external text file.

 

Does anyone know whether it's possible through an expression, or SDK by writing a plugin?  So far I was unable to find any info on this topic.

 

Thanks for any ideas.

Using Expressions to stop and start movement of solid layers

$
0
0

I have two solid layers ( a red square and a blue square). The position of the red square is [129,239] and the blue square is to the right of the red square with a position [301, 240].  I would like the blue square to move to the right for 2 seconds, 1 second after I start the timeline.  When the blue square stops moving I would like this to trigger the red square to move to the right for 2 seconds.  I would like to perform this using all expressions code without creating keyframes on the timeline and I'm having trouble.  Please help!

 

Thanks

Multiple Expressions

$
0
0

Is there any way that I can patch the same expression in the same property layer multiple times? What if I would like my camera to execute the same expression at different points in the composition?

Reading thisComp FPS?

$
0
0

In this global expression:

 

timeToTimecode(t = time + thisComp.displayStartTime, timecodeBase = 30, isDuration = false)

 

 

Instead of being coded to 30, is it possible for timecodebase to read the current comp's FPS automatically?

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)


Math.pow(Math.E, time)

$
0
0

Hi folks!

 

The expression

 

"Math.pow( Math.E, time )" keeps giving me a "divide by zero" error.

 

This seems to be similar to problems others have had, but the other solutions don't quite work in my case, since Math.E isn't negative.  "time" of course is a non-integer, but the expression doesn't even work for me if I replace it with "Math.ceil(time)." 

 

Can anybody tell me what I'm missing?  Thanks in advance!

 

--S

3D WARP/3DBEND: geometry expression no show?

$
0
0

"3D warp" as seen on tv.adobe "What's New", does not seem to be available on my version of CS6 AE (from disk). I'm not getting the geometry option even though,I have the 3D box checked and it is a pixel based layer. I do get the other expression options such as transform and material options. Can anyone help me bend stuff?

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?

How to automate the length of a rectangle solid to a text layer ?!

counting up $ numbers using expressions

$
0
0

Math.round(effect("Slider Control")("Slider"))/100

I am counting up from 7.25 to 15.00 and have to manually add the $ mark and 00 at the end of the animation. The decimal place doesn't stay in place when double digits appear.

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!

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.


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!

walk cycle: how to avoid slipping legs?

$
0
0

hi

 

I wonder if there's an expression which would allow me to synchronize walking character's steps with its horizontal position? I animate two-legged character's legs for walk cycle, but when i animate the whole character's X axis position it's very hard to avoid its legs from skidding across the surface. any free or non-free plugin/expression for this?

Can I connect a particle emitter to the position of a 3D null?

$
0
0

I'm trying to connect a particle emitter to a 3D null instead of lights. The reason is that when I connect Particular to a light it no longer seems to have any directional control. So I can't rotate it and make all the particles shoot in one direction, for example. All the rotate functions are disabled.

 

I'm trying to make a plane in in Video Copilots Element 3D look like it's firing bullets. I have a light attached to the muzzle of the gun but I had the directional problems I just outlined. So now I'm trying to attach the emitter to a 3D null object that will replace the light.

 

I'm not great at coding so if there's a way to control the direction of light emitters, or attach an emitter to a 3D null... or even a better way altogether I'd much appreciate the help.

 

Many thanks.

 

SJ.

Is it possible to call a script file from an expression?

$
0
0

Hello everyone,

 

tl;dr Accessing path vertices via expression doesn't seem possible, but scripts can, so is it possible to do it by calling a script file inside the expression?

 

My goal is to access the number of vertices in various path objects and use this value in an expression. The expression is driving a trim path's offset property and the expression use relative naming so that I can copy the trim path to 500 other shape layers groups and have a different effect (speed of the offset) for each group depending on the number of vertices of each path.

 

I've been looking for a solution to this problem for quite some time now and my conclusion is that you simply cannot access path vertices via expression, whether the path is in a mask or a shape layer.

Is this correct?

 

With a mask on a solid layer and according to the After Effects Scripting Guide I should be able to do:

thisComp.layer("Black Solid 1").mask("Mask 1").maskPath.value

or

thisComp.layer("Black Solid 1").mask("Mask 1").maskPath.value.vertices

or

thisComp.layer("Black Solid 1").mask("Mask 1").maskPath.value.vertices.length

I also tried:

thisComp.layer("Black Solid 1").mask("Mask 1").maskPath.vertices.length

and so on...

 

But when debugging this with the source text of a text layer I only get "undefined" for the value and errors for the other expressions ("property named 'vertices' in Class 'Property' is missing or does not exist").

I'm pretty sure these are the correct methods since a lot of scripts are using those, including:

http://omino.com/pixelblog/2008/12/25/ae-mask-vertices-from-extendscript/

http://www.crgreen.com/aescripts/actual_scripts/Connect_Point_to_Mask_Vertex.jsx

http://aescripts.com/maskvertexexpression/

 

So if directly accessing the path arrays via expression is not possible, I was thinking about calling, in each expression, an external script which would then return the number of vertices there is in each arrays. It would look like something like this (pseudo-code):

arrayLength = content(thisProperty.propertyGroup(2).name).content("Path 1").value.vertices.length

return arrayLength

And then use the value I get from the script to adjust the speeds in my expressions:

time*arrayLength*thisComp.layer("Controller").effect("Speed")("Slider")

 

So is it possible to call a script file inside an expression? How?

If not, do you have any other suggestion?

 

Thanks.

 

Reference: After Effects CS6 Scripting Guide, page 172.

AfterEffects Expression Text Row

$
0
0

Hello could some please help.

I have a single text layer with a row of numbers. I would like each number in the row to change after a set time. I would like each string to be different length as well.

 

Eample

(Row 1) 348920

(Row 2) 934

(Row 3) 9

(Row 4)4324

 

I would like to be able to change the number of rows and how long each sting can be (Set a Max & Min)

 

So in every 4 secs a new row would appear and the length of each row would be different.

 

I hope its clear, if not please let me know. I will try to explain it better if I can

 

Thanks for any help

Viewing all 47983 articles
Browse latest View live


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