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

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.


Referencing the expression of another layer

$
0
0
i have a somewhat lengthy expression that will be applied to all transform properties of all layers in a project. i would like to be able to easily update this expression and have that update ripple through all elements using it. my question is: is there a way to dynamically copy the expression of another layer? does the expression field itself have a name that i can use to copy it?

 

i want to do something like this:

thisComp.layer("layer_name").transform.position.expression;

 

where "expression" at the end is whatever the name of the expression field is. any help would be greatly appreciated.

Dan's Universal Counting Clock

$
0
0

Hey Dan!

 

I was trying to get your Universal Counting Clock to stop when it hits 00:00:00, but this part threw me:

 

 

if (clockTime < 0){

  sign = "-";

  clockTime = -clockTime;

}else{

  sign = "";

}

 

I tried

 

if (clockTime < 0) {

  clockTime = 0;

 

but it kept counting. How would you get it to stop counting (either up or down)?

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

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)

loopOut() script won't loop keyframes. Why?

$
0
0

Hello. I am using AE cs6 win version.

Right now I am trying to loop key frames using loopOut() expression, but it won't loop.

Please see this video.

 

 

Moving of The pale blue square is what I want, but if I use loopOut() expression to make such moving, it makes this green square movement. This green square has only 2 hold interpolation keyf rames on x position, and I just use default loopOut() expression. Seems green square's key frame 2 is ignored after first loop by loop expression.

Do you know why? Thank you in advance.

delay scale parameter from the shape layer repeater

$
0
0

Hi,

 

 

I want to animate the scale parameter of the repeater effect and delay it on several shapes.

 

 

I've tried with this expression using 2 expressions sliders but without success

 

 

thisIndex=thisProperty.propertyGroup(3).propertyIndex;

effet=effect("repetition echelle")("Curseur");

delai=effect("delai")("Curseur")*thisComp.frameDuration*(thisIndex - 1);

[effet.valueAtTime(time - d),effet.valueAtTime(time - d)]

 

 

I've searched through the web but didn't find anything about it and I'm wondering if it's even possible

 

 

Any clue ?

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


How to delay opacity following another layer

$
0
0

Hello All.

 

I have 100+ layers that I would like to fade on in a delayed fashion following the manual opacity key frames set in a 'master' layer. Thus, each of the 100+ layers will incrementally fade on by half a second — after the 'master' layer has faded in.

 

My research has led me to this expression:

 

thisComp.layer("leader").transform.opacity.valueAtTime(time-thisComp.frameDuration)

 

however the above fades in all 100+ layers simultaneously. I'd like the layers to fade in one after the other.

 

 

Can anyone suggest the script to make this happen please?

Expressions by Accident

$
0
0

So I'm working along on a composition, nothing fancy. NOT using any expressions, at least on purpose. Moving layers around etc. I think I was moving several layers forward or backwards in time.

 

Then I go to change some Transform parameters and they're red and can't be changed. I twirl down and find each Transform parameter has an expression similar to this

 

comp("Demaria_rev1").layer("AA188202.MXF").transform.anchorPoint

 

Question 1, how did this happen? Whatever I did it applied to many layers, I think at one time. It also happened to Effects such as Keylight where parameters such as Screen Gain had this

 

comp("Demaria_rev1").layer("AA188202.MXF").effect("Keylight (1.2)")("Screen Gain")

 

I have no idea what I did to get all these expressions - it doesn't seem like they do anything either but maybe I'm missing something. It just seemed to lock up certain parameters.

 

And question 2, is there a way to globally remove the expressions? Reset doesn't seem to do anything and manually going to each one is time consuming.

 

Any info is appreciated.

 

Thanks

Math.sin(Math.PI) strange result

$
0
0

Hi,

 

In my AE expression Math.sin(Math.PI) gives a result of 1.22E-16, in stead of the expected zero.

Does anyone know why?

keyframes control with layer markers

$
0
0

Hello,

 

I have an animation of a line that has two sets of keyframes of two different properties in CS4.

Basically a line gets generated in the first phase then it gets cleared out in the second phase.

This is done using two slider controls that act on the horizontal size of two rectangles and using merge paths (using the second rectangle as a matte for the first to clear it out)

 

I've put two layer markers on my layer hoping to link the keyframes to each of them.

 

Then I have found this script on the web and I put it on the first property :

 

L= thisComp.layer("ShapeLayer");

n = 0;

if (L.marker.numKeys > 0){

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

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

n--;

}

}if (n == 0){

valueAtTime(0);

}else{

t = time - L.marker.key(n).time;

valueAtTime(t)

}

 

This indeed lets me move the whole animation with the layermarker (which is very good) but I can't find a way to link the second set of keyframes to do the output.

I will add a link with the project file: WeTransfer

 

Please help!

Thanks

Ticking Clock

$
0
0

We have all seen the old clock rotation expression where you create a rotation for the second hand and then tie the minute hand to the rotation with an expression so that it moves at 1/60th the speed to simulate minutes and seconds right?

 

I am trying to create something similar but with a 'ticking' clock like a timex watch on the second hand so that it ticks along. tick, tick, tick, tick instead of the smooth rotation. I have worked that out using this expression tied to rotation:

 

var tick = time*6;

Math.floor(tick)

 

 

But what I want to happen is now to have the minute hand ( separate layer ) tick over 6 degrees every minute. In other words, it holds for 59 seconds and then jumps 6 degrees in 1 second.

 

I can't figure that part out. Any ideas?

 

Thanks

 

Jim

Change expression editor font

$
0
0

It's sometimes tricky (on windows, anyway) to accurately select text in the expressions editor. I end up using an external editor and copy/pasting most of the time.

 

Is it at least possible to change the expression editor font to a monospaced one (using some sort of preferences hack, maybe?)

 

Thanks

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?


Visualising audio as analog VU meter

$
0
0

Hey,

 

So I'm kinda new to AE, but I know enough to get around so that's clear now.

So I'm starting up a YouTube music channel and I'm trying to find out how to represent audio as an analog VU meter.

The image I am working with is below, and as you can see, it has 7 empty VU meters which I want to represent each track I have (7).

Does anyone know of how such thing would be done?

 

Thanks,

James.

 

background-VU.png

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.

Very long time remapping : Memory leak

$
0
0

Hi,

 

I want to submit what looks like a bug to me, publishing it here might help other who encounter the same issue.
If you have a very long composition in which you apply a time expression expression (scripting), depending on what is inside your expression, After Effects might try to fill the memory until you can't do anything and have to restart AE .

 

I have to precise my expression is quite weird but not very long to compute.

 

Antoine.

How to get an Array of all layers in the current comp

$
0
0

In expressions, how do you get a list of all layers in a comp?  The following doesn't work and errors with "property or method named 'layers' in Class 'Comp' is missing or does not exist":

 

allLayers = thisComp.layers;

How do I add a 3D wiggle expression to a seamless loop expression in After Effects?

$
0
0

I am using this xyz wiggle expression for several layer (each layer having slightly different integers to have different movement.

 

 

a =wiggle(0.2,150);

b =wiggle(0.15,160);

c = wiggle(0.2,500);

[a[0],b[1],c[2]]

 

But I want to make it a seamless loop. I found another expression that does this, but it is not in 3d space.

 

freq = 1;
amp = 110;
loopTime = 3;
//this will be changed to 6 seconds
t = time % loopTime;
wiggle1 = wiggle(freq, amp, 1, 0.5, t);
wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime);
linear(t, 0, loopTime, wiggle1, wiggle2)

 

How can I merge the expression?

Viewing all 47983 articles
Browse latest View live


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