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

Camera Zoom Expression

$
0
0

Hi All, I've been recently using a workflow I quite like to create hundreds or thousands of instances of a 3D object in AE, and I'd like to take some of the guesswork out of it with an expression for the camera.

 

Let me give you an example of the kind of shot I'm working on. 

 

Imagine you're pushing in towards the window of an office building when it opens and out of it starts pouring hundreds of paper airplanes.  My workflow is to do the following once I've got the office building and the airplanes built in AE.  Design the camera move, with one airplane which follows a typical path.  Then use the perspective changes on that airplane to create a 2D "card" which can be fed to a particle system which replicates the move hundreds of times with minor variations.

 

What I'm trying to make:  a set of expressions to use with the camera for the purposes of creating the 2D card.   What it needs to do is point the camera at the object and control zoom.  Ultimately it needs to keep the object's  orientation and apparent size constant through the shot, so that the only change in the object that you see is the change in perspective.

 

I've been eyeballing this in the past and it works relatively well, but I think if I nailed it down I could have a really useful system for creating apparently 3D particles.   Thanks in advance for any help!


Inverse Opacity

$
0
0

I have two layers. I want one to be on while the other is off. Neither one can be visible at the same time. But one of them always has to be visible.

 

I came up with a pretty simple expression to make one layer fade off while another fades on.

b = thisComp.layer("White Solid").transform.opacity;

Math.abs(b-100)

 

But it doesn't work if either layer's maximum opacity is an artibrarty value (like Layer A's max opacity should be 70% and Layer B's is 30%). Yes, I could precomp to get opacities back to 100%, but I'd rather not.

Settings that affect sampleImage()

$
0
0

I have a script that uses sampleImage to find whether there is any visible content within the composition (the script adds a layer and applys sampleImage to it). Somebody who is using the script is experiencing some issues. In one project, the sampleImage expression fails to find the visible layer. What makes it complicated is that I ran the script on my computer with the same project and did not experience any problems. The user has tested the same script on other projects and it has worked fine.

 

Are there any after effects settings that affect sampleImage() results?

 

The user who is experienceing the problem is working in AE CS6 on a mac. I tested his project in CS6 on Windows, but I have tested the script in CS6 on my mac also and haven't had any problems.

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

Track nested child layer's position

$
0
0

Hi,

 

I have a Main Comp with a layer named 'Controller'.I have several 2d layers parented to this controller.

Now,i need to precompose two of them.let's say this precomposition of these two layers is named 'precomp 1'.

How can i parent these two layers in the 'precomp1' to the 'Controller' in the Main Comp again via Expression?

 

Dan,any ideas?

How to create a simple bobbing up and down motion expression?

$
0
0

Hi, I have a 3D object that I want to continuously bob up and down but I'm having trouble finding an expression to do this.

 

I would use wiggle on the Z except wiggle creates random motion and I need consistant up and down oscillations.

 

It seems simple but I can't figure it out... any ideas? Thanks.

 

-Pete

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!

sampleImage() in 4-color gradient issue

$
0
0

hi there

 

I am trying a technique for logo/element removal that I saw in a post from a couple years back, where a tracked, solid "patch" is placed over the unwanted element, and a 4 color gradient effect is applied to the patch, which then uses the sampleImage() method to grab local colors around the element.

 

I've gotten it working fine with the below code, except for one problem: when I parent my null (acting as a "color picker" position) to the original tracking info, the color no longer samples properly. Unparenting the null makes the sampling work fine, but then, I have to hand key the null, which is a pain and doesn't produce great results.

 

myPoint = thisComp.layer("Null 1").transform.position;

target = thisComp.layer("myAwesomeFootage.avi")

target.sampleImage(target.fromWorld(myPoint), radius = [1, 1], postEffect = true, t = time)

 

Any tips on getting around this parenting problem?

 

thanks!

 

ML


Increase and decrease a numerical text layer over time

$
0
0

I need to create a text layer with a numerical value that will range from 0% to 100% over time using key frames. I need the value to change over time, increasing or decreasing the percentage based on key frames. Any ideas? Thank you!

Limit value range with expression?

$
0
0

Hi there,

 

Is there a way to put a limit on value range when linking it to key-framed audio?

 

My situation is that I want to link the Glow Intensity of one of my objects to the key-framed audio. The issue I'm having is that everything north of 0.4 looks horrific.

 

So was wondering if there was anything I could add to the expression that will only allow the value of the Glow Intensity to vary between 0.0 and 0.4?

 

 

Cheers

Simon

toComp is not working correctly for Particular and Element 3d (pics included to demonstrate problem)

$
0
0

So, Im using AE CS6. The two plugins concerned are Element 3d and Trapcode Particular.

Im going to include alot of information since I'm not sure what would come in handy to know to solve this.

 

The final goal is to have the particle emitter follow the left wing of the object when the object is moved using the null named 'Scythe'. (See first photo)

'Scythe' is the brownish null at the center of the object.

 

I have used the follwing expression line on the Particles X,Y emitter:

thisComp.layer("Element Position 2").toComp([0,0,0]);

 

'Element Position 2' is the green Null you see in this picture, and is also the proper position for the particle emitter.

 

http://i.imgur.com/qtucKAx.png

http://imgur.com/qtucKAx

 

However, when this expression is applied it moves the emitter location. As shown in the following picture.

 

http://i.imgur.com/uSezbYY.png

http://imgur.com/uSezbYY

 

The emitter is only in the proper location on the first frame (first pic), on the second frame (second pic) and every frame afterwards, it is elavated to another position.

 

Can someone help me correct the new position without manually adjusting the ([0,0,0]) value in the expression line?

Delaying Expression

$
0
0

Hi,

I wanted to delay the scaling that is driven by an expression over a control slider. As in a tutorial video i put -10 at the end of the expression, but i don’t yet get the wanted timing delay of 10 frames.

How is it done right to delay the layer by 10 frames ?

 

I tried these and some more :

http://files.2he.com/uploads2/2014_02_14_12_17_54.jpg

http://files.2he.com/uploads2/2014_02_14_12_22_53.jpg

 

Tutorial:

http://files.2he.com/uploads2/2014_02_14_12_25_37.jpg

 

Regards,

Frank

Loop Composition creates flicker effect

$
0
0

I try to loop a composition within an other and used "Zeitverzerrung" (Time Warp) on this Composition. I added the Expression loopOut(type="cylce"). The Loop works fine but at the time of the second keyframe of Time Warp the Composition disappears. I don't know why but it creates a flicker effect I don't want to have. Thanks, Alex

Source Text Generated by Expression - Current Value?

$
0
0

I'm writing an expression to control the sourceText of a text layer based upon the length of another text layer. Part of the functionality is to only update the current layer text if there is a large enough change in length.  Is there a way to access the current value of the text layer that was generated by the expression?  value and sourceText.text point to the text set on the text layer, not the generated layer. 

 

Here's my expression

 

 function calc(prevValue) {  var textLength = thisComp.layer(1).text.sourceText.length;  var perc = thisComp.layer(2).text.animator("Animator 1").selector("Range Selector 1").start;  var newValue = 140 - Math.floor(textLength * perc / 100);  return (parseInt(prevValue) - newValue) < 10 ? prevValue : newValue;
}

//Need to pass the previously generated text value here...how do you access it?
calc(text.sourceText);



 

Couldn't find any way to access it in the expression references.

 

Thoughts?

Calvin

Snappier Wiggle?

$
0
0

How would you make a wiggle expression that radically reduced the time between values?  Like Wiggle that uses Exponential interpolation as inbetween values? So even though the pace would be something like wiggle(1,50), it would take much less than the 1 second wiggle interval to change between values.

 

Kind of like how a hummingbird feeds? It hovers, hovers, hovers... then snap into a new position.... hover, hover, hover... snap into new position.

 

Any ideas about this?

 

(Also, is the Jagged/Smooth option of the ancient Wiggler available in expression form?)


Have timecode reset at layer marker.

$
0
0

Hey guys.

 

I've been fiddling around with expressions for a bit but I can't get past this one.

Basically I need to create an expression which has a timecode counting up (minutes, seconds and frames).

 

But when it hits a layer marker it needs to reset. It needs to be able to react to layer markers from other layers too.

 

Can anyone help me out with this one?

 

Thanks in advance!

Smooth Rotation Expression

$
0
0

I will admit expressions are my downfall when it comes to After Effects. It doesn't help that anything dealing with numbers/math are a foreign language to me.

 

Anyway I need to make a still image of a dangling earring rotate back and forth on an ear. I tried wiggle and other expressions but was unsuccessful. I then created the effect manually with rotation keyframes. I am sure there is an easier way to do this especially since the image will be in the FG and blurred so the movement does not need to be exact just the illusion is enough.

 

I will need to also start and stop the movement which I think could be applied to the right expression with a slider control and just keyframing to 0.

toComp method on Puppet Pin position property returns bogus values

$
0
0

In trying to rig this girl character I've had a strange behaviour come up. I could work around it easily enough but it's getting to me that there's something I'm not understanding. My level of experience with expressions is relatively low but I have some Javascript experience so the main principles are clear.

What's annoying me is that my procedure works fine in a simple scene created wholly in AE. However when I import a .psd file (using composition-retain layer sizes), the same approach becomes useless. I feel like I'm missing something about layer sizes in relation to comps or something, or come upon a bug.

 

Ok this is my first post and its a little involved. I've always been able to find answers by searching online or in documentation. Here goes.

 

I'm trying to set up a character using Puppet Pins, which I will link to nulls as part of a more complicated setup down the road. My general approach is to set up the pins first and see how it all moves manually before creating nulls and linking the pins to the positions of the nulls. So far so simple. To get my nulls to the exact position of my pins, i pickwhip the null position to the pin position, see what the coords are, then remove the expression and put in the coords manually on the null. Once the nulls and pins are lined up, I just link the pins to the nulls with an expression in the pins "position" property.

 

This all works fine in my simple scene consisting of a solid layer with puppet pins applied, and some nulls. The nulls snap to the pins perfectly, and I don't have to convert the pin coordinates to comp space or anything. The pins coords seem to be in comp space already. Then I can link the pins to my nulls and all is fine.

 

However, in my complex scene which is generated from an imported .psd, the pin coords do not correspond to comp space. They're very low and seem to match up to the layer the puppet effect was applied to. So the null ends up way off near the top left of the comp.

 

No problem. We just run toComp on the position of the pin and we should get the comp space coords of the pin. But I don't. I get something way off.

 

Why do the pin positions not map to comp space automatically in my psd-based comp, as they did with the simple comp?

 

Is it even possible to run toComp successfully in the following way

toComp(thisComp.layer("R_Arm").effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 1").position);

or is the return of

thisComp.layer("R_Arm").effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 1").position;

not of the right data type to be an argument of toComp?

 

Are pin coordinates just layer based coordinates like any other or are there other factors involved?

 

I'd like to be able to set up pins where I want them and link them to nulls with exactly matching coordinates so the artwork doesn't jump when I link them.

 

More generally, is there any attribute of a psd file that can affect the coordinate system of a comp generated on import. The file in question contained all regular layers, plus one group of 3 (which came in as a pre-comp the entire size of the main comp, as expected), no layer effects or anything else fishy.

 

Anyone more experienced with expressions and coordinate spaces in AE have any idea what I'm missing?

 

 

 

 

Macbook Pro Early 2011 15" i7 2.2Ghz

16gb RAM

AMD Radeon 6750 1GB

OSX 10.9.2

AE 12.2.1.5

Can`t access to gradient colors in shape.

$
0
0

Hi.

Trying to access to gradient colors using expression.

I thought that I can access to them using array, something like this:

 

thisComp.layer("Cubes").content("Group 1").content("Rectangle 1").content("Gradient Stroke 1").colors[0]

 

But it work only for colors[0], rest of them (color[1]. color[2]) doesn`t work at all.

 

Maybe there is another option how to access them?

 

Thanks.

Expression Get Project Path or Name

$
0
0

Hi,

 

I am new to After Effects as in I have just seen it for the first time today!

 

What I'd like to know is, is it possible to write an expression to return either the current project name or file path?

 

I'm assuming no as I cannot find any reference to this in the language reference. How would I go about integrating a script with the project to return the project name?

 

I have tried something basic like:

 

Expression code:

 

var currpath = $.evalFile(filepath);

 

filepath is the path to my script file, the script is like the below:

 

GetPath()

 

function GetPath() {

 

return app.project.name;

}

 

With this I get an error similar to method name 'Global' not found - not at my work computer so can't remember the exact message.

 

Any help would be appreciated.

 

Thanks,

 

Mark

Viewing all 47983 articles
Browse latest View live


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