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

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.


Can I Animate Individual Characters in a Text Block Using the Wiggle Expression?

$
0
0

I'm new to After Express and just diving in to expressions. I was trying to figure out if there was a simple way to use the wiggle expression in a way that it would wiggle individual characters in a text block independently of each other.

 

Definitely appreciate any help.

Basic tween

$
0
0

Hi, I am new to the syntax in Expressions, but I use Greensock TweenLite a lot

 

I was wondering what the equivalent of this would be. The Graphic would be the Current layer, a duration of 3 seconds, and move in from the left -440 pixels with easing

 

TweenLite.from(Graphic, 3, {x:"440px", ease:Sine.easeOut});


This would be applied on the position keyframe.

 

Any advice appreciated

 

Thanks

Expression target multiple layers

$
0
0

hi,

I have several layers, all with the same expression (linked to expression controls)

I wondered if it's possible to have one instance of the expression script to target multiple layers?

Rather than pasting he same expression code on each layer..

Thanks

Rotation offset time

$
0
0

I have this code for Position offset time, but, how to turn it for rotation offset time? I have tried to change the "p" for "r" and "position" to "rotation" but still not working...

 

offset = -.5;

p = thisComp.layer("My Animated Layer");

t = time + offset;

p.position.valueAtTime(t);

 

Thanks

I use a common expression and get an error. Why?

$
0
0

Hey!

Hope someone can help a little or a lot!?!?

I am not into expressions at all and that might explain why i dont see the "misstake(?)" myself here but maybe you do.

 

I copy an expression code from several tutorials and get an error.When i change it a bit the function i want mainly works. But i still can´t use all of the trick because i get a 2nd problem (which might be because of the 1st??).

  • ok so here is the tutorial i watched, for example:

e.d.Films Tutorial: Rigging Multi-Layered Characters - Lesson 01 - YouTube

 

  • this is the code from the tutorial which does not work with me. ("kopf" is the name of my null obejct layer)

n=thizsComp.layer("kopf") nullpos=n.toComp(n.anchorPoint¬); fromComp(nullpos);

 

  • this is a little different code form a similar tutorial:

L =thisComp.layer("kopf"); value+L.toComp(L.anchorPoint);

 

Insteadt I use a different expression which is made by after effects automaticly when i do the following: pressing alt and clicking the clock, pulling the spiral thing to the position of the null object. if i pull the spiral to the entire null object i get an other error too.

  • my code which seems to work till now:

thisComp.layer("kopf").transform.position

So i dont understand why everyone has these n= and l= things everywhere to begin with. after effects seems to have a problem with that or writes it different it self...?? i dont know. this confused me.

 

  • this is the error (german):

After effects warnung: expression wurde augrund eines fehlers deaktiviert.

Fehler in Zeile 1 in Eigenschaft „position“ von ebene 10 (´kopfhals´) in komposition ´kopfhalsnase´. erwartet: ;.

 

 

the 2nd problem i get in the following is :

after i pined the subject, created null objects and connected them to the pins i connect the nullobjects with eachother via the spirals. it kind of works but every point of the subject gets now totaly distored and jumps somewhere randmomly...

This does not happen in any of the tutorials... why, how???

 

hope you understand me, know exactly what to do and tell me...   I could get screenshots in case i was very ununderstandable...

thanks

Use After Effects Expressions to check if a layer is 2D or 3D

$
0
0

Is it possible within an after effects expression to check if a layer is 2d or 3d?

 

 

Thanks in Advance!

sourceRectAtTime difficulties

$
0
0

Hi all,

 

So I've done quite a bit of research on this new expression "control" and it has tons of possibilities, but I can't get it to work exactly as I want it to and I'm hoping someone here has some insight.

 

I'm looking at it to control the background shape around text that's input through the newish After Effects editable text for text boxes/lower thirds, etc in Premiere.

 

Evan Abrams is from whom I initially received the info from in his tutorial: SourceRectAtTime() Expression- Adobe After Effects tutorial - YouTube

Here is his expression work:

 

This is the expression we wrote on the size:

s=thisComp.layer("Hello people");

x=s.sourceRectAtTime(time-s.inPoint,true).width;

y=s.sourceRectAtTime(time-s.inPoint,true).height;

[x,y]

 

This is the expression we wrote on the position:

content("Rectangle 1").content("Rectangle Path 1").size/2

 

Works kinda well, but generally only with left justified text for both x and y dimensions AND he failed to point out that the anchor point of the shape layer needs to go to the top left point of the shape layer.

 

Someone responded to his video about trying it for right justified text and figured out that if the expression for the position is changed from:

 

content("Rectangle 1").content("Rectangle Path 1").size/2


to:

 

content("Rectangle 1").content("Rectangle Path 1").size/2*-1



Unfortunately, this doesn't work with multiple lines of text.

Also, the respondent point out that if the position expression is deleted, one can use the center justified text and have it work... but only for a single line of text.



Dan Ebberts pointed out an alternative solution here using solids:


//scale

 

t = thisComp.layer("text");

margin = 20;

r = t.sourceRectAtTime(time,true);

w = r.width*t.scale[0]/100 + margin;

h = r.height*t.scale[1]/100 + margin;

[w/width,h/height]*100

 

// position

 

t = thisComp.layer("text");

r = t.sourceRectAtTime(time,true);

s = t.scale;

ap = t.anchorPoint;

p = t.position;

x = p[0] + (r.left + r.width/2 - ap[0])*s[0]/100;

y = p[1] + (r.top + r.height/2 - ap[1])*s[1]/100;

[x,y]

 

Unfortunately, when one does the import of the comp from AE to Premiere, the text justification is correct initially, but when the text is changed in premiere the whole thing breaks and it defaults to a left justification for the text and that requires moving the box and text in Premiere to make it how it appeared in AE (although the center justification is lost) and I don't want to have to modify the position property in Premiere.


I found this expression control on Reddit:

 

[–]dfreynoldsMoGraph/VFX 10+ years1 point 8 months ago*

Create a text layer with some text, called "A Text Layer"

Create a shape layer with a Rectangle Path element in it.

Put this expression in the size property of the Rectangle Path:

theTextLayer = thisComp.layer("A Text Layer");

thePadding = 40;

theTextRectInfo = theTextLayer.sourceRectAtTime(time);

theWidth = theTextRectInfo.width + (thePadding*2);

theHeight = theTextRectInfo.height + (thePadding*2);

[theWidth,theHeight]

Put this expression in the position property of the shape layer:

theTextLayer = thisComp.layer("A Text Layer");

theTextRectInfo = theTextLayer.sourceRectAtTime(time);

theX = theTextLayer.toComp([0,0])[0] + (theTextRectInfo.width/2);

theY = theTextLayer.toComp([0,0])[1] - (theTextRectInfo.height/2);

[theX,theY]


 

 

But as with the other examples, it cannot handle changes in the text justification or multiple lines of text correctly unless everything is left justified in AE.

 

I need to have an expression control on the text and background shape layer that I can modify for left, center and right justified text that can allow for multiple lines of text to be input in Premiere and it keeps it's original location as it's tested in after effects.

 

Any ideas?

 

Thanks for any help you might have!

 




substring() not a function?

$
0
0

Hi!

 

trying to do the simple task of separating 6 characters (numbers) and adding a space after the first 3.


My script reads:

 

 

siffror = parseFloat(Math.round(thisComp.layer("Räknare Slider").effect("Slider Control")("Slider")));

s1 = siffror.substring(0, 3);

s2 = siffror.substring(3, 6);

"Co2 saved: " + s1 + " " + s2 + " ton";

 

it says siffror.substring is not a function.

 

What am I doing wrong here?

Expression error using checkbox control

$
0
0

I'm trying, for the first time, to create an expression that controls a value depending on whether or not a keyed checkbox is on.  This is my code.

 


x = comp("overlay grain").layer("frame").transform.position;

 

If (effect("Frame Stutter")("Checkbox") == true)
{
    value = x + wiggle(25,5);
}
Else
{
    value = value + wiggle(25,5);
}

 


When I run this, I get the error:

 


After Effects warning: Function If is undefined
Expression disabled.

 

Error occurred at line 3.
Comp: 'main'
Layer: 1 ('Date Stamp')
Property: 'Position'

 


I have been racking my brain over what the problem is.  I have used If/Else statements in the past successfully and I know that there is just something very simple that I am missing.  I have also tried using "== 1" instead of "== true", but I got the same result.

 

Help please.

AE CS6: Render glitches with timeremap expressions

$
0
0

Version:

11.0

 

OS:

Mac 10.7.4

 

Source Footage:

.ai files

 

Problem:

 

First of all, we've been using this method for character animation since AE 7.0.  We have had minor glitches here and there, but nothing consistent enough to a real problem.  We're currently using CS5.5, and considering the CS6 upgrade.

 

I am filing an official bug report for this, but am curious if anyone else is experiencing this.  I don't want to share my project here as it's for a TV show in production.

 

Starting with CS6, we're experiencing random, arbitary render glitches all over the place.  Our character comps are generally two comps deep.  Meaning in the character comp, we have timeremapped comps for sequences of eyes, eyebrows, mouths, etc.  Inside those comps, there is a lot more going on than just an image sequence.  We have mesh warp keyframes and other stuff.

 

All of this is controlled by various expressions that link everything to some simple master controls.  I'm sure this sounds familiar -- it's very similar to the method used in these tutorials, but not even as complex.

 

As for the glitches, they are hard to pin down.  There are different glitches depending on whether the character is continually reasterized in the scene or not, which comp we're in, etc.  Really random.  The problem is resolved by proxying those precomps (the eyes, mouths, etc) with prerendered sequences.  This is an OK workaround for most cases, but we can't depend on it.

 

Thanks for any help.  In the meantime we'll be sticking with 5.5.

 

Bryan

Accurate Timer For Sports

$
0
0

Hi all. I'm trying to make an expression you apply to a text layer to time sports videos accurately. So far, I have the minutes and seconds figured out, but can't seem to get the milliseconds to work. They keep adding extra values past 100 which is what i dont want. Whenever it reaches 100 it should start over.

 

milli = Math.floor(time*100);

sek = Math.floor(time%60);

min = Math.floor(time/60);



if(sek<10)

{

   "0" + min +":0" + sek + ":" + milli;

}

else

{

   "0" + min +":" + sek + ":" + milli;

}

Paths, Keyframes, and Expressions

$
0
0

Hi,

 

Is it possible to change the shape layer path keyframes via expressions? For example:

key(1).value = thisComp.layer("Reference").content("Smile").path;

key(2).value = thisComp.layer("Reference").content("Frown").path;

 

In theory, the result should be that the path's first keyframe would look like a smile and the second keyframe would look like a frown.

 

But that isn't happening. Instead, the path has the shape of whichever value is on the last line of the expression, regardless of which keyframe it is at. Am I doing something wrong? Why is this happening?

 

Thank you so much for your time,

 

--Saib

Repeat news ticker seamlessly

$
0
0

Hello,

 

I am making a news ticker and I am happy with the design result so far. The only thing what's left is repeating the ticker.

 

This is my current setup:

 

  • Main comp
    • Main news-ticker comp
      • News content composition
        This comp has a time remap expression:
        loopOut("cycle", 0)
        And 2 keyframes. One at the beginning and one at the end. **

        • Inside this composition is a text layer. This is one line of multiple news items. It scrolls with the following expression on the position:
          offset = 8.34; // Value in pixels per frame
          x = timeToFrames() * offset;
          value - [x, 0]


** I am looking for a solution to let it loop seamlessly. So the first news items should connect to the last news item and so on..

Do I need a separate expression for this? Or is there any other trick to accomplish this?

Text Anchor Point / Alignment

$
0
0

I Have a Shape and a Text;

 

  • Put "sourceRectAtTime()" expression in Shape size, to be equal Real Text size in pixels. That is, not the size in pixels shown in Chacterer box (nominal size in pixles).
  • Need keep Text, always, on top of Shape aligned.
  • I assured that Text and Shape properties were:
  • Comp = 1280x720
  • Text and Shape:
  1. Achor Point [0,0]
  2. Position [640,360] (middle Comp size)

 

  • I expected to see the text on the shape, perfectly aligned.

forum.PNG

But the value of Anchor Point to Shape is not equal to Text.

"0" for text is = middle in width and low in height.

"0" for shape is  = middle in width and middle in height.

 

Yes, i can drag text to the alignment of Shape.

In reality, the problem is not Height. Not even in Anchor Point. But in Width Position. Why, when I change the text, there variations in the position. Look:

forum2.PNG

When I change text, with Anchor Point is okay, always in center, but the position becomes misaligned.The text leaves the Shape position, going to the right.

This should happen because of variations in the width of the letters, the "sourceRectAtTime()" expression is extremely sensitive to the letters.

 

When I drag to the correct location looks like this:

forum 3.PNG

Except that I can not be dragging, I need everything lines up forever, automatically. Even though I change the text.

 

How to solve this problem?

 

Update: Please, note that if I put some "symbol", larger in height It is also impaired:

forum 5.PNG


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.

Exponential Scale and Linear Move

$
0
0

Hello i'm trying to scale 2d layers exponentially. My problem — when I add 2 linear keys to move the layer — scale looks like bouncing. The expo scale code I found on adobe is <a href="https://forums.adobe.com/message/1899077">here</a>. My result comapred here: Project <a href="https://www.dropbox.com/s/41typw3o2zgsugw/Expo%20Scale.aep?dl=0">(CC)</a> or <a href="https://www.dropbox.com/s/gp0edzq00for54l/Expo%20Scale%20copy%20%28CS6%29.aep?dl=0">(CS6)</a> Please anyone help!<br> <img src="http://i1331.photobucket.com/albums/w586/amberija/Exponential-Scale-Half_zpsu5qfc4sd.gif" />

How can I load external file .txt in After Effects CC 2014.0 Release / Mavericks OS X 10.9.4 (13E28)?

$
0
0

ello everybody.

 

Someone can help me to load a external file .txt in After Effects CC 2014.0 Release / Mavericks OS X 10.9.4 (13E28)?

 

I tried the code bellow, but doesn't work.

 

try{

myPath = "~/Desktop/source.txt";

$.evalFile(myPath);

eval(thisComp.name)[0];

}catch(err){

"MISSING";

}

 

The source.txt file have the texts bellow:

 

var comp1 = ["Title”, “Subtitle”, “Description”];

var comp2 = ["Text 0", "Text 1", "Text 2"];

var comp3 = ["Text 0", "Text 1", "Text 2"];

 

Thanks.

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,

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

Viewing all 47983 articles
Browse latest View live


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