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

Fill Color Controller to change between colors overtime

$
0
0

Hi All,

 

I'm using CS6 AE..

 

I have created a clapometer style animation that uses a colour controller and value/numbers controller to animate the hand from left to right of a semi circle. As the hand moves (by a value slider) the layer underneath fills and I would like the color to go from yellow to red via multiple colors.

 

So far I have this code on my fill layer

 

l=thisComp.layer("Fill color controllers");

i=1;

colors=[];

try {

while(l.effect(i)) {

if (l.effect(i)(1).name=="Color") {

colors.push(l.effect(i)(1).value);

}

i++;

}

} catch (e) {}

if (colors.length) {

r=Math.floor(random(colors.length));

colors[r];

} else {

}

 

And a fill color controller layer with 5 different color expression controls. At the moment the code cycles through them randomly, but I would like cycle through the list. I know there are other ways I could do this but I am trying to improve my expression knowledge and hope someone can help me!

 

Cheers!


global array variables? , transfer data from one layer expression to another

$
0
0

hi i have arrays in expression, but i have a problem, every time when i move effect point control(i need move it for my task)  array update and erasing, but i need to save data from previous array state

 

 

i add this expression to text layer on Source text

//create array

var arrayX = [];

var arrayY = [];

//add data to array

arrayX.push(12);

arrayX.push(232);

arrayX.push(2424);

arrayY.push(0);

arrayY.push(322);

arrayY.push(122);

text_cur_layer = text.sourceText;

//final result

text_cur_layer ="Array_X= "+arrayX.join( ', ' )+"\r"+"      Array_Y= "+arrayY.join( ', ' );

 

 

expression return 

in array x must be (12 232 2424)

in arrayY  must be (0 322 122)

 

 

so every time when i change state on effect "point control"(slider control and etc) this expression updates and give me always same numbers, from this commands^

arrayX.push(12);

arrayX.push(232);

arrayX.push(2424);

arrayY.push(0);

arrayY.push(322);

arrayY.push(122);

 

 

it happened because i create array every time with

var arrayX = [];

var arrayY = [];

i think this commands erasing all data from array and create new clean array, so i need some how save previous data...., in AE script i can do that with creation array

globally for all functions, but don't know how  do this in expression

 

 

 

 

also i think it can be done with transfer data from array to string and save this string in another layer and then get this data after array creation, but i don't know how i can save array string data and export this string back?

 

 

example

 

 

var arrayX = [];

var arrayY = [];

//try import previous data back(i don't know how do that, just using standard java code..)

//and now i need get data from strX strY from save place and chekc it later

if(strX!=null && strY!=null)

{

arrayX=strX.split(',');

arrayX=strX.split(',');

}

//add data to array

arrayX.push(12);

arrayX.push(232);

arrayX.push(2424);

arrayY.push(0);

arrayY.push(322);

arrayY.push(122);

text_cur_layer = text.sourceText;

//final result

text_cur_layer ="Array_X= "+arrayX.join( ', ' )+"\r"+"      Array_Y= "+arrayY.join( ', ' );

//get data to save

var strX = arrayX.join(',')

var strY = arrayY.join(', ');

 

 

and then i need some how save this strX and  strY  to save place

 

 

 

 

Sorry for bad English

Trying to automatically place and fill lower thirds triggered by comment markers

$
0
0

Hi,

 

 

I'm currently trying to solve a workflow idea based on the idea of script Guru Dan Ebberts of creating automatic subtitles from speech transcription markers (here is his script which works great for subtitling):

 

 

//****************************************************

// This expression creates a text string consisting

// of groups of five marker comment fields

// (separated by spaces). Each text string is displayed

// when the current time has reached the first marker

// of that group.

 

 

L = thisComp.layer("Legato_Ames_BTS_02_trans.mov");

max = 5; // number of words to display

 

 

n = 0;

if (L.marker.numKeys > 0){

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

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

    n--;

  }

}

 

 

 

 

s = " ";

if (n > 0){

  base = Math.floor((n-1)/max)*max + 1;

 

 

  for (i = base; i < base + max; i++){

    if (i <= L.marker.numKeys){

      s += L.marker.key(i).comment + "  ";

    }

  }

}

s

 

 

 

 

This script reads out the comment contents on the specific layer "Legato_Ames_BTS_02_trans.mov" (which have automatically been created via analyzing speech).

 

 

My idea was to modify the script that it reads not only the markes on the specific layer but in ALL layers within this composition.

 

 

Then I created a lower third animation (e.g. a new composition) which I also want to trigger its start everytime where a marker is placed on one of the layers within the composition so that when the playbar hits a marker, the script reads out the comment content (which already works by the script above) and also starts the background lower third animation comp.

 

 

If this is not possible I would have to do without the animation and only create a second graphic lower third layer where only its opacity is triggered "on" and "off" (like fade in / fade out after 5 sec).

 

 

My second idea is to separate the two actions in two scripts: the first which reads out the content of the markers and automatically creates the text and on a second layer a script which triggers the animation comp to start at the same time.

 

 

I already got specific markers labeled "hit" to trigger e.g. an effect on an adjustment layer by the other great script of Dan, but I only get this working on triggering effects, not a whole composition:

 

 

m = thisComp.layer("Layer 1").marker;

n = 0;

if (m.numKeys > 0){

  n = m.nearestKey(time).index;

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

  if (n > 0 && m.key(n).comment != "hit"){

    n--;

    while (n > 0){

      if (m.key(n).comment == "hit") break;

      n--;

    }

  }

}

if (n > 0)

  linear(time - m.key(n).time,0,2,100,0)

else

  0

 

 

 

 

I tried to figure out how I get these to actions combined but unless I'm not a coder I got stuck wiht that.

 

 

Anybody has an idea who to do combine these?

 

 

Thanks

How to make my expression to a preset?

$
0
0

Hi there,

I have a question. Is it possible to make my expression to be a preset so I can use it again and again. If it's possible, how to build a control for he variable value inside the expression in the preset? Thanks

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.

After Effects CS4 audio levels expression problem

$
0
0

Basically what I have is a layer with a checkbox. There is also an audio layer which has its audio levels linked to the checkbox by this expression:

 

if(thisComp.layer("White Solid 1").effect("Checkbox Control")("Checkbox")==true)
[5,5]
else
[-20,-20]

 

No matter if the checkbox is checked or not, when previewing the audio is played as if it had Audio Levels set to 0. When there is no expression, the audio levels can be controlled normally. But when the expression is applied, the Audio Levels is stuck at 0dB. This problem seem to be apparent only when previewing. After the audio is rendered, the file plays as it would be expected. Could anyone please help me with this?

 

EDIT: Also, the waveform seems to react normally to the checkbox.

dynamic text

$
0
0

hello!

i want to link the y values of a shape layer to a source text.

so i tried to pick whip the source text to the y position of a shape layer.

 

exp text.jpg

the problem is that when i animate the shape layer the text becomes very messy because it shows lots of numbers after the comma. as you can see in the video.

 

exp text 2 - YouTube

 

is there an expression to limit numbers after the comma or have integer numbers? thx!!!!

Parenting Layer Positions - Can Variations Be Added?

$
0
0

If I parent one layer to a child layer, then the child layer will move exactly the same as the parent layer. If the parent layer moves 200 pixels to the right, then the child layer will move 200 pixels to the right.

 

Is there a way to vary the way the child layer moves? Say, a lesser percentage of pixels?

 

See below. The parent layer is the right pupil, and the child layer is the left pupil. Both pupils are centered, and look like they're in the right place.

Screen Shot 2015-01-05 at 10.45.10 PM.png

The right pupil parent layer moves to the right, and the child layer left pupil moves the same distance. It's starting to look wrong.

Screen Shot 2015-01-05 at 10.45.37 PM.png

The right pupil parent layer moves all the way to the edge of the eyeball. Now the child layer pupil has left the eye socket, and seems kind of other-worldly.

Screen Shot 2015-01-05 at 10.46.06 PM.png

 

Is there a way to tell the child layer to somehow move less than the parent layer? Say, 70% or 80% of the distance of the parent?


Placing Solid From Nulls

$
0
0

Hey folks!  I'm trying to use 3 nulls to define a plane, and place a solid on that plane.  I found Dan Ebberts's expression for deriving the orientation of the solid (see below).

 

That seems to be working fine (hard to tell so far), but what I still need to do is set the position of the solid so that it intersects the 3 nulls (assuming it's large enough).  Otherwise, I've got a properly oriented solid, but it could be anywhere in space!

 

Please help if you can!

 

Cheers,

Ari

 

***

 

Dan's orientation expression:

 

UL = thisComp.layer("Corner 1").toWorld([0,0,0]);

LL = thisComp.layer("Corner 2").toWorld([0,0,0]);

LR = thisComp.layer("Corner 3").toWorld([0,0,0]);

u = normalize(LR-LL);

v = normalize(LL-UL);

w = cross(u,v);

sinb = clamp(w[0],-1,1);

b = Math.asin(sinb);

cosb = Math.cos(b);

if (Math.abs(cosb) > .0005){

c = -Math.atan2(v[0],u[0]);

a = -Math.atan2(w[1],w[2]);

}else{

a = Math.atan2(u[1],v[1]);

c = 0;

}

[radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]

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

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?

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.

Tracking puppet pin tool with null object track(HELP)

$
0
0

I'm trying to track my puppet pin tool to a null object.

 

I am using the code

 

n=thisComp.layer("NullObject_Name");
nullpos=n.toComp(anchorPoint);
fromComp(nullpos);

 

But ever time I assign the name of the null obect tp the puppet pin (eg. hair_bottom_left0)

 

n=thisComp.layer("hair_bottom_left0");
nullpos=n.toComp(anchorPoint);
fromComp(nullpos);

 

The pin tracks a different position and not the null object.

 

How do I get the pin to track to the null object I assigned it too?

Control Layer in point of expression % Number Count

$
0
0

I have an expression that Dan  Ebberts created for number counting with a percentage sign

 

beginCount = 0;
stopCount = 100;

 

beginTime = 0; // start counting at time = 0
countDur = 4; // count for 4 seconds

 

"" + Math.round(linear(time,beginTime,beginTime + countDur,beginCount,stopCount)) + "%"

 

For my animation the layer starts around 16 seconds into my timeline and the expression has already finished before then.  Is there a way to control the
in point for a layer for this expression?

 

Thanks very much

 

Ira

Random Frame Time Remap Expression

$
0
0

I work with a lot of hand-drawn loops and I'm curious about expressions that can randomize the frame playback of image sequences using the time-remapping property. 

 

For example, in traditional hand-drawn animation when you wanted to hold a pose without the animation looking static you would create what's called a traceback, which means you would physically trace at least 8 frames of the same drawing and then shoot them over and over again in a random order for however long you needed to hold the pose.  That way you don't get the exact same pattern of frames cycling over and over like you would if you just looped it.

 

Of course you can manually reorder frames in After Effects, but it's very time-consuming and I'm wondering if an expression could be written that could easily be modified for different sequences at different timings and different lengths.  For instance, I found this expression by Filip Vandueren on the Creative Cow website http://forums.creativecow.net/thread/227/12413  It was intended to randomize a 5 frame sequence, however the sequence and the comp have to be at the same frame-rate in order for it to work.  Therefore, I have to work at a 12fps sequence in a 12fps comp if I want the animation to look like it was shot on 2s.  Usually a 12fps sequence with no time remap expressions will play back on 2s if it's in a 24fps comp and as far as I can tell using time stretch or posterize time doesn't work.  Time stretch does nothing and posterize time crashes after effects when I add it to the image squence with the expression applied to the time-remapping property.  This probably has something to do with an expressions conflict that happens once time remapping is applied to the image sequence.  Anyhow, I'm asking if there's a way to modify this expression so that I could put my footage into a comp at another frame rate and use the expression itself to tell it to play at either 8fps, 12fps or any other frame rate.

 

This is Filip Vandueren's expression

 

seedRandom(1,true);

var t=timeToFrames();

var r1=-3;

var r2=-2;

var r3=-1;

for (var i=0;t>=i; i++) {

   var r3=Math.floor(random(5));

   if (r1==r3 || r2==r3) {

      t++;

      continue;

   }

   r1=r2;

   r2=r3;

}

framesToTime(r3);


This is an expression based on Vandueren's that I tried to modify for an 8 frame image sequence.  It sort of worked but it didn't really achieve what I was looking for.

 

timeRemap

seedRandom(2,true);

var t=timeToFrames();

var r1=-6;

var r2=-5;

var r3=-4;

var r4=-3;

var r5=-2;

var r6=-1;

for (var i=0;t>=i; i++) {

   var r3=Math.floor(random(8));

   if (r1==r3 || r2==r3) {

      t++;

      continue;

   }

   r1=r2;

   r2=r3;

}

framesToTime(r3);

 

The image sequence played all 8 frames randomly without duplicating them, but I still couldn't figure out how to make it play at 8fps or 12fps without conforming the comp frame rate to the frame rate of the image sequence.  Ideally I'd like the expression to determine the frame rate so that I can have it in a comp with other frame rates and not have to worry about disturbing the expression.

 

Reordering random frames is a common thing for 2D animators to do so I'll also file a feature request asking After Effects to add this feature to an existing plug-in or create a standalone plug-in.


"global" function in expressions

$
0
0

Hi guys,

 

I'm looking for something very basic with expressions but can't seem to find it. I want to define a function and use that function inside ~100 or so layers. At the moment I'm typing a couple of lines of code inside each expression layer to drive the position of each layer which is insane of course. I just want to define one function (and define it only once):

 

function getPosition(null1,null2,offset){

     ...stuff..

     return position

}

 

And in my comp, use that function everywhere to drive the position attribute for example:

 

getPosition("null5",null6",0)

 

Writing that function inside each expression is a bit daft of course but I can't seem to find a way to define such a function to use throughout my comp. Could anyone point me in the right direction? Thanks!

AE expression for "length of text layer" for lower thirds nameplate

$
0
0
Hello everyone,

Is there a way to measure the total width (and height) of a text layer, to automatically update the length (and height) of a shape layer? I produce web news segments with 7-15 lower thirds displays for each video. I'm looking for a more efficient way to re-size each nameplate. Currently I manually re-size each shape layer to fit the name. Is there an expression that will update the shape layer, based on the length (in pixels) of the text layer?

See an example video of what I'm talking about:
http://dallasvoice.com/dvtv_track.php?s=345
(look for the nameplates that animate in at the beginning of each interview)

I've read everything I can get my hands on, but nothing has helped. Any help would be appreciated!
-RY

Multiple Expressions -- how to?

$
0
0
I have both keyframes and a wiggle expression on the position property of a layer.

Can I stack expressions like wiggle(n1,n2) and loop_out("cycle",0) on the same property?

follow a leader with delay

$
0
0

hi

 

i have bunch of layers all distributed in z space.All in a row.So,they have all differenent position data.

Now the first layer starts to move towards the camera.After a specific time i.e 1.5 secs i want to move the second layer to move with the first one.etc.

 

thisComp.layer(thisLayer,-1).position.valueAtTime() doesn't work.

 

something similar to this>

start = 0; //start time of template motion
end = 4.0; //end time of template motion

 

t = thisComp.layer("template");
offset = (t.effect("offset")("Slider")/100)*(index -1);
travel = linear(t.effect("travel")("Slider")/100,start,end);
t.position.valueAtTime(travel - offset)

 

any ideas?

cheers

Building manual DOF with blur filters

$
0
0

I know AE CS5.5 has cool new camera blur for the AE cams.  But I'm working in a project that the client wants CS4   So I'm using a 3rd party blur plug-in.

 

Here's what I've come up. I apply a blur and an expression slider to each 3D layer. I also have 3D null that determines the Camera focus distance. The slider multiplier is there just to give me some manual control if an out of focus layer isn't blurry enough.

 

Is there a better way to write this?

 

L = thisComp.layer("Layer1");

O = length( L.toWorld(L.anchorPoint), toWorld([0,0,0]));

C = thisComp.layer("Camera 1").cameraOption.focusDistance;

M = effect("Blur Multiplier")("Slider");

(O + C) * .1 * M

Viewing all 47983 articles
Browse latest View live


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